Skip to content

Commit a564e09

Browse files
Add v1beta2 condition to MD controller
1 parent e5cbc4a commit a564e09

14 files changed

+1917
-78
lines changed

api/v1beta1/machinedeployment_types.go

+123
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,129 @@ const (
7777
MachineDeploymentUniqueLabel = "machine-template-hash"
7878
)
7979

80+
// MachineDeployment's Available condition and corresponding reasons that will be used in v1Beta2 API version.
81+
const (
82+
// MachineDeploymentAvailableV1Beta2Condition is true if the MachineDeployment is not deleted, and it has minimum
83+
// availability according to parameters specified in the deployment strategy, e.g. If using RollingUpgrade strategy,
84+
// availableReplicas must be greater or equal than desired replicas - MaxUnavailable replicas.
85+
MachineDeploymentAvailableV1Beta2Condition = AvailableV1Beta2Condition
86+
87+
// MachineDeploymentAvailableWaitingForReplicasSetV1Beta2Reason surfaces when the .spec.replicas
88+
// field of the MachineDeployment is not set.
89+
MachineDeploymentAvailableWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
90+
91+
// MachineDeploymentAvailableWaitingForAvailableReplicasSetV1Beta2Reason surfaces when the .status.v1beta2.availableReplicas
92+
// field of the MachineDeployment is not set.
93+
MachineDeploymentAvailableWaitingForAvailableReplicasSetV1Beta2Reason = "WaitingForAvailableReplicasSet"
94+
95+
// MachineDeploymentAvailableV1Beta2Reason surfaces when a Deployment is available.
96+
MachineDeploymentAvailableV1Beta2Reason = AvailableV1Beta2Reason
97+
98+
// MachineDeploymentNotAvailableV1Beta2Reason surfaces when a Deployment is not available.
99+
MachineDeploymentNotAvailableV1Beta2Reason = NotAvailableV1Beta2Reason
100+
101+
// MachineDeploymentAvailableInternalErrorV1Beta2Reason surfaces unexpected failures when computing the Available condition.
102+
MachineDeploymentAvailableInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
103+
)
104+
105+
// MachineDeployment's MachinesReady condition and corresponding reasons that will be used in v1Beta2 API version.
106+
const (
107+
// MachineDeploymentMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
108+
MachineDeploymentMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition
109+
110+
// MachineDeploymentMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineDeployment.
111+
MachineDeploymentMachinesReadyNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason
112+
113+
// MachineDeploymentMachinesReadyInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
114+
// or aggregating machine's conditions.
115+
MachineDeploymentMachinesReadyInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
116+
)
117+
118+
// MachineDeployment's MachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
119+
const (
120+
// MachineDeploymentMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
121+
MachineDeploymentMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition
122+
123+
// MachineDeploymentMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineDeployment.
124+
MachineDeploymentMachinesUpToDateNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason
125+
126+
// MachineDeploymentMachinesUpToDateInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
127+
// or aggregating status.
128+
MachineDeploymentMachinesUpToDateInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
129+
)
130+
131+
// MachineDeployment's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
132+
const (
133+
// MachineDeploymentScalingUpV1Beta2Condition is true if available replicas < desired replicas.
134+
MachineDeploymentScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition
135+
136+
// MachineDeploymentScalingUpV1Beta2Reason surfaces when actual replicas < desired replicas.
137+
MachineDeploymentScalingUpV1Beta2Reason = ScalingUpV1Beta2Reason
138+
139+
// MachineDeploymentNotScalingUpV1Beta2Reason surfaces when actual replicas >= desired replicas.
140+
MachineDeploymentNotScalingUpV1Beta2Reason = NotScalingUpV1Beta2Reason
141+
142+
// MachineDeploymentScalingUpInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines.
143+
MachineDeploymentScalingUpInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
144+
145+
// MachineDeploymentScalingUpWaitingForReplicasSetV1Beta2Reason surfaces when the .spec.replicas
146+
// field of the MachineDeployment is not set.
147+
MachineDeploymentScalingUpWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
148+
)
149+
150+
// MachineDeployment's ScalingDown condition and corresponding reasons that will be used in v1Beta2 API version.
151+
const (
152+
// MachineDeploymentScalingDownV1Beta2Condition is true if replicas > desired replicas.
153+
MachineDeploymentScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition
154+
155+
// MachineDeploymentScalingDownV1Beta2Reason surfaces when actual replicas > desired replicas.
156+
MachineDeploymentScalingDownV1Beta2Reason = ScalingDownV1Beta2Reason
157+
158+
// MachineDeploymentNotScalingDownV1Beta2Reason surfaces when actual replicas <= desired replicas.
159+
MachineDeploymentNotScalingDownV1Beta2Reason = NotScalingDownV1Beta2Reason
160+
161+
// MachineDeploymentScalingDownInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines.
162+
MachineDeploymentScalingDownInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
163+
164+
// MachineDeploymentScalingDownWaitingForReplicasSetV1Beta2Reason surfaces when the .spec.replicas
165+
// field of the MachineDeployment is not set.
166+
MachineDeploymentScalingDownWaitingForReplicasSetV1Beta2Reason = WaitingForReplicasSetV1Beta2Reason
167+
)
168+
169+
// MachineDeployment's Remediating condition and corresponding reasons that will be used in v1Beta2 API version.
170+
const (
171+
// MachineDeploymentRemediatingV1Beta2Condition details about ongoing remediation of the controlled machines, if any.
172+
MachineDeploymentRemediatingV1Beta2Condition = RemediatingV1Beta2Condition
173+
174+
// MachineDeploymentRemediatingV1Beta2Reason surfaces when the MachineDeployment has at least one machine with HealthCheckSucceeded set to false
175+
// and with the OwnerRemediated condition set to false.
176+
MachineDeploymentRemediatingV1Beta2Reason = RemediatingV1Beta2Reason
177+
178+
// MachineDeploymentNotRemediatingV1Beta2Reason surfaces when the MachineDeployment does not have any machine with HealthCheckSucceeded set to false
179+
// and with the OwnerRemediated condition set to false.
180+
MachineDeploymentNotRemediatingV1Beta2Reason = NotRemediatingV1Beta2Reason
181+
182+
// MachineDeploymentRemediatingInternalErrorV1Beta2Reason surfaces unexpected failures when computing the Remediating condition.
183+
MachineDeploymentRemediatingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
184+
)
185+
186+
// MachineDeployment's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
187+
const (
188+
// MachineDeploymentDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
189+
MachineDeploymentDeletingV1Beta2Condition = DeletingV1Beta2Condition
190+
191+
// MachineDeploymentDeletingDeletionTimestampNotSetV1Beta2Reason surfaces when the MachineDeployment is not deleting because the
192+
// DeletionTimestamp is not set.
193+
MachineDeploymentDeletingDeletionTimestampNotSetV1Beta2Reason = DeletionTimestampNotSetV1Beta2Reason
194+
195+
// MachineDeploymentDeletingDeletionTimestampSetV1Beta2Reason surfaces when the MachineDeployment is deleting because the
196+
// DeletionTimestamp is set.
197+
MachineDeploymentDeletingDeletionTimestampSetV1Beta2Reason = DeletionTimestampSetV1Beta2Reason
198+
199+
// MachineDeploymentDeletingInternalErrorV1Beta2Reason surfaces unexpected failures when deleting a MachineDeployment.
200+
MachineDeploymentDeletingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
201+
)
202+
80203
// ANCHOR: MachineDeploymentSpec
81204

82205
// MachineDeploymentSpec defines the desired state of MachineDeployment.

api/v1beta1/v1beta2_condition_consts.go

+3-26
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ const (
9090
// AvailableV1Beta2Reason applies to a condition surfacing object availability.
9191
AvailableV1Beta2Reason = "Available"
9292

93+
// NotAvailableV1Beta2Reason applies to a condition surfacing object not satisfying availability per-requisites.
94+
NotAvailableV1Beta2Reason = "NotAvailable"
95+
9396
// ScalingUpV1Beta2Reason surfaces when an object is scaling up.
9497
ScalingUpV1Beta2Reason = "ScalingUp"
9598

@@ -170,32 +173,6 @@ const (
170173
InspectionFailedV1Beta2Reason = "InspectionFailed"
171174
)
172175

173-
// Conditions that will be used for the MachineDeployment object in v1Beta2 API version.
174-
const (
175-
// MachineDeploymentAvailableV1Beta2Condition is true if the MachineDeployment is not deleted, and it has minimum
176-
// availability according to parameters specified in the deployment strategy, e.g. If using RollingUpgrade strategy,
177-
// availableReplicas must be greater or equal than desired replicas - MaxUnavailable replicas.
178-
MachineDeploymentAvailableV1Beta2Condition = AvailableV1Beta2Condition
179-
180-
// MachineDeploymentMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
181-
MachineDeploymentMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition
182-
183-
// MachineDeploymentMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
184-
MachineDeploymentMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition
185-
186-
// MachineDeploymentScalingUpV1Beta2Condition is true if available replicas < desired replicas.
187-
MachineDeploymentScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition
188-
189-
// MachineDeploymentScalingDownV1Beta2Condition is true if replicas > desired replicas.
190-
MachineDeploymentScalingDownV1Beta2Condition = ScalingDownV1Beta2Condition
191-
192-
// MachineDeploymentRemediatingV1Beta2Condition details about ongoing remediation of the controlled machines, if any.
193-
MachineDeploymentRemediatingV1Beta2Condition = RemediatingV1Beta2Condition
194-
195-
// MachineDeploymentDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
196-
MachineDeploymentDeletingV1Beta2Condition = DeletingV1Beta2Condition
197-
)
198-
199176
// Conditions that will be used for the Cluster object in v1Beta2 API version.
200177
const (
201178
// ClusterAvailableV1Beta2Condition is true if the Cluster's is not deleted, and RemoteConnectionProbe, InfrastructureReady,

controlplane/kubeadm/api/v1beta1/v1beta2_condition_consts.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ const (
154154
// Note: KubeadmControlPlane only remediates machines with HealthCheckSucceeded set to false and with the OwnerRemediated condition set to false.
155155
KubeadmControlPlaneRemediatingV1Beta2Condition = clusterv1.RemediatingV1Beta2Condition
156156

157-
// KubeadmControlPlaneRemediatingV1Beta2Reason surfaces when kcp has at least one machine with HealthCheckSucceeded set to false
157+
// KubeadmControlPlaneRemediatingV1Beta2Reason surfaces when the KubeadmControlPlane has at least one machine with HealthCheckSucceeded set to false
158158
// and with the OwnerRemediated condition set to false.
159159
KubeadmControlPlaneRemediatingV1Beta2Reason = clusterv1.RemediatingV1Beta2Reason
160160

161-
// KubeadmControlPlaneNotRemediatingV1Beta2Reason surfaces when kcp does not have any machine with HealthCheckSucceeded set to false
161+
// KubeadmControlPlaneNotRemediatingV1Beta2Reason surfaces when the KubeadmControlPlane does not have any machine with HealthCheckSucceeded set to false
162162
// and with the OwnerRemediated condition set to false.
163163
KubeadmControlPlaneNotRemediatingV1Beta2Reason = clusterv1.NotRemediatingV1Beta2Reason
164164

controlplane/kubeadm/internal/controllers/status.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ import (
3737
clog "sigs.k8s.io/cluster-api/util/log"
3838
)
3939

40-
// updateStatus is called after every reconcilitation loop in a defer statement to always make sure we have the
41-
// resource status subresourcs up-to-date.
40+
// updateStatus is called after every reconciliation loop in a defer statement to always make sure we have the
41+
// KubeadmControlPlane status up-to-date.
4242
func (r *KubeadmControlPlaneReconciler) updateStatus(ctx context.Context, controlPlane *internal.ControlPlane) error {
4343
selector := collections.ControlPlaneSelectorForCluster(controlPlane.Cluster.Name)
4444
// Copy label selector to its status counterpart in string format.
@@ -380,7 +380,6 @@ func setRemediatingCondition(ctx context.Context, kcp *controlplanev1.KubeadmCon
380380
return
381381
}
382382

383-
// TODO: Bring together externally remediated machines and owner remediated machines
384383
remediatingCondition, err := v1beta2conditions.NewAggregateCondition(
385384
machinesToBeRemediated.UnsortedList(), clusterv1.MachineOwnerRemediatedV1Beta2Condition,
386385
v1beta2conditions.TargetConditionType(controlplanev1.KubeadmControlPlaneRemediatingV1Beta2Condition),

internal/controllers/machine/machine_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
225225
}
226226

227227
defer func() {
228-
r.reconcileStatus(ctx, s)
228+
r.updateStatus(ctx, s)
229229

230230
// Always attempt to patch the object and status after each reconciliation.
231231
// Patch ObservedGeneration only if the reconciliation completed successfully

internal/controllers/machine/machine_controller_status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ import (
3737
v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
3838
)
3939

40-
// reconcileStatus reconciles Machine's status during the entire lifecycle of the machine.
40+
// updateStatus update Machine's status.
4141
// This implies that the code in this function should account for several edge cases e.g. machine being partially provisioned,
4242
// machine being partially deleted but also for running machines being disrupted e.g. by deleting the node.
4343
// Additionally, this func should ensure that the conditions managed by this controller are always set in order to
4444
// comply with the recommendation in the Kubernetes API guidelines.
4545
// Note: v1beta1 conditions are not managed by this func.
46-
func (r *Reconciler) reconcileStatus(ctx context.Context, s *scope) {
46+
func (r *Reconciler) updateStatus(ctx context.Context, s *scope) {
4747
// Update status from the Bootstrap Config external resource.
4848
// Note: some of the status fields derived from the Bootstrap Config are managed in reconcileBootstrap, e.g. status.BootstrapReady, etc.
4949
// here we are taking care only of the delta (condition).

0 commit comments

Comments
 (0)