Skip to content

Commit

Permalink
Add LiveImage support to host_state_machine
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Hardy committed Dec 17, 2020
1 parent 47ab27a commit 1b2bab0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
17 changes: 13 additions & 4 deletions controllers/metal3.io/host_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,25 @@ func (hsm *hostStateMachine) provisioningCancelled() bool {
if hsm.Host.HasError() {
return true
}
if hsm.Host.Spec.Image == nil {
if hsm.Host.Spec.Image == nil && hsm.Host.Spec.LiveImage == nil {
return true
}
if hsm.Host.Spec.Image.URL == "" {
if hsm.Host.Spec.LiveImage != nil && hsm.Host.Spec.LiveImage.URL == "" {
return true
}
if hsm.Host.Status.Provisioning.Image.URL == "" {
if hsm.Host.Spec.LiveImage != nil && hsm.Host.Status.Provisioning.LiveImage.URL == "" {
return false
}
if hsm.Host.Spec.Image.URL != hsm.Host.Status.Provisioning.Image.URL {
if hsm.Host.Spec.LiveImage != nil && hsm.Host.Spec.LiveImage.URL != hsm.Host.Status.Provisioning.LiveImage.URL {
return true
}
if hsm.Host.Spec.Image != nil && hsm.Host.Spec.Image.URL == "" {
return true
}
if hsm.Host.Spec.Image != nil && hsm.Host.Status.Provisioning.Image.URL == "" {
return false
}
if hsm.Host.Spec.Image != nil && hsm.Host.Spec.Image.URL != hsm.Host.Status.Provisioning.Image.URL {
return true
}
return false
Expand Down
32 changes: 32 additions & 0 deletions controllers/metal3.io/host_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ func TestProvisioningCancelled(t *testing.T) {
Expected: true,
},

{
Scenario: "with liveimage url, unprovisioned",
Host: metal3v1alpha1.BareMetalHost{
ObjectMeta: metav1.ObjectMeta{
Name: "myhost",
Namespace: "myns",
},
Spec: metal3v1alpha1.BareMetalHostSpec{
LiveImage: &metal3v1alpha1.LiveImage{
URL: "not-empty",
},
Online: true,
},
},
Expected: false,
},

{
Scenario: "with liveimage, unprovisioned",
Host: metal3v1alpha1.BareMetalHost{
ObjectMeta: metav1.ObjectMeta{
Name: "myhost",
Namespace: "myns",
},
Spec: metal3v1alpha1.BareMetalHostSpec{
LiveImage: &metal3v1alpha1.LiveImage{},
Online: true,
},
},
Expected: true,
},

{
Scenario: "without, unprovisioned",
Host: metal3v1alpha1.BareMetalHost{
Expand Down

0 comments on commit 1b2bab0

Please sign in to comment.