Skip to content

Commit

Permalink
Merge pull request #1128 from dtantsur/fix-skip-inspect
Browse files Browse the repository at this point in the history
Skip the inspecting state when inspection is disabled
  • Loading branch information
metal3-io-bot committed Jul 13, 2022
2 parents 97f9233 + 3b6d72f commit fa2b32e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions controllers/metal3.io/host_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ func (hsm *hostStateMachine) handleRegistering(info *reconcileInfo) actionResult
// if the credentials change and the Host must be re-registered.
if hsm.Host.Spec.ExternallyProvisioned {
hsm.NextState = metal3v1alpha1.StateExternallyProvisioned
} else if inspectionDisabled(hsm.Host) {
hsm.NextState = metal3v1alpha1.StatePreparing
} else {
hsm.NextState = metal3v1alpha1.StateInspecting
}
Expand Down Expand Up @@ -377,10 +379,10 @@ func (hsm *hostStateMachine) handleExternallyProvisioned(info *reconcileInfo) ac
return hsm.Reconciler.actionManageSteadyState(hsm.Provisioner, info)
}

switch {
case hsm.Host.NeedsHardwareInspection():
// TODO(dtantsur): move this logic inside NeedsHardwareInspection?
if hsm.Host.NeedsHardwareInspection() && !inspectionDisabled(hsm.Host) {
hsm.NextState = metal3v1alpha1.StateInspecting
default:
} else {
hsm.NextState = metal3v1alpha1.StatePreparing
}
return actionComplete{}
Expand Down
13 changes: 13 additions & 0 deletions controllers/metal3.io/host_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,11 @@ func TestErrorCountClearedOnStateTransition(t *testing.T) {
Host: host(metal3v1alpha1.StateRegistering).build(),
TargetState: metal3v1alpha1.StateInspecting,
},
{
Scenario: "registering-to-preparing",
Host: host(metal3v1alpha1.StateRegistering).DisableInspection().build(),
TargetState: metal3v1alpha1.StatePreparing,
},
{
Scenario: "inspecting-to-preparing",
Host: host(metal3v1alpha1.StateInspecting).build(),
Expand Down Expand Up @@ -1175,6 +1180,14 @@ func (hb *hostBuilder) SetOperationalStatus(status metal3v1alpha1.OperationalSta
return hb
}

func (hb *hostBuilder) DisableInspection() *hostBuilder {
if hb.Annotations == nil {
hb.Annotations = make(map[string]string, 1)
}
hb.Annotations[inspectAnnotationPrefix] = "disabled"
return hb
}

func (hb *hostBuilder) setDeletion() *hostBuilder {
date := metav1.Date(2021, time.January, 18, 10, 18, 0, 0, time.UTC)
hb.DeletionTimestamp = &date
Expand Down
1 change: 1 addition & 0 deletions docs/BaremetalHost_ProvisioningState.dot
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ digraph BaremetalHost {
ExternallyProvisioned [label="Externally\nProvisioned"]

Registering -> Inspecting [label="!externallyProvisioned && NeedsHardwareInspection()"]
Registering -> Preparing [label="!externallyProvisioned && inspectionDisabled()"]
Registering -> ExternallyProvisioned [label="externallyProvisioned"]
Registering -> Deleting2 [label="!DeletionTimestamp.IsZero()"]

Expand Down
Binary file modified docs/BaremetalHost_ProvisioningState.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa2b32e

Please sign in to comment.