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

✨ Update machine with v1beta2 status #11276

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
144 changes: 144 additions & 0 deletions api/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,150 @@ const (
ManagedNodeLabelDomain = "node.cluster.x-k8s.io"
)

// Machine's Available condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// MachineAvailableV1Beta2Condition is true if the machine is Ready for at least MinReadySeconds, as defined by the Machine's MinReadySeconds field.
fabriziopandini marked this conversation as resolved.
Show resolved Hide resolved
// Note: MinReadySeconds is assumed 0 until it will be implemented in v1beta2 API.
MachineAvailableV1Beta2Condition = AvailableV1Beta2Condition

// MachineNotReadyV1Beta2Reason surfaces when a machine is not ready (and thus not available).
MachineNotReadyV1Beta2Reason = "NotReady"

// MachineWaitingForMinReadySecondsV1Beta2Reason surfaces when a machine is ready for less than MinReadySeconds (and thus not yet available).
MachineWaitingForMinReadySecondsV1Beta2Reason = "WaitingForMinReadySeconds"

// MachineReadyNotYetReportedV1Beta2Reason surfaces when a machine ready is not reported yet.
// Note: this should never happen and it is a signal of some internal error.
MachineReadyNotYetReportedV1Beta2Reason = "ReadyNotYetReported"

// MachineAvailableV1Beta2Reason surfaces when a machine is ready for at least MinReadySeconds.
// Note: MinReadySeconds is assumed 0 until it will be implemented in v1beta2 API.
MachineAvailableV1Beta2Reason = AvailableV1Beta2Condition
)

// Machine's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
// Note: when possible, Ready condition will use reasons from the conditions it summarizes.
const (
// MachineReadyV1Beta2Condition is true if the Machine's deletionTimestamp is not set, Machine's BootstrapConfigReady, InfrastructureReady,
// NodeHealthy and HealthCheckSucceeded (if present) conditions are true; if other conditions are defined in spec.readinessGates,
// these conditions must be true as well.
MachineReadyV1Beta2Condition = ReadyV1Beta2Condition

// MachineErrorComputingReadyV1Beta2Reason surfaces when there was an error computing the ready condition.
// Note: this should never happen and it is a signal of some internal error.
MachineErrorComputingReadyV1Beta2Reason = "ErrorComputingReady"
)

// Machine's UpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
// Note: UpToDate condition is set by the controller owning the machine.
const (
// MachineUpToDateV1Beta2Condition is true if the Machine spec matches the spec of the Machine's owner resource, e.g. KubeadmControlPlane or MachineDeployment.
// The Machine's owner (e.g. MachineDeployment) is authoritative to set their owned Machine's UpToDate conditions based on its current spec.
MachineUpToDateV1Beta2Condition = "UpToDate"
sbueringer marked this conversation as resolved.
Show resolved Hide resolved
)

// Machine's BootstrapConfigReady condition and corresponding reasons that will be used in v1Beta2 API version.
// Note: when possible, BootstrapConfigReady condition will use reasons surfaced from the underlying bootstrap config object.
const (
// MachineBootstrapConfigReadyV1Beta2Condition condition mirrors the corresponding Ready condition from the Machine's BootstrapConfig resource.
MachineBootstrapConfigReadyV1Beta2Condition = BootstrapConfigReadyV1Beta2Condition

// MachineBootstrapDataSecretProvidedV1Beta2Reason surfaces when a bootstrap data secret is provided (not originated
// from a BoostrapConfig object referenced from the machine).
MachineBootstrapDataSecretProvidedV1Beta2Reason = "DataSecretProvided"

// MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason surfaces a BootstrapConfig Ready condition (read from a bootstrap config object) which is invalid.
// (e.g. its status is missing).
MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason

// MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason applies to a BootstrapConfig Ready condition (read from a bootstrap config object) that reports no reason.
MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason = NoReasonReportedV1Beta2Reason

// MachineBootstrapConfigInternalErrorV1Beta2Reason surfaces unexpected failures when reading a BootstrapConfig object.
MachineBootstrapConfigInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason

// MachineBootstrapConfigDoesNotExistV1Beta2Reason surfaces when a referenced bootstrap config object does not exist.
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
MachineBootstrapConfigDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason

// MachineBootstrapConfigDeletedV1Beta2Reason surfaces when a referenced bootstrap config object has been deleted.
// Note: controllers can't identify if the bootstrap config object was deleted the controller itself, e.g.
// during the deletion workflow, or by a users.
MachineBootstrapConfigDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
)

// Machine's InfrastructureReady condition and corresponding reasons that will be used in v1Beta2 API version.
// Note: when possible, InfrastructureReady condition will use reasons surfaced from the underlying infra machine object.
const (
// MachineInfrastructureReadyV1Beta2Condition mirrors the corresponding Ready condition from the Machine's Infrastructure resource.
MachineInfrastructureReadyV1Beta2Condition = InfrastructureReadyV1Beta2Condition

// MachineInfrastructureInvalidConditionReportedV1Beta2Reason surfaces a infrastructure Ready condition (read from an infra machine object) which is invalid.
// (e.g. its status is missing).
MachineInfrastructureInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason

// MachineInfrastructureReadyNoReasonReportedV1Beta2Reason applies to a infrastructure Ready condition (read from an infra machine object) that reports no reason.
MachineInfrastructureReadyNoReasonReportedV1Beta2Reason = NoReasonReportedV1Beta2Reason

// MachineInfrastructureInternalErrorV1Beta2Reason surfaces unexpected failures when reading a infra machine object.
MachineInfrastructureInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason

// MachineInfrastructureDoesNotExistV1Beta2Reason surfaces when a referenced infrastructure object does not exist.
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
MachineInfrastructureDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason

// MachineInfrastructureDeletedV1Beta2Reason surfaces when a referenced infrastructure object has been deleted.
// Note: controllers can't identify if the infrastructure object was deleted by the controller itself, e.g.
// during the deletion workflow, or by a users.
MachineInfrastructureDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
)

// Machine's NodeHealthy and NodeReady conditions and corresponding reasons that will be used in v1Beta2 API version.
// Note: when possible, NodeHealthy and NodeReady conditions will use reasons surfaced from the underlying node.
const (
// MachineNodeHealthyV1Beta2Condition is true if the Machine's Node is ready and it does not report MemoryPressure, DiskPressure and PIDPressure.
MachineNodeHealthyV1Beta2Condition = "NodeHealthy"

// MachineNodeReadyV1Beta2Condition is true if the Machine's Node is ready.
MachineNodeReadyV1Beta2Condition = "NodeReady"

// MachineNodeConditionNotYetReportedV1Beta2Reason surfaces when a Machine's Node doesn't have a condition reported yet.
MachineNodeConditionNotYetReportedV1Beta2Reason = "NodeConditionNotYetReported"

// MachineNodeDoesNotExistV1Beta2Reason surfaces when the node hosted on the machine does not exist.
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
MachineNodeDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason

// MachineNodeDeletedV1Beta2Reason surfaces when the node hosted on the machine has been deleted.
// Note: controllers can't identify if the Node was deleted by the controller itself, e.g.
// during the deletion workflow, or by a users.
MachineNodeDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
)

// Machine's HealthCheckSucceeded and OwnerRemediated conditions and corresponding reasons that will be used in v1Beta2 API version.
// Note: HealthCheckSucceeded and OwnerRemediated condition are set by the MachineHealthCheck controller.
const (
// MachineHealthCheckSucceededV1Beta2Condition is true if MHC instances targeting this machine report the Machine
// is healthy according to the definition of healthy present in the spec of the MachineHealthCheck object.
MachineHealthCheckSucceededV1Beta2Condition = "HealthCheckSucceeded"

// MachineOwnerRemediatedV1Beta2Condition is only present if MHC instances targeting this machine
// determine that the controller owning this machine should perform remediation.
MachineOwnerRemediatedV1Beta2Condition = "OwnerRemediated"
)

// Machine's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// MachineDeletingV1Beta2Condition surfaces details about progress in the machine deletion workflow.
MachineDeletingV1Beta2Condition = DeletingV1Beta2Condition
)

// Machine's Paused condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// MachinePausedV1Beta2Condition is true if the Machine or the Cluster it belongs to are paused.
MachinePausedV1Beta2Condition = PausedV1Beta2Condition
)

// ANCHOR: MachineSpec

// MachineSpec defines the desired state of Machine.
Expand Down
52 changes: 20 additions & 32 deletions api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,45 +85,33 @@ const (
PausedV1Beta2Condition = "Paused"
)

// Conditions that will be used for the Machine object in v1Beta2 API version.
// Reasons that are used across different objects.
const (
// MachineAvailableV1Beta2Condition is true if the machine is Ready for at least MinReadySeconds, as defined by the Machine's MinReadySeconds field.
MachineAvailableV1Beta2Condition = AvailableV1Beta2Condition
// InvalidConditionReportedV1Beta2Reason applies to a condition, usually read from an external object, that is invalid
// (e.g. its status is missing).
InvalidConditionReportedV1Beta2Reason = "InvalidConditionReported"

// MachineReadyV1Beta2Condition is true if the Machine is not deleted, Machine's BootstrapConfigReady, InfrastructureReady,
// NodeHealthy and HealthCheckSucceeded (if present) are true; if other conditions are defined in spec.readinessGates,
// these conditions must be true as well.
MachineReadyV1Beta2Condition = ReadyV1Beta2Condition
// NoReasonReportedV1Beta2Reason applies to a condition, usually read from an external object, that reports no reason.
// Note: this could happen e.g. when an external object still uses Cluster API v1beta1 Conditions.
NoReasonReportedV1Beta2Reason = "NoReasonReported"

// MachineUpToDateV1Beta2Condition is true if the Machine spec matches the spec of the Machine's owner resource, e.g. KubeadmControlPlane or MachineDeployment.
// The Machine's owner (e.g MachineDeployment) is authoritative to set their owned Machine's UpToDate conditions based on its current spec.
MachineUpToDateV1Beta2Condition = "UpToDate"
// InternalErrorV1Beta2Reason surfaces unexpected errors reporting by controllers.
// In most cases, it will be required to look at controllers logs to properly triage those issues.
InternalErrorV1Beta2Reason = "InternalError"

// MachineBootstrapConfigReadyV1Beta2Condition condition mirrors the corresponding Ready condition from the Machine's BootstrapConfig resource.
MachineBootstrapConfigReadyV1Beta2Condition = BootstrapConfigReadyV1Beta2Condition
// ObjectDoesNotExistV1Beta2Reason surfaces when a referenced object does not exist.
ObjectDoesNotExistV1Beta2Reason = "ObjectDoesNotExist"

// MachineInfrastructureReadyV1Beta2Condition mirrors the corresponding Ready condition from the Machine's Infrastructure resource.
MachineInfrastructureReadyV1Beta2Condition = InfrastructureReadyV1Beta2Condition
// ObjectDeletedV1Beta2Reason surfaces when a referenced object has been deleted.
// Note: controllers can't identify if the object was deleted by the controller itself, e.g.
// during the deletion workflow, or by a users.
ObjectDeletedV1Beta2Reason = "ObjectDeleted"

// MachineNodeHealthyV1Beta2Condition is true if the Machine's Node is ready and it does not report MemoryPressure, DiskPressure and PIDPressure.
MachineNodeHealthyV1Beta2Condition = "NodeHealthy"
// NotPausedV1Beta2Reason surfaces when an object is not paused.
NotPausedV1Beta2Reason = "NotPaused"

// MachineNodeReadyV1Beta2Condition is true if the Machine's Node is ready.
MachineNodeReadyV1Beta2Condition = "NodeReady"

// MachineHealthCheckSucceededV1Beta2Condition is true if MHC instances targeting this machine report the Machine
// is healthy according to the definition of healthy present in the spec of the MachineHealthCheck object.
MachineHealthCheckSucceededV1Beta2Condition = "HealthCheckSucceeded"

// MachineOwnerRemediatedV1Beta2Condition is only present if MHC instances targeting this machine
// determine that the controller owning this machine should perform remediation.
MachineOwnerRemediatedV1Beta2Condition = "OwnerRemediated"

// MachineDeletingV1Beta2Condition surfaces details about progress in the machine deletion workflow.
MachineDeletingV1Beta2Condition = DeletingV1Beta2Condition

// MachinePausedV1Beta2Condition is true if the Machine or the Cluster it belongs to are paused.
MachinePausedV1Beta2Condition = PausedV1Beta2Condition
// PausedV1Beta2Reason surfaces when an object is paused.
PausedV1Beta2Reason = "Paused"
)

// Conditions that will be used for the MachineSet object in v1Beta2 API version.
Expand Down
5 changes: 5 additions & 0 deletions internal/contract/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func (b *BootstrapContract) Ready() *Bool {
}
}

// ReadyConditionType returns the type of the ready condition.
func (b *BootstrapContract) ReadyConditionType() string {
return "Ready"
}

// DataSecretName provide access to status.dataSecretName field in a bootstrap object.
func (b *BootstrapContract) DataSecretName() *String {
return &String{
Expand Down
5 changes: 5 additions & 0 deletions internal/contract/infrastructure_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func (m *InfrastructureMachineContract) Ready() *Bool {
}
}

// ReadyConditionType returns the type of the ready condition.
func (m *InfrastructureMachineContract) ReadyConditionType() string {
return "Ready"
}

// FailureReason provides access to the status.failureReason field in an InfrastructureMachine object. Note that this field is optional.
func (m *InfrastructureMachineContract) FailureReason() *String {
return &String{
Expand Down
Loading
Loading