Skip to content

Commit

Permalink
Merge pull request #965 from Nordix/enable-detach-ready-nodes
Browse files Browse the repository at this point in the history
Enable detach annotation for ready nodes
  • Loading branch information
metal3-io-bot committed Sep 3, 2021
2 parents c2d6d46 + 90f25de commit ae74cdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/metal3.io/host_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (hsm *hostStateMachine) checkDetachedHost(info *reconcileInfo) (result acti
if hasDetachedAnnotation(hsm.Host) {
// Only allow detaching hosts in Provisioned/ExternallyProvisioned states
switch info.host.Status.Provisioning.State {
case metal3v1alpha1.StateProvisioned, metal3v1alpha1.StateExternallyProvisioned:
case metal3v1alpha1.StateProvisioned, metal3v1alpha1.StateExternallyProvisioned, metal3v1alpha1.StateReady:
return hsm.Reconciler.detachHost(hsm.Provisioner, info)
}
}
Expand Down
20 changes: 19 additions & 1 deletion controllers/metal3.io/host_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,28 @@ func TestDetach(t *testing.T) {
ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK,
ExpectedState: metal3v1alpha1.StateReady,
},
{
Scenario: "DetachReadyHost",
Host: host(metal3v1alpha1.StateReady).SetImageURL("").SetStatusPoweredOn(false).build(),
HasDetachedAnnotation: true,
ExpectedDetach: true,
ExpectedDirty: true,
ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusDetached,
ExpectedState: metal3v1alpha1.StateReady,
},
{
Scenario: "AttachReadyHost",
Host: host(metal3v1alpha1.StateReady).SetImageURL("").SetStatusPoweredOn(false).build(),
HasDetachedAnnotation: false,
ExpectedDetach: false,
ExpectedDirty: true,
ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK,
ExpectedState: metal3v1alpha1.StateReady,
},
{
Scenario: "ReadyHost",
Host: host(metal3v1alpha1.StateReady).build(),
HasDetachedAnnotation: true,
HasDetachedAnnotation: false,
ExpectedDetach: false,
ExpectedDirty: true,
ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK,
Expand Down

0 comments on commit ae74cdc

Please sign in to comment.