Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,26 +612,28 @@ func clearHostProvisioningSettings(host *metal3v1alpha1.BareMetalHost) {
}

func (r *BareMetalHostReconciler) actionDeprovisioning(prov provisioner.Provisioner, info *reconcileInfo) actionResult {
// Adopt the host in case it has been re-registered during the
// deprovisioning process before it completed
provResult, err := prov.Adopt(info.host.Status.ErrorType == metal3v1alpha1.RegistrationError)
if err != nil {
return actionError{err}
}
if provResult.ErrorMessage != "" {
return recordActionFailure(info, metal3v1alpha1.RegistrationError, provResult.ErrorMessage)
}
if provResult.Dirty {
result := actionContinue{provResult.RequeueAfter}
if clearError(info.host) {
return actionUpdate{result}
if info.host.Status.Provisioning.Image.URL != "" {
Comment thread
zaneb marked this conversation as resolved.
// Adopt the host in case it has been re-registered during the
// deprovisioning process before it completed
provResult, err := prov.Adopt(info.host.Status.ErrorType == metal3v1alpha1.RegistrationError)
if err != nil {
return actionError{err}
}
if provResult.ErrorMessage != "" {
return recordActionFailure(info, metal3v1alpha1.RegistrationError, provResult.ErrorMessage)
}
if provResult.Dirty {
result := actionContinue{provResult.RequeueAfter}
if clearError(info.host) {
return actionUpdate{result}
}
return result
}
return result
}

info.log.Info("deprovisioning")

provResult, err = prov.Deprovision(info.host.Status.ErrorType == metal3v1alpha1.ProvisioningError)
provResult, err := prov.Deprovision(info.host.Status.ErrorType == metal3v1alpha1.ProvisioningError)
if err != nil {
return actionError{errors.Wrap(err, "failed to deprovision")}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioner/ironic/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ func (p *ironicProvisioner) Deprovision(force bool) (result provisioner.Result,
p.log.Info("cleaning")
return operationContinuing(deprovisionRequeueDelay)

case nodes.Active:
case nodes.Active, nodes.DeployFail:
p.log.Info("starting deprovisioning")
p.publisher("DeprovisioningStarted", "Image deprovisioning started")
return p.changeNodeProvisionState(
Expand Down
9 changes: 9 additions & 0 deletions pkg/provisioner/ironic/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ func TestDeprovision(t *testing.T) {
expectedRequestAfter: 10,
expectedDirty: true,
},
{
name: "deploy failed state",
ironic: testserver.NewIronic(t).WithDefaultResponses().Node(nodes.Node{
ProvisionState: string(nodes.DeployFail),
UUID: nodeUUID,
}),
expectedRequestAfter: 10,
expectedDirty: true,
},
{
name: "error state",
ironic: testserver.NewIronic(t).WithDefaultResponses().Node(nodes.Node{
Expand Down