Skip to content

Commit 74d34e3

Browse files
authored
Merge pull request #11276 from fabriziopandini/update-v1beta2-status-machine-controller
✨ Update machine with v1beta2 status
2 parents 0f8e172 + 7278f4a commit 74d34e3

24 files changed

+2971
-1095
lines changed

api/v1beta1/machine_types.go

+144
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,150 @@ const (
8686
ManagedNodeLabelDomain = "node.cluster.x-k8s.io"
8787
)
8888

89+
// Machine's Available condition and corresponding reasons that will be used in v1Beta2 API version.
90+
const (
91+
// MachineAvailableV1Beta2Condition is true if the machine is Ready for at least MinReadySeconds, as defined by the Machine's MinReadySeconds field.
92+
// Note: MinReadySeconds is assumed 0 until it will be implemented in v1beta2 API.
93+
MachineAvailableV1Beta2Condition = AvailableV1Beta2Condition
94+
95+
// MachineNotReadyV1Beta2Reason surfaces when a machine is not ready (and thus not available).
96+
MachineNotReadyV1Beta2Reason = "NotReady"
97+
98+
// MachineWaitingForMinReadySecondsV1Beta2Reason surfaces when a machine is ready for less than MinReadySeconds (and thus not yet available).
99+
MachineWaitingForMinReadySecondsV1Beta2Reason = "WaitingForMinReadySeconds"
100+
101+
// MachineReadyNotYetReportedV1Beta2Reason surfaces when a machine ready is not reported yet.
102+
// Note: this should never happen and it is a signal of some internal error.
103+
MachineReadyNotYetReportedV1Beta2Reason = "ReadyNotYetReported"
104+
105+
// MachineAvailableV1Beta2Reason surfaces when a machine is ready for at least MinReadySeconds.
106+
// Note: MinReadySeconds is assumed 0 until it will be implemented in v1beta2 API.
107+
MachineAvailableV1Beta2Reason = AvailableV1Beta2Condition
108+
)
109+
110+
// Machine's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
111+
// Note: when possible, Ready condition will use reasons from the conditions it summarizes.
112+
const (
113+
// MachineReadyV1Beta2Condition is true if the Machine's deletionTimestamp is not set, Machine's BootstrapConfigReady, InfrastructureReady,
114+
// NodeHealthy and HealthCheckSucceeded (if present) conditions are true; if other conditions are defined in spec.readinessGates,
115+
// these conditions must be true as well.
116+
MachineReadyV1Beta2Condition = ReadyV1Beta2Condition
117+
118+
// MachineErrorComputingReadyV1Beta2Reason surfaces when there was an error computing the ready condition.
119+
// Note: this should never happen and it is a signal of some internal error.
120+
MachineErrorComputingReadyV1Beta2Reason = "ErrorComputingReady"
121+
)
122+
123+
// Machine's UpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
124+
// Note: UpToDate condition is set by the controller owning the machine.
125+
const (
126+
// MachineUpToDateV1Beta2Condition is true if the Machine spec matches the spec of the Machine's owner resource, e.g. KubeadmControlPlane or MachineDeployment.
127+
// The Machine's owner (e.g. MachineDeployment) is authoritative to set their owned Machine's UpToDate conditions based on its current spec.
128+
MachineUpToDateV1Beta2Condition = "UpToDate"
129+
)
130+
131+
// Machine's BootstrapConfigReady condition and corresponding reasons that will be used in v1Beta2 API version.
132+
// Note: when possible, BootstrapConfigReady condition will use reasons surfaced from the underlying bootstrap config object.
133+
const (
134+
// MachineBootstrapConfigReadyV1Beta2Condition condition mirrors the corresponding Ready condition from the Machine's BootstrapConfig resource.
135+
MachineBootstrapConfigReadyV1Beta2Condition = BootstrapConfigReadyV1Beta2Condition
136+
137+
// MachineBootstrapDataSecretProvidedV1Beta2Reason surfaces when a bootstrap data secret is provided (not originated
138+
// from a BoostrapConfig object referenced from the machine).
139+
MachineBootstrapDataSecretProvidedV1Beta2Reason = "DataSecretProvided"
140+
141+
// MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason surfaces a BootstrapConfig Ready condition (read from a bootstrap config object) which is invalid.
142+
// (e.g. its status is missing).
143+
MachineBootstrapConfigInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
144+
145+
// MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason applies to a BootstrapConfig Ready condition (read from a bootstrap config object) that reports no reason.
146+
MachineBootstrapConfigReadyNoReasonReportedV1Beta2Reason = NoReasonReportedV1Beta2Reason
147+
148+
// MachineBootstrapConfigInternalErrorV1Beta2Reason surfaces unexpected failures when reading a BootstrapConfig object.
149+
MachineBootstrapConfigInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
150+
151+
// MachineBootstrapConfigDoesNotExistV1Beta2Reason surfaces when a referenced bootstrap config object does not exist.
152+
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
153+
MachineBootstrapConfigDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason
154+
155+
// MachineBootstrapConfigDeletedV1Beta2Reason surfaces when a referenced bootstrap config object has been deleted.
156+
// Note: controllers can't identify if the bootstrap config object was deleted the controller itself, e.g.
157+
// during the deletion workflow, or by a users.
158+
MachineBootstrapConfigDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
159+
)
160+
161+
// Machine's InfrastructureReady condition and corresponding reasons that will be used in v1Beta2 API version.
162+
// Note: when possible, InfrastructureReady condition will use reasons surfaced from the underlying infra machine object.
163+
const (
164+
// MachineInfrastructureReadyV1Beta2Condition mirrors the corresponding Ready condition from the Machine's Infrastructure resource.
165+
MachineInfrastructureReadyV1Beta2Condition = InfrastructureReadyV1Beta2Condition
166+
167+
// MachineInfrastructureInvalidConditionReportedV1Beta2Reason surfaces a infrastructure Ready condition (read from an infra machine object) which is invalid.
168+
// (e.g. its status is missing).
169+
MachineInfrastructureInvalidConditionReportedV1Beta2Reason = InvalidConditionReportedV1Beta2Reason
170+
171+
// MachineInfrastructureReadyNoReasonReportedV1Beta2Reason applies to a infrastructure Ready condition (read from an infra machine object) that reports no reason.
172+
MachineInfrastructureReadyNoReasonReportedV1Beta2Reason = NoReasonReportedV1Beta2Reason
173+
174+
// MachineInfrastructureInternalErrorV1Beta2Reason surfaces unexpected failures when reading a infra machine object.
175+
MachineInfrastructureInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
176+
177+
// MachineInfrastructureDoesNotExistV1Beta2Reason surfaces when a referenced infrastructure object does not exist.
178+
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
179+
MachineInfrastructureDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason
180+
181+
// MachineInfrastructureDeletedV1Beta2Reason surfaces when a referenced infrastructure object has been deleted.
182+
// Note: controllers can't identify if the infrastructure object was deleted by the controller itself, e.g.
183+
// during the deletion workflow, or by a users.
184+
MachineInfrastructureDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
185+
)
186+
187+
// Machine's NodeHealthy and NodeReady conditions and corresponding reasons that will be used in v1Beta2 API version.
188+
// Note: when possible, NodeHealthy and NodeReady conditions will use reasons surfaced from the underlying node.
189+
const (
190+
// MachineNodeHealthyV1Beta2Condition is true if the Machine's Node is ready and it does not report MemoryPressure, DiskPressure and PIDPressure.
191+
MachineNodeHealthyV1Beta2Condition = "NodeHealthy"
192+
193+
// MachineNodeReadyV1Beta2Condition is true if the Machine's Node is ready.
194+
MachineNodeReadyV1Beta2Condition = "NodeReady"
195+
196+
// MachineNodeConditionNotYetReportedV1Beta2Reason surfaces when a Machine's Node doesn't have a condition reported yet.
197+
MachineNodeConditionNotYetReportedV1Beta2Reason = "NodeConditionNotYetReported"
198+
199+
// MachineNodeDoesNotExistV1Beta2Reason surfaces when the node hosted on the machine does not exist.
200+
// Note: this could happen when creating the machine. However, this state should be treated as an error if it lasts indefinitely.
201+
MachineNodeDoesNotExistV1Beta2Reason = ObjectDoesNotExistV1Beta2Reason
202+
203+
// MachineNodeDeletedV1Beta2Reason surfaces when the node hosted on the machine has been deleted.
204+
// Note: controllers can't identify if the Node was deleted by the controller itself, e.g.
205+
// during the deletion workflow, or by a users.
206+
MachineNodeDeletedV1Beta2Reason = ObjectDeletedV1Beta2Reason
207+
)
208+
209+
// Machine's HealthCheckSucceeded and OwnerRemediated conditions and corresponding reasons that will be used in v1Beta2 API version.
210+
// Note: HealthCheckSucceeded and OwnerRemediated condition are set by the MachineHealthCheck controller.
211+
const (
212+
// MachineHealthCheckSucceededV1Beta2Condition is true if MHC instances targeting this machine report the Machine
213+
// is healthy according to the definition of healthy present in the spec of the MachineHealthCheck object.
214+
MachineHealthCheckSucceededV1Beta2Condition = "HealthCheckSucceeded"
215+
216+
// MachineOwnerRemediatedV1Beta2Condition is only present if MHC instances targeting this machine
217+
// determine that the controller owning this machine should perform remediation.
218+
MachineOwnerRemediatedV1Beta2Condition = "OwnerRemediated"
219+
)
220+
221+
// Machine's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
222+
const (
223+
// MachineDeletingV1Beta2Condition surfaces details about progress in the machine deletion workflow.
224+
MachineDeletingV1Beta2Condition = DeletingV1Beta2Condition
225+
)
226+
227+
// Machine's Paused condition and corresponding reasons that will be used in v1Beta2 API version.
228+
const (
229+
// MachinePausedV1Beta2Condition is true if the Machine or the Cluster it belongs to are paused.
230+
MachinePausedV1Beta2Condition = PausedV1Beta2Condition
231+
)
232+
89233
// ANCHOR: MachineSpec
90234

91235
// MachineSpec defines the desired state of Machine.

api/v1beta1/v1beta2_condition_consts.go

+20-32
Original file line numberDiff line numberDiff line change
@@ -85,45 +85,33 @@ const (
8585
PausedV1Beta2Condition = "Paused"
8686
)
8787

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

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

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

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

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

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

111-
// MachineNodeReadyV1Beta2Condition is true if the Machine's Node is ready.
112-
MachineNodeReadyV1Beta2Condition = "NodeReady"
113-
114-
// MachineHealthCheckSucceededV1Beta2Condition is true if MHC instances targeting this machine report the Machine
115-
// is healthy according to the definition of healthy present in the spec of the MachineHealthCheck object.
116-
MachineHealthCheckSucceededV1Beta2Condition = "HealthCheckSucceeded"
117-
118-
// MachineOwnerRemediatedV1Beta2Condition is only present if MHC instances targeting this machine
119-
// determine that the controller owning this machine should perform remediation.
120-
MachineOwnerRemediatedV1Beta2Condition = "OwnerRemediated"
121-
122-
// MachineDeletingV1Beta2Condition surfaces details about progress in the machine deletion workflow.
123-
MachineDeletingV1Beta2Condition = DeletingV1Beta2Condition
124-
125-
// MachinePausedV1Beta2Condition is true if the Machine or the Cluster it belongs to are paused.
126-
MachinePausedV1Beta2Condition = PausedV1Beta2Condition
113+
// PausedV1Beta2Reason surfaces when an object is paused.
114+
PausedV1Beta2Reason = "Paused"
127115
)
128116

129117
// Conditions that will be used for the MachineSet object in v1Beta2 API version.

internal/contract/bootstrap.go

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ func (b *BootstrapContract) Ready() *Bool {
3939
}
4040
}
4141

42+
// ReadyConditionType returns the type of the ready condition.
43+
func (b *BootstrapContract) ReadyConditionType() string {
44+
return "Ready"
45+
}
46+
4247
// DataSecretName provide access to status.dataSecretName field in a bootstrap object.
4348
func (b *BootstrapContract) DataSecretName() *String {
4449
return &String{

internal/contract/infrastructure_machine.go

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func (m *InfrastructureMachineContract) Ready() *Bool {
4949
}
5050
}
5151

52+
// ReadyConditionType returns the type of the ready condition.
53+
func (m *InfrastructureMachineContract) ReadyConditionType() string {
54+
return "Ready"
55+
}
56+
5257
// FailureReason provides access to the status.failureReason field in an InfrastructureMachine object. Note that this field is optional.
5358
func (m *InfrastructureMachineContract) FailureReason() *String {
5459
return &String{

0 commit comments

Comments
 (0)