Skip to content
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

Skip the inspecting state when inspection is disabled #1128

Merged
merged 1 commit into from
Jul 13, 2022
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
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
dtantsur marked this conversation as resolved.
Show resolved Hide resolved
} 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving it inside NeedsHardwareInspection would save updating the state machine diagram :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was a bit more effort (needs to move some code around), are you fine with a follow-up?

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.