Skip to content

Commit

Permalink
Rename Ready state to Available
Browse files Browse the repository at this point in the history
Ready is a status also used by the Node resource, but with a different
meaning which causes unnecessary confusion especially on the UI side
where Host and Node status is combined.

Co-Authored-By: Zane Bitter <[email protected]>
  • Loading branch information
Jiri Tomasek and zaneb committed Sep 28, 2021
1 parent 8e87262 commit 558b922
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 54 deletions.
2 changes: 1 addition & 1 deletion apis/metal3.io/v1alpha1/baremetalhost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
4 changes: 2 additions & 2 deletions controllers/metal3.io/baremetalhost_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -1644,7 +1644,7 @@ func TestGetImageReady(t *testing.T) {
},
Status: metal3v1alpha1.BareMetalHostStatus{
Provisioning: metal3v1alpha1.ProvisionStatus{
State: metal3v1alpha1.StateReady,
State: metal3v1alpha1.StateAvailable,
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/metal3.io/demo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
},
)
}
Expand Down
14 changes: 7 additions & 7 deletions controllers/metal3.io/host_state_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
69 changes: 48 additions & 21 deletions controllers/metal3.io/host_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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,
Expand All @@ -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,
},

Expand Down Expand Up @@ -161,7 +169,7 @@ func TestDeprovisioningCapacity(t *testing.T) {
Host: host(metal3v1alpha1.StateDeprovisioning).build(),
HasDeprovisioningCapacity: true,

ExpectedDeprovisioningState: metal3v1alpha1.StateReady,
ExpectedDeprovisioningState: metal3v1alpha1.StateAvailable,
ExpectedDelayed: false,
},
{
Expand Down Expand Up @@ -327,36 +335,45 @@ 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(),
HasDetachedAnnotation: true,
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,
Expand All @@ -379,7 +396,7 @@ func TestDetach(t *testing.T) {
ExpectedDetach: false,
ExpectedDirty: true,
ExpectedOperationalStatus: metal3v1alpha1.OperationalStatusOK,
ExpectedState: metal3v1alpha1.StateReady,
ExpectedState: metal3v1alpha1.StateAvailable,
},
{
Scenario: "DeletingHost",
Expand Down Expand Up @@ -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",
},
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions docs/BaremetalHost_ProvisioningState.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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()"]
Expand All @@ -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]

Expand All @@ -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]
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.
3 changes: 2 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
6 changes: 4 additions & 2 deletions docs/baremetalhost-states.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions examples/demo-hosts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ spec:
apiVersion: v1
kind: Secret
metadata:
name: demo-ready-secret
name: demo-available-secret
type: Opaque
data:
username: YWRtaW4=
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/provisioner/demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 558b922

Please sign in to comment.