diff --git a/controllers/metal3.io/host_state_machine.go b/controllers/metal3.io/host_state_machine.go index e99a359286..7f71a1badb 100644 --- a/controllers/metal3.io/host_state_machine.go +++ b/controllers/metal3.io/host_state_machine.go @@ -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 } @@ -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{} diff --git a/controllers/metal3.io/host_state_machine_test.go b/controllers/metal3.io/host_state_machine_test.go index f35a9b1e48..f7901c8c97 100644 --- a/controllers/metal3.io/host_state_machine_test.go +++ b/controllers/metal3.io/host_state_machine_test.go @@ -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(), @@ -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 diff --git a/docs/BaremetalHost_ProvisioningState.dot b/docs/BaremetalHost_ProvisioningState.dot index 2100affce3..d91d066121 100644 --- a/docs/BaremetalHost_ProvisioningState.dot +++ b/docs/BaremetalHost_ProvisioningState.dot @@ -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()"] diff --git a/docs/BaremetalHost_ProvisioningState.png b/docs/BaremetalHost_ProvisioningState.png index 944b1238b2..d247102bbe 100644 Binary files a/docs/BaremetalHost_ProvisioningState.png and b/docs/BaremetalHost_ProvisioningState.png differ