-
Notifications
You must be signed in to change notification settings - Fork 311
Handle re-registration in all states #716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6843481
3ea268e
b7b10d7
93cbf64
502d2fb
2e4e00b
1846513
1f17aab
79f695d
324f7b1
431470c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,6 +181,7 @@ func (r *BareMetalHostReconciler) Reconcile(request ctrl.Request) (result ctrl.R | |
| // management controller. | ||
| var bmcCreds *bmc.Credentials | ||
| var bmcCredsSecret *corev1.Secret | ||
| haveCreds := false | ||
| switch host.Status.Provisioning.State { | ||
| case metal3v1alpha1.StateNone, metal3v1alpha1.StateUnmanaged: | ||
| bmcCreds = &bmc.Credentials{} | ||
|
|
@@ -194,6 +195,8 @@ func (r *BareMetalHostReconciler) Reconcile(request ctrl.Request) (result ctrl.R | |
| } else { | ||
| return r.credentialsErrorResult(err, request, host) | ||
| } | ||
| } else { | ||
| haveCreds = true | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -219,7 +222,7 @@ func (r *BareMetalHostReconciler) Reconcile(request ctrl.Request) (result ctrl.R | |
| return ctrl.Result{Requeue: true, RequeueAfter: provisionerNotReadyRetryDelay}, nil | ||
| } | ||
|
|
||
| stateMachine := newHostStateMachine(host, r, prov) | ||
| stateMachine := newHostStateMachine(host, r, prov, haveCreds) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: just to avoid passing another param to the host machine, couldn't this check be done via the Provisioner interface (verifying that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't know what type of Provisioner we have, so we don't know where (or even if) that data is stored. Also I don't want to have to look at the contents of the creds (which are not passed as a pointer) to see if they're empty or not.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| actResult := stateMachine.ReconcileState(info) | ||
| result, err = actResult.Result() | ||
|
|
||
|
|
@@ -428,15 +431,13 @@ func (r *BareMetalHostReconciler) actionRegistering(prov provisioner.Provisioner | |
| // so clear any previous error and record the success in the | ||
| // status block. | ||
| info.log.Info("updating credentials success status fields") | ||
| registeredNewCreds := !info.host.Status.GoodCredentials.Match(*info.bmcCredsSecret) | ||
| info.host.UpdateGoodCredentials(*info.bmcCredsSecret) | ||
| info.log.Info("clearing previous error message") | ||
| info.host.ClearError() | ||
|
|
||
| info.publishEvent("BMCAccessValidated", "Verified access to BMC") | ||
|
|
||
| if info.host.Spec.ExternallyProvisioned { | ||
| info.publishEvent("ExternallyProvisioned", | ||
| "Registered host that was externally provisioned") | ||
| if registeredNewCreds { | ||
| info.publishEvent("BMCAccessValidated", "Verified access to BMC") | ||
| } | ||
|
|
||
| return actionComplete{} | ||
|
|
@@ -562,9 +563,23 @@ 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 { | ||
| info.host.ClearError() | ||
| return actionContinue{provResult.RequeueAfter} | ||
| } | ||
|
|
||
| info.log.Info("deprovisioning") | ||
|
|
||
| provResult, err := prov.Deprovision() | ||
| provResult, err = prov.Deprovision() | ||
| if err != nil { | ||
| return actionError{errors.Wrap(err, "failed to deprovision")} | ||
| } | ||
|
|
@@ -679,14 +694,12 @@ func (r *BareMetalHostReconciler) manageHostPower(prov provisioner.Provisioner, | |
| return steadyStateResult | ||
| } | ||
|
|
||
| // A host reaching this action handler should be provisioned or | ||
| // externally provisioned -- a state that it will stay in until the | ||
| // user takes further action. Both of those states mean that it has | ||
| // been registered with the provisioner once, so we use the Adopt() | ||
| // API to ensure that is still true. Then we monitor its power status. | ||
| // A host reaching this action handler should be provisioned or externally | ||
| // provisioned -- a state that it will stay in until the user takes further | ||
| // action. We use the Adopt() API to make sure that the provisioner is aware of | ||
| // the provisioning details. Then we monitor its power status. | ||
| func (r *BareMetalHostReconciler) actionManageSteadyState(prov provisioner.Provisioner, info *reconcileInfo) actionResult { | ||
|
|
||
| provResult, err := prov.Adopt() | ||
| provResult, err := prov.Adopt(info.host.Status.ErrorType == metal3v1alpha1.RegistrationError) | ||
| if err != nil { | ||
| return actionError{err} | ||
| } | ||
|
|
@@ -702,28 +715,10 @@ func (r *BareMetalHostReconciler) actionManageSteadyState(prov provisioner.Provi | |
| } | ||
|
|
||
| // A host reaching this action handler should be ready -- a state that | ||
| // it will stay in until the user takes further action. It has been | ||
| // registered with the provisioner once, so we use | ||
| // ValidateManagementAccess() to ensure that is still true. We don't | ||
| // it will stay in until the user takes further action. We don't | ||
| // use Adopt() because we don't want Ironic to treat the host as | ||
| // having been provisioned. Then we monitor its power status. | ||
| func (r *BareMetalHostReconciler) actionManageReady(prov provisioner.Provisioner, info *reconcileInfo) actionResult { | ||
|
|
||
| // We always pass false for credentialsChanged because if they had | ||
| // changed we would have ended up in actionRegister() instead of | ||
| // here. | ||
| provResult, err := prov.ValidateManagementAccess(false) | ||
| if err != nil { | ||
| return actionError{err} | ||
| } | ||
| if provResult.ErrorMessage != "" { | ||
| return recordActionFailure(info, metal3v1alpha1.RegistrationError, provResult.ErrorMessage) | ||
| } | ||
| if provResult.Dirty { | ||
| info.host.ClearError() | ||
| return actionContinue{provResult.RequeueAfter} | ||
| } | ||
|
|
||
| if info.host.NeedsProvisioning() { | ||
| // Ensure the provisioning settings we're going to use are stored. | ||
| dirty, err := saveHostProvisioningSettings(info.host) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably go ahead and remove this method, but that's not a reason to hold up this PR.