Skip to content

Commit d934125

Browse files
Small improvements to v1beta2 conditions godoc
1 parent 8fcde6a commit d934125

15 files changed

+63
-10
lines changed

api/v1beta1/cluster_types.go

+8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const (
4545
// ClusterAvailableV1Beta2Condition is true if the Cluster is not deleted, and RemoteConnectionProbe, InfrastructureReady,
4646
// ControlPlaneAvailable, WorkersAvailable, TopologyReconciled (if present) conditions are true.
4747
// If conditions are defined in spec.availabilityGates, those conditions must be true as well.
48+
// Note:
49+
// - When summarizing TopologyReconciled, all reasons except TopologyReconcileFailed and ClusterClassNotReconciled will
50+
// be treated as info. This is because even if topology is not fully reconciled, this is an expected temporary state
51+
// and it doesn't impact availability.
52+
// - When summarizing InfrastructureReady, ControlPlaneAvailable, in case the Cluster is deleting, the absence of the
53+
// referenced object won't be considered as an issue.
4854
ClusterAvailableV1Beta2Condition = AvailableV1Beta2Condition
4955

5056
// ClusterAvailableV1Beta2Reason surfaces when the cluster availability criteria is met.
@@ -270,6 +276,7 @@ const (
270276
// Cluster's ControlPlaneMachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
271277
const (
272278
// ClusterControlPlaneMachinesUpToDateV1Beta2Condition surfaces details of control plane machines not up to date, if any.
279+
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
273280
ClusterControlPlaneMachinesUpToDateV1Beta2Condition = "ControlPlaneMachinesUpToDate"
274281

275282
// ClusterControlPlaneMachinesUpToDateV1Beta2Reason surfaces when all the control plane machine's UpToDate conditions are true.
@@ -293,6 +300,7 @@ const (
293300
// Cluster's WorkerMachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
294301
const (
295302
// ClusterWorkerMachinesUpToDateV1Beta2Condition surfaces details of worker machines not up to date, if any.
303+
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
296304
ClusterWorkerMachinesUpToDateV1Beta2Condition = "WorkerMachinesUpToDate"
297305

298306
// ClusterWorkerMachinesUpToDateV1Beta2Reason surfaces when all the worker machine's UpToDate conditions are true.

api/v1beta1/machine_types.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,19 @@ const (
104104
)
105105

106106
// Machine's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
107-
// Note: when possible, Ready condition will use reasons from the conditions it summarizes.
108107
const (
109108
// MachineReadyV1Beta2Condition is true if the Machine's deletionTimestamp is not set, Machine's BootstrapConfigReady, InfrastructureReady,
110109
// NodeHealthy and HealthCheckSucceeded (if present) conditions are true; if other conditions are defined in spec.readinessGates,
111110
// these conditions must be true as well.
111+
// Note:
112+
// - When summarizing the Deleting condition:
113+
// - Details about Pods stuck in draining or volumes waiting for detach are dropped, in order to improve readability & reduce flickering
114+
// of the condition that bubbles up to the owning resources/ to the Cluster (it also makes it more likely this condition might be aggregated with
115+
// conditions reported by other machines).
116+
// - If deletion is in progress for more than 15m, this surfaces on the summary condition (hint about a possible stale deletion).
117+
// - if drain is in progress for more than 5 minutes, a summery of what is blocking drain also surfaces in the message.
118+
// - When summarizing BootstrapConfigReady, InfrastructureReady, NodeHealthy, in case the Machine is deleting, the absence of the
119+
// referenced object won't be considered as an issue.
112120
MachineReadyV1Beta2Condition = ReadyV1Beta2Condition
113121

114122
// MachineReadyV1Beta2Reason surfaces when the machine readiness criteria is met.
@@ -420,7 +428,11 @@ type MachineSpec struct {
420428
// Another example are external controllers, e.g. responsible to install special software/hardware on the Machines;
421429
// they can include the status of those components with a new condition and add this condition to ReadinessGates.
422430
//
423-
// NOTE: this field is considered only for computing v1beta2 conditions.
431+
// NOTE: This field is considered only for computing v1beta2 conditions.
432+
// NOTE: In case readinessGates conditions start with the APIServer, ControllerManager, Scheduler prefix, and all those
433+
// readiness gates condition are reporting the same message, when computing the Machine's Ready condition those
434+
// readinessGates will be replaced by a single entry reporting "Control plane components: " + message.
435+
// This helps to improve readability of conditions bubbling up to the Machine's owner resource / to the Cluster).
424436
// +optional
425437
// +listType=map
426438
// +listMapKey=conditionType

api/v1beta1/machinedeployment_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const (
128128
// MachineDeployment's MachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
129129
const (
130130
// MachineDeploymentMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
131+
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
131132
MachineDeploymentMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition
132133

133134
// MachineDeploymentMachinesUpToDateV1Beta2Reason surfaces when all the controlled machine's UpToDate conditions are true.

api/v1beta1/machineset_types.go

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type MachineSetSpec struct {
9090
// MachineSet's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
9191
const (
9292
// MachineSetScalingUpV1Beta2Condition is true if actual replicas < desired replicas.
93+
// Note: In case a MachineSet preflight check is preventing scale up, this will surface in the condition message.
9394
MachineSetScalingUpV1Beta2Condition = ScalingUpV1Beta2Condition
9495

9596
// MachineSetScalingUpV1Beta2Reason surfaces when actual replicas < desired replicas.
@@ -153,6 +154,7 @@ const (
153154
// Note: Reason's could also be derived from the aggregation of machine's MachinesUpToDate conditions.
154155
const (
155156
// MachineSetMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
157+
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
156158
MachineSetMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition
157159

158160
// MachineSetMachinesUpToDateV1Beta2Reason surfaces when all the controlled machine's UpToDate conditions are true.

api/v1beta1/zz_generated.openapi.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinepools.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machines.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_machinesets.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/api/v1beta1/v1beta2_condition_consts.go

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const (
3030
// plane cannot be considered operational (if etcd is not operational on a machine, most likely also API server,
3131
// scheduler and controller manager on the same machine will be impacted).
3232
// - In case of external etcd, KCP cannot make any assumption on etcd status, so all the etcd checks are skipped.
33+
//
34+
// Please note that when this condition is true, partial unavailability will be surfaced in the condition message,
35+
// but with a 10s delay to ensure flakes do not impact condition stability.
3336
KubeadmControlPlaneAvailableV1Beta2Condition = clusterv1.AvailableV1Beta2Condition
3437

3538
// KubeadmControlPlaneAvailableInspectionFailedV1Beta2Reason documents a failure when inspecting the status of the
@@ -157,6 +160,7 @@ const (
157160
// KubeadmControlPlane's MachinesUpToDate condition and corresponding reasons that will be used in v1Beta2 API version.
158161
const (
159162
// KubeadmControlPlaneMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
163+
// Note: New machines are considered 10s after machine creation. This gives time to the machine's owner controller to recognize the new machine and add the UpToDate condition.
160164
KubeadmControlPlaneMachinesUpToDateV1Beta2Condition = clusterv1.MachinesUpToDateV1Beta2Condition
161165

162166
// KubeadmControlPlaneMachinesUpToDateV1Beta2Reason surfaces when all the controlled machine's UpToDate conditions are true.
@@ -194,6 +198,7 @@ const (
194198
// KubeadmControlPlane's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
195199
const (
196200
// KubeadmControlPlaneScalingUpV1Beta2Condition is true if actual replicas < desired replicas.
201+
// Note: In case a KubeadmControlPlane preflight check is preventing scale up, this will surface in the condition message.
197202
KubeadmControlPlaneScalingUpV1Beta2Condition = clusterv1.ScalingUpV1Beta2Condition
198203

199204
// KubeadmControlPlaneScalingUpV1Beta2Reason surfaces when actual replicas < desired replicas.
@@ -210,6 +215,7 @@ const (
210215
// KubeadmControlPlane's ScalingDown condition and corresponding reasons that will be used in v1Beta2 API version.
211216
const (
212217
// KubeadmControlPlaneScalingDownV1Beta2Condition is true if actual replicas > desired replicas.
218+
// Note: In case a KubeadmControlPlane preflight check is preventing scale down, this will surface in the condition message.
213219
KubeadmControlPlaneScalingDownV1Beta2Condition = clusterv1.ScalingDownV1Beta2Condition
214220

215221
// KubeadmControlPlaneScalingDownV1Beta2Reason surfaces when actual replicas > desired replicas.

controlplane/kubeadm/internal/controllers/controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ func reconcileMachineUpToDateCondition(_ context.Context, controlPlane *internal
977977

978978
for _, machine := range controlPlane.Machines {
979979
if machinesNotUptoDateNames.Has(machine.Name) {
980+
// Note: the code computing the message for KCP's RolloutOut condition is making assumptions on the format/content of this message.
980981
message := ""
981982
if reasons, ok := machinesNotUptoDateConditionMessages[machine.Name]; ok {
982983
for i := range reasons {

controlplane/kubeadm/internal/filters.go

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func matchesMachineSpec(infraConfigs map[string]*unstructured.Unstructured, mach
5050
machineVersion = *machine.Spec.Version
5151
}
5252
logMessages = append(logMessages, fmt.Sprintf("Machine version %q is not equal to KCP version %q", machineVersion, kcp.Spec.Version))
53+
// Note: the code computing the message for KCP's RolloutOut condition is making assumptions on the format/content of this message.
5354
conditionMessages = append(conditionMessages, fmt.Sprintf("Version %s, %s required", machineVersion, kcp.Spec.Version))
5455
}
5556

internal/controllers/machine/drain/drain.go

+4
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ func (r EvictionResult) ConditionMessage(nodeDrainStartTime *metav1.Time) string
452452
if len(r.PodsDeletionTimestampSet) > 1 {
453453
kind = "Pods"
454454
}
455+
// Note: the code computing stale warning for the machine deleting condition is making assumptions on the format/content of this message.
456+
// Same applies for other conditions where deleting is involved, e.g. MachineSet's Deleting and ScalingDown condition.
455457
conditionMessage = fmt.Sprintf("%s\n* %s %s: deletionTimestamp set, but still not removed from the Node",
456458
conditionMessage, kind, PodListToString(r.PodsDeletionTimestampSet, 3))
457459
}
@@ -470,6 +472,8 @@ func (r EvictionResult) ConditionMessage(nodeDrainStartTime *metav1.Time) string
470472
if len(pods) > 1 {
471473
kind = "Pods"
472474
}
475+
// Note: the code computing stale warning for the machine deleting condition is making assumptions on the format/content of this message.
476+
// Same applies for other conditions where deleting is involved, e.g. MachineSet's Deleting and ScalingDown condition.
473477
failureMessage = strings.Replace(failureMessage, "Cannot evict pod as it would violate the pod's disruption budget.", "cannot evict pod as it would violate the pod's disruption budget.", -1)
474478
if !strings.HasPrefix(failureMessage, "cannot evict pod as it would violate the pod's disruption budget.") {
475479
failureMessage = "failed to evict Pod, " + failureMessage

internal/controllers/machinedeployment/mdutil/util.go

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ func MachineTemplateUpToDate(current, desired *clusterv1.MachineTemplateSpec) (u
379379

380380
if !reflect.DeepEqual(currentCopy.Spec.Version, desiredCopy.Spec.Version) {
381381
logMessages = append(logMessages, fmt.Sprintf("spec.version %s, %s required", ptr.Deref(currentCopy.Spec.Version, "nil"), ptr.Deref(desiredCopy.Spec.Version, "nil")))
382+
// Note: the code computing the message for MachineDeployment's RolloutOut condition is making assumptions on the format/content of this message.
382383
conditionMessages = append(conditionMessages, fmt.Sprintf("Version %s, %s required", ptr.Deref(currentCopy.Spec.Version, "nil"), ptr.Deref(desiredCopy.Spec.Version, "nil")))
383384
}
384385

internal/controllers/machineset/machineset_controller.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,10 @@ func newMachineUpToDateCondition(s *scope) *metav1.Condition {
645645
conditionMessages[i] = fmt.Sprintf("* %s", conditionMessages[i])
646646
}
647647
return &metav1.Condition{
648-
Type: clusterv1.MachineUpToDateV1Beta2Condition,
649-
Status: metav1.ConditionFalse,
650-
Reason: clusterv1.MachineNotUpToDateV1Beta2Reason,
648+
Type: clusterv1.MachineUpToDateV1Beta2Condition,
649+
Status: metav1.ConditionFalse,
650+
Reason: clusterv1.MachineNotUpToDateV1Beta2Reason,
651+
// Note: the code computing the message for MachineDeployment's RolloutOut condition is making assumptions on the format/content of this message.
651652
Message: strings.Join(conditionMessages, "\n"),
652653
}
653654
}

0 commit comments

Comments
 (0)