diff --git a/apis/metal3.io/v1alpha1/baremetalhost_types.go b/apis/metal3.io/v1alpha1/baremetalhost_types.go index a9863c8334..c402c9efcb 100644 --- a/apis/metal3.io/v1alpha1/baremetalhost_types.go +++ b/apis/metal3.io/v1alpha1/baremetalhost_types.go @@ -182,7 +182,7 @@ const ( // StatePreparing means we are removing existing configuration and set new configuration to the host StatePreparing ProvisioningState = "preparing" - // StateReady means the host can be consumed + // StateReady is a deprecated name for StateAvailable StateReady ProvisioningState = "ready" // StateAvailable means the host can be consumed diff --git a/controllers/metal3.io/baremetalhost_controller.go b/controllers/metal3.io/baremetalhost_controller.go index 1cf417a90d..ab456f78f4 100644 --- a/controllers/metal3.io/baremetalhost_controller.go +++ b/controllers/metal3.io/baremetalhost_controller.go @@ -1075,11 +1075,11 @@ func (r *BareMetalHostReconciler) actionManageSteadyState(prov provisioner.Provi return r.manageHostPower(prov, info) } -// A host reaching this action handler should be ready -- a state that +// A host reaching this action handler should be available -- a state that // 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 { +func (r *BareMetalHostReconciler) actionManageAvailable(prov provisioner.Provisioner, info *reconcileInfo) actionResult { if info.host.NeedsProvisioning() { clearError(info.host) return actionComplete{} diff --git a/controllers/metal3.io/baremetalhost_controller_test.go b/controllers/metal3.io/baremetalhost_controller_test.go index b826b9925e..4630859d64 100644 --- a/controllers/metal3.io/baremetalhost_controller_test.go +++ b/controllers/metal3.io/baremetalhost_controller_test.go @@ -1635,7 +1635,7 @@ func TestErrorCountIncrementsAlways(t *testing.T) { } } -func TestGetImageReady(t *testing.T) { +func TestGetImageAvailable(t *testing.T) { host := metal3v1alpha1.BareMetalHost{ Spec: metal3v1alpha1.BareMetalHostSpec{ Image: &metal3v1alpha1.Image{ @@ -1644,7 +1644,7 @@ func TestGetImageReady(t *testing.T) { }, Status: metal3v1alpha1.BareMetalHostStatus{ Provisioning: metal3v1alpha1.ProvisionStatus{ - State: metal3v1alpha1.StateReady, + State: metal3v1alpha1.StateAvailable, }, }, } diff --git a/controllers/metal3.io/demo_test.go b/controllers/metal3.io/demo_test.go index 3b5ec0b3cf..e548ff73d6 100644 --- a/controllers/metal3.io/demo_test.go +++ b/controllers/metal3.io/demo_test.go @@ -125,10 +125,10 @@ func TestDemoPreparingError(t *testing.T) { ) } -// TestDemoReady tests that a host with the right name reports -// that it is ready to be provisioned -func TestDemoReady(t *testing.T) { - host := newDefaultNamedHost(demo.ReadyHost, t) +// TestDemoAvailable tests that a host with the right name reports +// that it is available to be provisioned +func TestDemoAvailable(t *testing.T) { + host := newDefaultNamedHost(demo.AvailableHost, t) r := newDemoReconciler(host) tryReconcile(t, r, host, @@ -138,7 +138,7 @@ func TestDemoReady(t *testing.T) { host.Status.Provisioning.State, host.Status.ErrorMessage, ) - return host.Status.Provisioning.State == metal3v1alpha1.StateReady + return host.Status.Provisioning.State == metal3v1alpha1.StateAvailable }, ) } diff --git a/controllers/metal3.io/host_state_machine.go b/controllers/metal3.io/host_state_machine.go index 3c93cd5bf4..8f38165e8b 100644 --- a/controllers/metal3.io/host_state_machine.go +++ b/controllers/metal3.io/host_state_machine.go @@ -45,9 +45,9 @@ func (hsm *hostStateMachine) handlers() map[metal3v1alpha1.ProvisioningState]sta metal3v1alpha1.StateInspecting: hsm.handleInspecting, metal3v1alpha1.StateExternallyProvisioned: hsm.handleExternallyProvisioned, metal3v1alpha1.StateMatchProfile: hsm.handleMatchProfile, - metal3v1alpha1.StateAvailable: hsm.handleReady, metal3v1alpha1.StatePreparing: hsm.handlePreparing, - metal3v1alpha1.StateReady: hsm.handleReady, + metal3v1alpha1.StateAvailable: hsm.handleAvailable, + metal3v1alpha1.StateReady: hsm.handleAvailable, metal3v1alpha1.StateProvisioning: hsm.handleProvisioning, metal3v1alpha1.StateProvisioned: hsm.handleProvisioned, metal3v1alpha1.StateDeprovisioning: hsm.handleDeprovisioning, @@ -395,12 +395,12 @@ func (hsm *hostStateMachine) handlePreparing(info *reconcileInfo) actionResult { actResult := hsm.Reconciler.actionPreparing(hsm.Provisioner, info) if _, complete := actResult.(actionComplete); complete { hsm.Host.Status.ErrorCount = 0 - hsm.NextState = metal3v1alpha1.StateReady + hsm.NextState = metal3v1alpha1.StateAvailable } return actResult } -func (hsm *hostStateMachine) handleReady(info *reconcileInfo) actionResult { +func (hsm *hostStateMachine) handleAvailable(info *reconcileInfo) actionResult { if hsm.Host.Spec.ExternallyProvisioned { hsm.NextState = metal3v1alpha1.StateExternallyProvisioned clearHostProvisioningSettings(info.host) @@ -419,8 +419,8 @@ func (hsm *hostStateMachine) handleReady(info *reconcileInfo) actionResult { return actionComplete{} } - // ErrorCount is cleared when appropriate inside actionManageReady - actResult := hsm.Reconciler.actionManageReady(hsm.Provisioner, info) + // ErrorCount is cleared when appropriate inside actionManageAvailable + actResult := hsm.Reconciler.actionManageAvailable(hsm.Provisioner, info) if _, complete := actResult.(actionComplete); complete { hsm.NextState = metal3v1alpha1.StateProvisioning } @@ -494,7 +494,7 @@ func (hsm *hostStateMachine) handleDeprovisioning(info *reconcileInfo) actionRes if hsm.Host.DeletionTimestamp.IsZero() { if _, complete := actResult.(actionComplete); complete { - hsm.NextState = metal3v1alpha1.StateReady + hsm.NextState = metal3v1alpha1.StateAvailable hsm.Host.Status.ErrorCount = 0 } } else { diff --git a/controllers/metal3.io/host_state_machine_test.go b/controllers/metal3.io/host_state_machine_test.go index 697b9363e1..d088661ae7 100644 --- a/controllers/metal3.io/host_state_machine_test.go +++ b/controllers/metal3.io/host_state_machine_test.go @@ -46,6 +46,14 @@ func TestProvisioningCapacity(t *testing.T) { }, { Scenario: "transition-to-provisioning-delayed", + Host: host(metal3v1alpha1.StateAvailable).SaveHostProvisioningSettings().build(), + HasProvisioningCapacity: false, + + ExpectedProvisioningState: metal3v1alpha1.StateAvailable, + ExpectedDelayed: true, + }, + { + Scenario: "transition-to-provisioning-delayed-deprecated-ready", Host: host(metal3v1alpha1.StateReady).SaveHostProvisioningSettings().build(), HasProvisioningCapacity: false, @@ -62,7 +70,7 @@ func TestProvisioningCapacity(t *testing.T) { }, { Scenario: "transition-to-provisioning-ok", - Host: host(metal3v1alpha1.StateReady).SaveHostProvisioningSettings().build(), + Host: host(metal3v1alpha1.StateAvailable).SaveHostProvisioningSettings().build(), HasProvisioningCapacity: true, ExpectedProvisioningState: metal3v1alpha1.StateProvisioning, @@ -71,18 +79,18 @@ func TestProvisioningCapacity(t *testing.T) { { Scenario: "already-delayed-delayed", - Host: host(metal3v1alpha1.StateReady).SetOperationalStatus(metal3v1alpha1.OperationalStatusDelayed).build(), + Host: host(metal3v1alpha1.StateAvailable).SetOperationalStatus(metal3v1alpha1.OperationalStatusDelayed).build(), HasProvisioningCapacity: false, - ExpectedProvisioningState: metal3v1alpha1.StateReady, + ExpectedProvisioningState: metal3v1alpha1.StateAvailable, ExpectedDelayed: true, }, { Scenario: "already-delayed-ok", - Host: host(metal3v1alpha1.StateReady).SetOperationalStatus(metal3v1alpha1.OperationalStatusDelayed).build(), + Host: host(metal3v1alpha1.StateAvailable).SetOperationalStatus(metal3v1alpha1.OperationalStatusDelayed).build(), HasProvisioningCapacity: true, - ExpectedProvisioningState: metal3v1alpha1.StateReady, + ExpectedProvisioningState: metal3v1alpha1.StateAvailable, ExpectedDelayed: false, }, @@ -161,7 +169,7 @@ func TestDeprovisioningCapacity(t *testing.T) { Host: host(metal3v1alpha1.StateDeprovisioning).build(), HasDeprovisioningCapacity: true, - ExpectedDeprovisioningState: metal3v1alpha1.StateReady, + ExpectedDeprovisioningState: metal3v1alpha1.StateAvailable, ExpectedDelayed: false, }, { @@ -327,6 +335,15 @@ func TestDetach(t *testing.T) { ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK, ExpectedState: metal3v1alpha1.StateProvisioning, }, + { + Scenario: "DeprecatedReadyHost", + Host: host(metal3v1alpha1.StateReady).build(), + HasDetachedAnnotation: false, + ExpectedDetach: false, + ExpectedDirty: true, + ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK, + ExpectedState: metal3v1alpha1.StateProvisioning, + }, { Scenario: "PreparingHost", Host: host(metal3v1alpha1.StatePreparing).build(), @@ -334,29 +351,29 @@ func TestDetach(t *testing.T) { ExpectedDetach: false, ExpectedDirty: true, ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK, - ExpectedState: metal3v1alpha1.StateReady, + ExpectedState: metal3v1alpha1.StateAvailable, }, { - Scenario: "DetachReadyHost", - Host: host(metal3v1alpha1.StateReady).SetImageURL("").SetStatusPoweredOn(false).build(), + Scenario: "DetachAvailableHost", + Host: host(metal3v1alpha1.StateAvailable).SetImageURL("").SetStatusPoweredOn(false).build(), HasDetachedAnnotation: true, ExpectedDetach: true, ExpectedDirty: true, ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusDetached, - ExpectedState: metal3v1alpha1.StateReady, + ExpectedState: metal3v1alpha1.StateAvailable, }, { - Scenario: "AttachReadyHost", - Host: host(metal3v1alpha1.StateReady).SetImageURL("").SetStatusPoweredOn(false).build(), + Scenario: "AttachAvailableHost", + Host: host(metal3v1alpha1.StateAvailable).SetImageURL("").SetStatusPoweredOn(false).build(), HasDetachedAnnotation: false, ExpectedDetach: false, ExpectedDirty: true, ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK, - ExpectedState: metal3v1alpha1.StateReady, + ExpectedState: metal3v1alpha1.StateAvailable, }, { - Scenario: "ReadyHost", - Host: host(metal3v1alpha1.StateReady).build(), + Scenario: "AvailableHost", + Host: host(metal3v1alpha1.StateAvailable).build(), HasDetachedAnnotation: false, ExpectedDetach: false, ExpectedDirty: true, @@ -379,7 +396,7 @@ func TestDetach(t *testing.T) { ExpectedDetach: false, ExpectedDirty: true, ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK, - ExpectedState: metal3v1alpha1.StateReady, + ExpectedState: metal3v1alpha1.StateAvailable, }, { Scenario: "DeletingHost", @@ -866,12 +883,22 @@ func TestErrorCountIncreasedOnActionFailure(t *testing.T) { ProvisionerErrorOn: "Deprovision", }, { - Scenario: "ready-power-on", + Scenario: "available-power-on", + Host: host(metal3v1alpha1.StateAvailable).SetImageURL("").SetStatusPoweredOn(false).build(), + ProvisionerErrorOn: "PowerOn", + }, + { + Scenario: "available-power-off", + Host: host(metal3v1alpha1.StateAvailable).SetImageURL("").SetOnline(false).build(), + ProvisionerErrorOn: "PowerOff", + }, + { + Scenario: "deprecated-ready-power-on", Host: host(metal3v1alpha1.StateReady).SetImageURL("").SetStatusPoweredOn(false).build(), ProvisionerErrorOn: "PowerOn", }, { - Scenario: "ready-power-off", + Scenario: "deprecated-ready-power-off", Host: host(metal3v1alpha1.StateReady).SetImageURL("").SetOnline(false).build(), ProvisionerErrorOn: "PowerOff", }, @@ -928,7 +955,7 @@ func TestErrorCountClearedOnStateTransition(t *testing.T) { { Scenario: "preparing-to-ready", Host: host(metal3v1alpha1.StatePreparing).build(), - TargetState: metal3v1alpha1.StateReady, + TargetState: metal3v1alpha1.StateAvailable, }, { Scenario: "provisioning-to-provisioned", @@ -938,7 +965,7 @@ func TestErrorCountClearedOnStateTransition(t *testing.T) { { Scenario: "deprovisioning-to-ready", Host: host(metal3v1alpha1.StateDeprovisioning).build(), - TargetState: metal3v1alpha1.StateReady, + TargetState: metal3v1alpha1.StateAvailable, }, { Scenario: "deprovisioning-to-deleting", @@ -977,7 +1004,7 @@ func TestErrorClean(t *testing.T) { }, { Scenario: "clean-after-creds-change", - Host: host(metal3v1alpha1.StateReady). + Host: host(metal3v1alpha1.StateAvailable). SetStatusError(metal3v1alpha1.OperationalStatusError, metal3v1alpha1.InspectionError, "some error", 1). build(), SecretName: "NewCreds", diff --git a/docs/BaremetalHost_ProvisioningState.dot b/docs/BaremetalHost_ProvisioningState.dot index efec5e8c1b..3883b67a58 100644 --- a/docs/BaremetalHost_ProvisioningState.dot +++ b/docs/BaremetalHost_ProvisioningState.dot @@ -20,7 +20,7 @@ digraph BaremetalHost { ExternallyProvisioned -> Inspecting [label="!externallyProvisioned && NeedsHardwareInspection()"] ExternallyProvisioned -> MatchProfile [label="!externallyProvisioned && NeedsHardwareProfile()"] ExternallyProvisioned -> Preparing [label="!externallyProvisioned"] - Ready -> ExternallyProvisioned [label="externallyProvisioned"] + Available -> ExternallyProvisioned [label="externallyProvisioned"] Inspecting -> MatchProfile [label="done"] Inspecting -> Deleting3 [label="!DeletionTimestamp.IsZero()"] @@ -34,16 +34,16 @@ digraph BaremetalHost { Deleting5 [shape=point] - Preparing -> Ready [label="done"] + Preparing -> Available [label="done"] Preparing -> Deleting6 [label="!DeletionTimestamp.IsZero()"] Deleting6 [shape=point] - Ready [shape=doublecircle] - Ready -> Provisioning [label="NeedsProvisioning()"] - Ready -> Preparing [label="saveHostProvisioningSettings()"] - Ready -> Deleting7 [label="!DeletionTimestamp.IsZero()"] - Ready -> Inspecting [label="hasInspectAnnotation()"] + Available [shape=doublecircle] + Available -> Provisioning [label="NeedsProvisioning()"] + Available -> Preparing [label="saveHostProvisioningSettings()"] + Available -> Deleting7 [label="!DeletionTimestamp.IsZero()"] + Available -> Inspecting [label="hasInspectAnnotation()"] Deleting7 [shape=point] @@ -58,7 +58,7 @@ digraph BaremetalHost { ExternallyProvisioned -> Deleting [label="!DeletionTimestamp.IsZero()"] Deprovisioning -> Provisioning [label="NeedsProvisioning()"] - Deprovisioning -> Ready [label="!NeedsProvisioning()"] + Deprovisioning -> Available [label="!NeedsProvisioning()"] Deprovisioning -> Deleting [label="!DeletionTimestamp.IsZero()"] Deleting [shape=doublecircle] diff --git a/docs/BaremetalHost_ProvisioningState.png b/docs/BaremetalHost_ProvisioningState.png index cce6851538..62c4e14e5c 100644 Binary files a/docs/BaremetalHost_ProvisioningState.png and b/docs/BaremetalHost_ProvisioningState.png differ diff --git a/docs/api.md b/docs/api.md index 26c12dfa27..520b975cef 100644 --- a/docs/api.md +++ b/docs/api.md @@ -385,7 +385,8 @@ Settings related to deploying an image to the host. * *registering* -- The host's BMC details are being checked. * *match profile* -- The discovered hardware details on the host are being compared against known profiles. - * *ready* -- The host is available to be consumed. + * *available* -- The host is available to be consumed. (This state was + previously known as *ready*.) * *provisioning* -- An image is being written to the host's disk(s). * *provisioned* -- An image has been completely written to the host's disk(s). diff --git a/docs/baremetalhost-states.md b/docs/baremetalhost-states.md index f494b6858e..313c010fc6 100644 --- a/docs/baremetalhost-states.md +++ b/docs/baremetalhost-states.md @@ -47,9 +47,11 @@ When setting up RAID, BIOS and other similar configurations, the host will be in Preparing state. For ironic provisioner, we build and set up manual clean steps in Preparing state. -## Ready +## Available -A host in the Ready state is available to be provisioned. +A host in the Available state is available to be provisioned. +In older versions of the baremetal-operator, this state was called +Ready. ## Provisioning diff --git a/examples/demo-hosts.yaml b/examples/demo-hosts.yaml index d7d8577bcd..2bb828c43b 100644 --- a/examples/demo-hosts.yaml +++ b/examples/demo-hosts.yaml @@ -96,7 +96,7 @@ spec: apiVersion: v1 kind: Secret metadata: - name: demo-ready-secret + name: demo-available-secret type: Opaque data: username: YWRtaW4= @@ -105,14 +105,14 @@ data: apiVersion: metal3.io/v1alpha1 kind: BareMetalHost metadata: - name: demo-ready + name: demo-available labels: metal3demo: "" spec: online: true bmc: address: ipmi://192.168.122.3:6233 - credentialsName: demo-ready-secret + credentialsName: demo-available-secret --- apiVersion: v1 diff --git a/pkg/provisioner/demo/demo.go b/pkg/provisioner/demo/demo.go index be79a6f464..add5a76fe0 100644 --- a/pkg/provisioner/demo/demo.go +++ b/pkg/provisioner/demo/demo.go @@ -26,8 +26,8 @@ const ( // registered. RegisteringHost string = "demo-registering" - // ReadyHost is a host that is ready to be used. - ReadyHost string = "demo-ready" + // AvailableHost is a host that is available to be used. + AvailableHost string = "demo-available" // InspectingHost is a host that is having its hardware scanned. InspectingHost string = "demo-inspecting"