Skip to content

Commit

Permalink
Merge pull request #11411 from fabriziopandini/refine-v1beta2-conditi…
Browse files Browse the repository at this point in the history
…on-reasons

🌱 Refine v1beta2 condition reasons
  • Loading branch information
k8s-ci-robot authored Nov 13, 2024
2 parents c9654bb + 18d0cdc commit 7702621
Show file tree
Hide file tree
Showing 23 changed files with 660 additions and 279 deletions.
53 changes: 51 additions & 2 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ const (
// If conditions are defined in spec.availabilityGates, those conditions must be true as well.
ClusterAvailableV1Beta2Condition = AvailableV1Beta2Condition

// ClusterAvailableV1Beta2Reason surfaces when the cluster availability criteria is met.
ClusterAvailableV1Beta2Reason = AvailableV1Beta2Reason

// ClusterNotAvailableV1Beta2Reason surfaces when the cluster availability criteria is not met (and thus the machine is not available).
ClusterNotAvailableV1Beta2Reason = NotAvailableV1Beta2Reason

// ClusterAvailableUnknownV1Beta2Reason surfaces when at least one cluster availability criteria is unknown
// and no availability criteria is not met.
ClusterAvailableUnknownV1Beta2Reason = AvailableUnknownV1Beta2Reason

// ClusterAvailableInternalErrorV1Beta2Reason surfaces unexpected error when computing the Available condition.
ClusterAvailableInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
Expand Down Expand Up @@ -186,6 +196,17 @@ const (
// Note: Stand-alone MachineSets and stand-alone Machines are not included in this condition.
ClusterWorkersAvailableV1Beta2Condition = "WorkersAvailable"

// ClusterWorkersAvailableV1Beta2Reason surfaces when all MachineDeployment and MachinePool's Available conditions are true.
ClusterWorkersAvailableV1Beta2Reason = AvailableV1Beta2Reason

// ClusterWorkersNotAvailableV1Beta2Reason surfaces when at least one of the MachineDeployment and MachinePool's Available
// conditions is false.
ClusterWorkersNotAvailableV1Beta2Reason = NotAvailableV1Beta2Reason

// ClusterWorkersAvailableUnknownV1Beta2Reason surfaces when at least one of the MachineDeployment and MachinePool's Available
// conditions is unknown and none of those Available conditions is false.
ClusterWorkersAvailableUnknownV1Beta2Reason = AvailableUnknownV1Beta2Reason

// ClusterWorkersAvailableNoWorkersV1Beta2Reason surfaces when no MachineDeployment and MachinePool exist for the Cluster.
ClusterWorkersAvailableNoWorkersV1Beta2Reason = "NoWorkers"

Expand All @@ -199,6 +220,16 @@ const (
// ClusterMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
ClusterMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition

// ClusterMachinesReadyV1Beta2Reason surfaces when all the controlled machine's Ready conditions are true.
ClusterMachinesReadyV1Beta2Reason = ReadyV1Beta2Reason

// ClusterMachinesNotReadyV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is false.
ClusterMachinesNotReadyV1Beta2Reason = NotReadyV1Beta2Reason

// ClusterMachinesReadyUnknownV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is unknown
// and none of the controlled machine's Ready conditions is false.
ClusterMachinesReadyUnknownV1Beta2Reason = ReadyUnknownV1Beta2Reason

// ClusterMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the Cluster.
ClusterMachinesReadyNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason

Expand All @@ -212,6 +243,16 @@ const (
// ClusterMachinesUpToDateV1Beta2Condition surfaces details of Cluster's machines not up to date, if any.
ClusterMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition

// ClusterMachinesUpToDateV1Beta2Reason surfaces when all the controlled machine's UpToDate conditions are true.
ClusterMachinesUpToDateV1Beta2Reason = UpToDateV1Beta2Reason

// ClusterMachinesNotUpToDateV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is false.
ClusterMachinesNotUpToDateV1Beta2Reason = NotUpToDateV1Beta2Reason

// ClusterMachinesUpToDateUnknownV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is unknown
// and none of the controlled machine's UpToDate conditions is false.
ClusterMachinesUpToDateUnknownV1Beta2Reason = UpToDateUnknownV1Beta2Reason

// ClusterMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the Cluster.
ClusterMachinesUpToDateNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason

Expand Down Expand Up @@ -244,10 +285,14 @@ const (
// MachinePools and stand-alone MachineSets are scaling up.
ClusterScalingUpV1Beta2Reason = ScalingUpV1Beta2Reason

// ClusterNotScalingUpV1Beta2Reason surfaces when no one of the Cluster's control plane, MachineDeployments,
// ClusterNotScalingUpV1Beta2Reason surfaces when none of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets are scaling up.
ClusterNotScalingUpV1Beta2Reason = NotScalingUpV1Beta2Reason

// ClusterScalingUpUnknownV1Beta2Reason surfaces when one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets scaling up condition is unknown, and none true.
ClusterScalingUpUnknownV1Beta2Reason = "ScalingUpUnknown"

// ClusterScalingUpInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or computing the ScalingUp condition.
ClusterScalingUpInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
Expand All @@ -263,10 +308,14 @@ const (
// MachinePools and stand-alone MachineSets are scaling down.
ClusterScalingDownV1Beta2Reason = ScalingDownV1Beta2Reason

// ClusterNotScalingDownV1Beta2Reason surfaces when no one of the Cluster's control plane, MachineDeployments,
// ClusterNotScalingDownV1Beta2Reason surfaces when none of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets are scaling down.
ClusterNotScalingDownV1Beta2Reason = NotScalingUpV1Beta2Reason

// ClusterScalingDownUnknownV1Beta2Reason surfaces when one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets scaling down condition is unknown, and none true.
ClusterScalingDownUnknownV1Beta2Reason = "ScalingDownUnknown"

// ClusterScalingDownInternalErrorV1Beta2Reason surfaces unexpected failures when listing machines
// or computing the ScalingDown condition.
ClusterScalingDownInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
Expand Down
34 changes: 29 additions & 5 deletions api/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ const (
// 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"

Expand All @@ -114,6 +111,17 @@ const (
// these conditions must be true as well.
MachineReadyV1Beta2Condition = ReadyV1Beta2Condition

// MachineReadyV1Beta2Reason surfaces when the machine readiness criteria is met.
MachineReadyV1Beta2Reason = ReadyV1Beta2Reason

// MachineNotReadyV1Beta2Reason surfaces when the machine readiness criteria is not met.
// Note: when a machine is not ready, it is also not available.
MachineNotReadyV1Beta2Reason = NotReadyV1Beta2Reason

// MachineReadyUnknownV1Beta2Reason surfaces when at least one machine readiness criteria is unknown
// and no machine readiness criteria is not met.
MachineReadyUnknownV1Beta2Reason = ReadyUnknownV1Beta2Reason

// MachineReadyInternalErrorV1Beta2Reason surfaces unexpected error when computing the Ready condition.
MachineReadyInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
)
Expand Down Expand Up @@ -199,8 +207,24 @@ const (
// 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"
// MachineNodeReadyV1Beta2Reason surfaces when Machine's Node Ready condition is true.
MachineNodeReadyV1Beta2Reason = "NodeReady"

// MachineNodeNotReadyV1Beta2Reason surfaces when Machine's Node Ready condition is false.
MachineNodeNotReadyV1Beta2Reason = "NodeNotReady"

// MachineNodeReadyUnknownV1Beta2Reason surfaces when Machine's Node Ready condition is unknown.
MachineNodeReadyUnknownV1Beta2Reason = "NodeReadyUnknown"

// MachineNodeHealthyV1Beta2Reason surfaces when all the node conditions report healthy state.
MachineNodeHealthyV1Beta2Reason = "NodeHealthy"

// MachineNodeNotHealthyV1Beta2Reason surfaces when at least one node conditions report not healthy state.
MachineNodeNotHealthyV1Beta2Reason = "NodeNotHealthy"

// MachineNodeHealthUnknownV1Beta2Reason surfaces when at least one node conditions report healthy state unknown
// and no node conditions report not healthy state.
MachineNodeHealthUnknownV1Beta2Reason = "NodeHealthyUnknown"

// MachineNodeInternalErrorV1Beta2Reason surfaces unexpected failures when reading a Node object.
MachineNodeInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
Expand Down
20 changes: 20 additions & 0 deletions api/v1beta1/machinedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ const (
// MachineDeploymentMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
MachineDeploymentMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition

// MachineDeploymentMachinesReadyV1Beta2Reason surfaces when all the controlled machine's Ready conditions are true.
MachineDeploymentMachinesReadyV1Beta2Reason = ReadyV1Beta2Reason

// MachineDeploymentMachinesNotReadyV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is false.
MachineDeploymentMachinesNotReadyV1Beta2Reason = NotReadyV1Beta2Reason

// MachineDeploymentMachinesReadyUnknownV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is unknown
// and none of the controlled machine's Ready conditions is false.
MachineDeploymentMachinesReadyUnknownV1Beta2Reason = ReadyUnknownV1Beta2Reason

// MachineDeploymentMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineDeployment.
MachineDeploymentMachinesReadyNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason

Expand All @@ -120,6 +130,16 @@ const (
// MachineDeploymentMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
MachineDeploymentMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition

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

// MachineDeploymentMachinesNotUpToDateV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is false.
MachineDeploymentMachinesNotUpToDateV1Beta2Reason = NotUpToDateV1Beta2Reason

// MachineDeploymentMachinesUpToDateUnknownV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is unknown
// and none of the controlled machine's UpToDate conditions is false.
MachineDeploymentMachinesUpToDateUnknownV1Beta2Reason = UpToDateUnknownV1Beta2Reason

// MachineDeploymentMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineDeployment.
MachineDeploymentMachinesUpToDateNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason

Expand Down
20 changes: 20 additions & 0 deletions api/v1beta1/machineset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ const (
// MachineSetMachinesReadyV1Beta2Condition surfaces detail of issues on the controlled machines, if any.
MachineSetMachinesReadyV1Beta2Condition = MachinesReadyV1Beta2Condition

// MachineSetMachinesReadyV1Beta2Reason surfaces when all the controlled machine's Ready conditions are true.
MachineSetMachinesReadyV1Beta2Reason = ReadyV1Beta2Reason

// MachineSetMachinesNotReadyV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is false.
MachineSetMachinesNotReadyV1Beta2Reason = NotReadyV1Beta2Reason

// MachineSetMachinesReadyUnknownV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is unknown
// and none of the controlled machine's Ready conditions is false.
MachineSetMachinesReadyUnknownV1Beta2Reason = ReadyUnknownV1Beta2Reason

// MachineSetMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineSet.
MachineSetMachinesReadyNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason

Expand All @@ -145,6 +155,16 @@ const (
// MachineSetMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
MachineSetMachinesUpToDateV1Beta2Condition = MachinesUpToDateV1Beta2Condition

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

// MachineSetMachinesNotUpToDateV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is false.
MachineSetMachinesNotUpToDateV1Beta2Reason = NotUpToDateV1Beta2Reason

// MachineSetMachinesUpToDateUnknownV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is unknown
// and none of the controlled machine's UpToDate conditions is false.
MachineSetMachinesUpToDateUnknownV1Beta2Reason = UpToDateUnknownV1Beta2Reason

// MachineSetMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the MachineSet.
MachineSetMachinesUpToDateNoReplicasV1Beta2Reason = NoReplicasV1Beta2Reason

Expand Down
21 changes: 21 additions & 0 deletions api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ const (
// NotAvailableV1Beta2Reason applies to a condition surfacing object not satisfying availability criteria.
NotAvailableV1Beta2Reason = "NotAvailable"

// AvailableUnknownV1Beta2Reason applies to a condition surfacing object availability unknown.
AvailableUnknownV1Beta2Reason = "AvailableUnknown"

// ReadyV1Beta2Reason applies to a condition surfacing object readiness.
ReadyV1Beta2Reason = "Ready"

// NotReadyV1Beta2Reason applies to a condition surfacing object not satisfying readiness criteria.
NotReadyV1Beta2Reason = "NotReady"

// ReadyUnknownV1Beta2Reason applies to a condition surfacing object readiness unknown.
ReadyUnknownV1Beta2Reason = "ReadyUnknown"

// UpToDateV1Beta2Reason applies to a condition surfacing object up-tp-date.
UpToDateV1Beta2Reason = "UpToDate"

// NotUpToDateV1Beta2Reason applies to a condition surfacing object not up-tp-date.
NotUpToDateV1Beta2Reason = "NotUpToDate"

// UpToDateUnknownV1Beta2Reason applies to a condition surfacing object up-tp-date unknown.
UpToDateUnknownV1Beta2Reason = "UpToDateUnknown"

// ScalingUpV1Beta2Reason surfaces when an object is scaling up.
ScalingUpV1Beta2Reason = "ScalingUp"

Expand Down
20 changes: 20 additions & 0 deletions controlplane/kubeadm/api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ const (
// If not using an external etcd also EtcdPodHealthy, EtcdMemberHealthy conditions are included.
KubeadmControlPlaneMachinesReadyV1Beta2Condition = clusterv1.MachinesReadyV1Beta2Condition

// KubeadmControlPlaneMachinesReadyV1Beta2Reason surfaces when all the controlled machine's Ready conditions are true.
KubeadmControlPlaneMachinesReadyV1Beta2Reason = clusterv1.ReadyV1Beta2Reason

// KubeadmControlPlaneMachinesNotReadyV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is false.
KubeadmControlPlaneMachinesNotReadyV1Beta2Reason = clusterv1.NotReadyV1Beta2Reason

// KubeadmControlPlaneMachinesReadyUnknownV1Beta2Reason surfaces when at least one of the controlled machine's Ready conditions is unknown
// and no one of the controlled machine's Ready conditions is false.
KubeadmControlPlaneMachinesReadyUnknownV1Beta2Reason = clusterv1.ReadyUnknownV1Beta2Reason

// KubeadmControlPlaneMachinesReadyNoReplicasV1Beta2Reason surfaces when no machines exist for the KubeadmControlPlane.
KubeadmControlPlaneMachinesReadyNoReplicasV1Beta2Reason = clusterv1.NoReplicasV1Beta2Reason

Expand All @@ -149,6 +159,16 @@ const (
// KubeadmControlPlaneMachinesUpToDateV1Beta2Condition surfaces details of controlled machines not up to date, if any.
KubeadmControlPlaneMachinesUpToDateV1Beta2Condition = clusterv1.MachinesUpToDateV1Beta2Condition

// KubeadmControlPlaneMachinesUpToDateV1Beta2Reason surfaces when all the controlled machine's UpToDate conditions are true.
KubeadmControlPlaneMachinesUpToDateV1Beta2Reason = clusterv1.UpToDateV1Beta2Reason

// KubeadmControlPlaneMachinesNotUpToDateV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is false.
KubeadmControlPlaneMachinesNotUpToDateV1Beta2Reason = clusterv1.NotUpToDateV1Beta2Reason

// KubeadmControlPlaneMachinesUpToDateUnknownV1Beta2Reason surfaces when at least one of the controlled machine's UpToDate conditions is unknown
// and no one of the controlled machine's UpToDate conditions is false.
KubeadmControlPlaneMachinesUpToDateUnknownV1Beta2Reason = clusterv1.UpToDateUnknownV1Beta2Reason

// KubeadmControlPlaneMachinesUpToDateNoReplicasV1Beta2Reason surfaces when no machines exist for the KubeadmControlPlane.
KubeadmControlPlaneMachinesUpToDateNoReplicasV1Beta2Reason = clusterv1.NoReplicasV1Beta2Reason

Expand Down
22 changes: 22 additions & 0 deletions controlplane/kubeadm/internal/controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ func setMachinesReadyCondition(ctx context.Context, kcp *controlplanev1.KubeadmC
readyCondition, err := v1beta2conditions.NewAggregateCondition(
machines.UnsortedList(), clusterv1.MachineReadyV1Beta2Condition,
v1beta2conditions.TargetConditionType(controlplanev1.KubeadmControlPlaneMachinesReadyV1Beta2Condition),
// Using a custom merge strategy to override reasons applied during merge.
v1beta2conditions.CustomMergeStrategy{
MergeStrategy: v1beta2conditions.DefaultMergeStrategy(
v1beta2conditions.ComputeReasonFunc(v1beta2conditions.GetDefaultComputeMergeReasonFunc(
controlplanev1.KubeadmControlPlaneMachinesNotReadyV1Beta2Reason,
controlplanev1.KubeadmControlPlaneMachinesReadyUnknownV1Beta2Reason,
controlplanev1.KubeadmControlPlaneMachinesReadyV1Beta2Reason,
)),
),
},
)
if err != nil {
v1beta2conditions.Set(kcp, metav1.Condition{
Expand Down Expand Up @@ -360,6 +370,16 @@ func setMachinesUpToDateCondition(ctx context.Context, kcp *controlplanev1.Kubea
upToDateCondition, err := v1beta2conditions.NewAggregateCondition(
machines.UnsortedList(), clusterv1.MachineUpToDateV1Beta2Condition,
v1beta2conditions.TargetConditionType(controlplanev1.KubeadmControlPlaneMachinesUpToDateV1Beta2Condition),
// Using a custom merge strategy to override reasons applied during merge.
v1beta2conditions.CustomMergeStrategy{
MergeStrategy: v1beta2conditions.DefaultMergeStrategy(
v1beta2conditions.ComputeReasonFunc(v1beta2conditions.GetDefaultComputeMergeReasonFunc(
controlplanev1.KubeadmControlPlaneMachinesNotUpToDateV1Beta2Reason,
controlplanev1.KubeadmControlPlaneMachinesUpToDateUnknownV1Beta2Reason,
controlplanev1.KubeadmControlPlaneMachinesUpToDateV1Beta2Reason,
)),
),
},
)
if err != nil {
v1beta2conditions.Set(kcp, metav1.Condition{
Expand Down Expand Up @@ -399,6 +419,8 @@ func setRemediatingCondition(ctx context.Context, kcp *controlplanev1.KubeadmCon
remediatingCondition, err := v1beta2conditions.NewAggregateCondition(
machinesToBeRemediated.UnsortedList(), clusterv1.MachineOwnerRemediatedV1Beta2Condition,
v1beta2conditions.TargetConditionType(controlplanev1.KubeadmControlPlaneRemediatingV1Beta2Condition),
// Note: in case of the remediating conditions it is not required to use a CustomMergeStrategy/ComputeReasonFunc
// because we are considering only machinesToBeRemediated (and we can pin the reason when we set the condition).
)
if err != nil {
v1beta2conditions.Set(kcp, metav1.Condition{
Expand Down
Loading

0 comments on commit 7702621

Please sign in to comment.