Skip to content

Commit

Permalink
Merge pull request #2048 from zaneb/custom-deploy-equivalence
Browse files Browse the repository at this point in the history
🐛 Make custom deploy equivalent to image deploy
  • Loading branch information
metal3-io-bot authored Nov 20, 2024
2 parents 568ba96 + dd67b17 commit e2e9f33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 4 additions & 0 deletions apis/metal3.io/v1alpha1/baremetalhost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,10 @@ func (host *BareMetalHost) WasProvisioned() bool {
// We have an image provisioned.
return true
}
if host.Status.Provisioning.CustomDeploy != nil {
// We have a custom deploy provisioned.
return true
}
return false
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ func clearHostProvisioningSettings(host *metal3api.BareMetalHost) {
}

func (r *BareMetalHostReconciler) actionDeprovisioning(prov provisioner.Provisioner, info *reconcileInfo) actionResult {
if info.host.Status.Provisioning.Image.URL != "" {
if info.host.Status.Provisioning.Image.URL != "" || info.host.Status.Provisioning.CustomDeploy != nil {
// Adopt the host in case it has been re-registered during the
// deprovisioning process before it completed
provResult, err := prov.Adopt(
Expand Down
20 changes: 9 additions & 11 deletions pkg/provisioner/ironic/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,17 +1103,13 @@ func (p *ironicProvisioner) Adopt(data provisioner.AdoptData, restartOnFailure b
return transientError(fmt.Errorf("invalid state for adopt: %s",
ironicNode.ProvisionState))
case nodes.Manageable:
_, hasImageSource := ironicNode.InstanceInfo["image_source"]
_, hasBootISO := ironicNode.InstanceInfo["boot_iso"]
if data.State == metal3api.StateDeprovisioning &&
!(hasImageSource || hasBootISO) {
// If we got here after a fresh registration and image data is
// available, it should have been added to the node during
// registration. If it isn't present then we got here due to a
// failed cleaning on deprovision. The node will be cleaned again
// before the next provisioning, so just allow the controller to
// continue without adopting.
p.log.Info("no image info; not adopting", "state", ironicNode.ProvisionState)
if data.State == metal3api.StateDeprovisioning {
// During deprovisioning we may get here because of either a fresh
// registration or a failure during cleaning. Either way, the
// Deprovision() function will change move the state to Available,
// which will retry automated cleaning.
p.log.Info("deprovisioning in progress; not adopting",
"state", ironicNode.ProvisionState)
return operationComplete()
}
return p.changeNodeProvisionState(
Expand Down Expand Up @@ -1670,6 +1666,8 @@ func (p *ironicProvisioner) Deprovision(restartOnFailure bool) (result provision
// We end up here after CleanFail, retry cleaning. If a user
// wants to delete a host without cleaning, they can always set
// automatedCleaningMode: disabled.
// We also end up here if the node has to be re-registered, because we
// don't attempt to adopt once deprovisioning has started.
p.log.Info("deprovisioning node is in manageable state", "automatedClean", ironicNode.AutomatedClean)
return p.changeNodeProvisionState(
ironicNode,
Expand Down

0 comments on commit e2e9f33

Please sign in to comment.