Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#11422 from sbueringer/pr-condition…
Browse files Browse the repository at this point in the history
…-improvements

🌱 Various improvements of v1beta2 conditions
  • Loading branch information
k8s-ci-robot authored Nov 14, 2024
2 parents 7dd613c + d7471a5 commit f496ad9
Show file tree
Hide file tree
Showing 31 changed files with 364 additions and 266 deletions.
14 changes: 7 additions & 7 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ const (
ClusterTopologyReconciledV1Beta2Condition = "TopologyReconciled"

// ClusterTopologyReconcileSucceededV1Beta2Reason documents the reconciliation of a Cluster topology succeeded.
ClusterTopologyReconcileSucceededV1Beta2Reason = "TopologyReconcileSucceeded"
ClusterTopologyReconcileSucceededV1Beta2Reason = "ReconcileSucceeded"

// ClusterTopologyReconciledFailedV1Beta2Reason documents the reconciliation of a Cluster topology
// failing due to an error.
ClusterTopologyReconciledFailedV1Beta2Reason = "TopologyReconcileFailed"
ClusterTopologyReconciledFailedV1Beta2Reason = "ReconcileFailed"

// ClusterTopologyReconciledControlPlaneUpgradePendingV1Beta2Reason documents reconciliation of a Cluster topology
// not yet completed because Control Plane is not yet updated to match the desired topology spec.
Expand Down Expand Up @@ -113,9 +113,9 @@ const (
// with the ClusterClass surfaced in the ClusterClass status or controller logs.
ClusterTopologyReconciledClusterClassNotReconciledV1Beta2Reason = "ClusterClassNotReconciled"

// ClusterTopologyReconciledDeletionTimestampSetV1Beta2Reason surfaces when the Cluster is deleting because the
// ClusterTopologyReconciledDeletingV1Beta2Reason surfaces when the Cluster is deleting because the
// DeletionTimestamp is set.
ClusterTopologyReconciledDeletionTimestampSetV1Beta2Reason = DeletionTimestampSetV1Beta2Reason
ClusterTopologyReconciledDeletingV1Beta2Reason = DeletingV1Beta2Reason

// ClusterTopologyReconcilePausedV1Beta2Reason surfaces when the Cluster is paused.
ClusterTopologyReconcilePausedV1Beta2Reason = PausedV1Beta2Reason
Expand Down Expand Up @@ -316,7 +316,7 @@ const (

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

// ClusterScalingDownUnknownV1Beta2Reason surfaces when one of the Cluster's control plane, MachineDeployments,
// MachinePools and stand-alone MachineSets scaling down condition is unknown, and none true.
Expand Down Expand Up @@ -349,9 +349,9 @@ const (
// ClusterDeletingV1Beta2Condition surfaces details about ongoing deletion of the cluster.
ClusterDeletingV1Beta2Condition = DeletingV1Beta2Condition

// ClusterDeletingDeletionTimestampNotSetV1Beta2Reason surfaces when the Cluster is not deleting because the
// ClusterNotDeletingV1Beta2Reason surfaces when the Cluster is not deleting because the
// DeletionTimestamp is not set.
ClusterDeletingDeletionTimestampNotSetV1Beta2Reason = DeletionTimestampNotSetV1Beta2Reason
ClusterNotDeletingV1Beta2Reason = NotDeletingV1Beta2Reason

// ClusterDeletingWaitingForBeforeDeleteHookV1Beta2Reason surfaces when the Cluster deletion
// waits for the ClusterDelete hooks to allow deletion to complete.
Expand Down
17 changes: 6 additions & 11 deletions api/v1beta1/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ const (

// 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
MachineNodeDoesNotExistV1Beta2Reason = "NodeDoesNotExist"

// 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
MachineNodeDeletedV1Beta2Reason = "NodeDeleted"

// MachineNodeInspectionFailedV1Beta2Reason documents a failure when inspecting the status of a Node.
MachineNodeInspectionFailedV1Beta2Reason = InspectionFailedV1Beta2Reason
Expand Down Expand Up @@ -317,18 +317,13 @@ const (
// MachineDeletingV1Beta2Condition surfaces details about progress in the machine deletion workflow.
MachineDeletingV1Beta2Condition = DeletingV1Beta2Condition

// MachineDeletingV1Beta2Reason surfaces when the Machine is deleting.
// This reason is only used for the MachineDeletingV1Beta2Condition when calculating the
// Ready condition when the deletionTimestamp on a Machine is set.
MachineDeletingV1Beta2Reason = "Deleting"

// MachineDeletingDeletionTimestampNotSetV1Beta2Reason surfaces when the Machine is not deleting because the
// MachineNotDeletingV1Beta2Reason surfaces when the Machine is not deleting because the
// DeletionTimestamp is not set.
MachineDeletingDeletionTimestampNotSetV1Beta2Reason = DeletionTimestampNotSetV1Beta2Reason
MachineNotDeletingV1Beta2Reason = NotDeletingV1Beta2Reason

// MachineDeletingDeletionTimestampSetV1Beta2Reason surfaces when the Machine is deleting because the
// MachineDeletingV1Beta2Reason surfaces when the Machine is deleting because the
// DeletionTimestamp is set. This reason is used if none of the more specific reasons apply.
MachineDeletingDeletionTimestampSetV1Beta2Reason = DeletionTimestampSetV1Beta2Reason
MachineDeletingV1Beta2Reason = DeletingV1Beta2Reason

// MachineDeletingInternalErrorV1Beta2Reason surfaces unexpected failures when deleting a Machine.
MachineDeletingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/machinedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ const (
// MachineDeploymentDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
MachineDeploymentDeletingV1Beta2Condition = DeletingV1Beta2Condition

// MachineDeploymentDeletingDeletionTimestampNotSetV1Beta2Reason surfaces when the MachineDeployment is not deleting because the
// MachineDeploymentNotDeletingV1Beta2Reason surfaces when the MachineDeployment is not deleting because the
// DeletionTimestamp is not set.
MachineDeploymentDeletingDeletionTimestampNotSetV1Beta2Reason = DeletionTimestampNotSetV1Beta2Reason
MachineDeploymentNotDeletingV1Beta2Reason = NotDeletingV1Beta2Reason

// MachineDeploymentDeletingDeletionTimestampSetV1Beta2Reason surfaces when the MachineDeployment is deleting because the
// MachineDeploymentDeletingV1Beta2Reason surfaces when the MachineDeployment is deleting because the
// DeletionTimestamp is set.
MachineDeploymentDeletingDeletionTimestampSetV1Beta2Reason = DeletionTimestampSetV1Beta2Reason
MachineDeploymentDeletingV1Beta2Reason = DeletingV1Beta2Reason

// MachineDeploymentDeletingInternalErrorV1Beta2Reason surfaces unexpected failures when deleting a MachineDeployment.
MachineDeploymentDeletingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
Expand Down
12 changes: 6 additions & 6 deletions api/v1beta1/machineset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,25 @@ const (
// MachineSetMachineRemediationDeferredV1Beta2Reason surfaces when remediation of a MachineSet machine must be deferred.
MachineSetMachineRemediationDeferredV1Beta2Reason = "RemediationDeferred"

// MachineSetMachineRemediationMachineDeletedV1Beta2Reason surfaces when remediation of a MachineSet machine
// MachineSetMachineRemediationMachineDeletingV1Beta2Reason surfaces when remediation of a MachineSet machine
// has been completed by deleting the unhealthy machine.
// Note: After an unhealthy machine is deleted, a new one is created by the MachineSet as part of the
// regular reconcile loop that ensures the correct number of replicas exist.
MachineSetMachineRemediationMachineDeletedV1Beta2Reason = "MachineDeleted"
MachineSetMachineRemediationMachineDeletingV1Beta2Reason = "MachineDeleting"
)

// MachineSet's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// MachineSetDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
MachineSetDeletingV1Beta2Condition = DeletingV1Beta2Condition

// MachineSetDeletingDeletionTimestampNotSetV1Beta2Reason surfaces when the MachineSet is not deleting because the
// MachineSetNotDeletingV1Beta2Reason surfaces when the MachineSet is not deleting because the
// DeletionTimestamp is not set.
MachineSetDeletingDeletionTimestampNotSetV1Beta2Reason = DeletionTimestampNotSetV1Beta2Reason
MachineSetNotDeletingV1Beta2Reason = NotDeletingV1Beta2Reason

// MachineSetDeletingDeletionTimestampSetV1Beta2Reason surfaces when the MachineSet is deleting because the
// MachineSetDeletingV1Beta2Reason surfaces when the MachineSet is deleting because the
// DeletionTimestamp is set.
MachineSetDeletingDeletionTimestampSetV1Beta2Reason = DeletionTimestampSetV1Beta2Reason
MachineSetDeletingV1Beta2Reason = DeletingV1Beta2Reason

// MachineSetDeletingInternalErrorV1Beta2Reason surfaces unexpected failures when deleting a MachineSet.
MachineSetDeletingInternalErrorV1Beta2Reason = InternalErrorV1Beta2Reason
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ const (
// ConnectionDownV1Beta2Reason surfaces that the connection to the workload cluster is down.
ConnectionDownV1Beta2Reason = "ConnectionDown"

// DeletionTimestampNotSetV1Beta2Reason surfaces when an object is not deleting because the
// NotDeletingV1Beta2Reason surfaces when an object is not deleting because the
// DeletionTimestamp is not set.
DeletionTimestampNotSetV1Beta2Reason = "DeletionTimestampNotSet"
NotDeletingV1Beta2Reason = "NotDeleting"

// DeletionTimestampSetV1Beta2Reason surfaces when an object is deleting because the
// DeletingV1Beta2Reason surfaces when an object is deleting because the
// DeletionTimestamp is set. This reason is used if none of the more specific reasons apply.
DeletionTimestampSetV1Beta2Reason = "DeletionTimestampSet"
DeletingV1Beta2Reason = "Deleting"

// DeletionCompletedV1Beta2Reason surfaces when the deletion process has been completed.
// This reason is set right after the corresponding finalizer is removed.
Expand Down
8 changes: 4 additions & 4 deletions controlplane/kubeadm/api/v1beta1/v1beta2_condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,23 @@ const (
// KubeadmControlPlaneMachineRemediationDeferredV1Beta2Reason surfaces when remediation of a control plane machine must be deferred.
KubeadmControlPlaneMachineRemediationDeferredV1Beta2Reason = "RemediationDeferred"

// KubeadmControlPlaneMachineRemediationMachineDeletedV1Beta2Reason surfaces when remediation of a control plane machine
// KubeadmControlPlaneMachineRemediationMachineDeletingV1Beta2Reason surfaces when remediation of a control plane machine
// has been completed by deleting the unhealthy machine.
// Note: After an unhealthy machine is deleted, a new one is created by the KubeadmControlPlaneMachine as part of the
// regular reconcile loop that ensures the correct number of replicas exist; KubeadmControlPlane machine waits for
// the new machine to exists before removing the controlplane.cluster.x-k8s.io/remediation-in-progress annotation.
// This is part of a series of safeguards to ensure that operation are performed sequentially on control plane machines.
KubeadmControlPlaneMachineRemediationMachineDeletedV1Beta2Reason = "MachineDeleted"
KubeadmControlPlaneMachineRemediationMachineDeletingV1Beta2Reason = "MachineDeleting"
)

// KubeadmControlPlane's Deleting condition and corresponding reasons that will be used in v1Beta2 API version.
const (
// KubeadmControlPlaneDeletingV1Beta2Condition surfaces details about ongoing deletion of the controlled machines.
KubeadmControlPlaneDeletingV1Beta2Condition = clusterv1.DeletingV1Beta2Condition

// KubeadmControlPlaneDeletingDeletionTimestampNotSetV1Beta2Reason surfaces when the KCP is not deleting because the
// KubeadmControlPlaneNotDeletingV1Beta2Reason surfaces when the KCP is not deleting because the
// DeletionTimestamp is not set.
KubeadmControlPlaneDeletingDeletionTimestampNotSetV1Beta2Reason = clusterv1.DeletionTimestampNotSetV1Beta2Reason
KubeadmControlPlaneNotDeletingV1Beta2Reason = clusterv1.NotDeletingV1Beta2Reason

// KubeadmControlPlaneDeletingWaitingForWorkersDeletionV1Beta2Reason surfaces when the KCP deletion
// waits for the workers to be deleted.
Expand Down
2 changes: 1 addition & 1 deletion controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func (r *KubeadmControlPlaneReconciler) reconcileDelete(ctx context.Context, con
// If no control plane machines remain, remove the finalizer
if len(controlPlane.Machines) == 0 {
controlPlane.DeletingReason = controlplanev1.KubeadmControlPlaneDeletingDeletionCompletedV1Beta2Reason
controlPlane.DeletingMessage = ""
controlPlane.DeletingMessage = "Deletion completed"

controllerutil.RemoveFinalizer(controlPlane.KCP, controlplanev1.KubeadmControlPlaneFinalizer)
return ctrl.Result{}, nil
Expand Down
44 changes: 22 additions & 22 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2012,49 +2012,49 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * EtcdMemberHealthy: Node does not exist",
" * EtcdMemberHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * APIServerPodHealthy: Node does not exist\n" +
" * ControllerManagerPodHealthy: Node does not exist\n" +
" * SchedulerPodHealthy: Node does not exist\n" +
" * EtcdPodHealthy: Node does not exist",
" * APIServerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
" * ControllerManagerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
" * SchedulerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
" * EtcdPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
},
},
expectMachineConditions: []metav1.Condition{
{
Type: controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineControllerManagerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineSchedulerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: clusterv1.MachineUpToDateV1Beta2Condition,
Expand Down Expand Up @@ -2092,49 +2092,49 @@ func TestKubeadmControlPlaneReconciler_reconcileControlPlaneAndMachinesCondition
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneEtcdClusterHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * EtcdMemberHealthy: Node does not exist",
" * EtcdMemberHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneControlPlaneComponentsHealthUnknownV1Beta2Reason,
Message: "* Machine machine1-test:\n" +
" * APIServerPodHealthy: Node does not exist\n" +
" * ControllerManagerPodHealthy: Node does not exist\n" +
" * SchedulerPodHealthy: Node does not exist\n" +
" * EtcdPodHealthy: Node does not exist",
" * APIServerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
" * ControllerManagerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
" * SchedulerPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID\n" +
" * EtcdPodHealthy: Waiting for GenericInfrastructureMachine to report spec.providerID",
},
},
expectMachineConditions: []metav1.Condition{
{
Type: controlplanev1.KubeadmControlPlaneMachineAPIServerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineControllerManagerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineSchedulerPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdPodHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachinePodInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: controlplanev1.KubeadmControlPlaneMachineEtcdMemberHealthyV1Beta2Condition,
Status: metav1.ConditionUnknown,
Reason: controlplanev1.KubeadmControlPlaneMachineEtcdMemberInspectionFailedV1Beta2Reason,
Message: "Node does not exist",
Message: "Waiting for GenericInfrastructureMachine to report spec.providerID",
},
{
Type: clusterv1.MachineUpToDateV1Beta2Condition,
Expand Down Expand Up @@ -3301,7 +3301,7 @@ func TestKubeadmControlPlaneReconciler_reconcileDelete(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())
g.Expect(kcp.Finalizers).To(BeEmpty())
g.Expect(controlPlane.DeletingReason).To(Equal(controlplanev1.KubeadmControlPlaneDeletingDeletionCompletedV1Beta2Reason))
g.Expect(controlPlane.DeletingMessage).To(BeEmpty())
g.Expect(controlPlane.DeletingMessage).To(Equal("Deletion completed"))
})

t.Run("does not remove any control plane Machines if other Machines exist", func(t *testing.T) {
Expand Down Expand Up @@ -3453,7 +3453,7 @@ func TestKubeadmControlPlaneReconciler_reconcileDelete(t *testing.T) {
g.Expect(err).ToNot(HaveOccurred())
g.Expect(kcp.Finalizers).To(BeEmpty())
g.Expect(controlPlane.DeletingReason).To(Equal(controlplanev1.KubeadmControlPlaneDeletingDeletionCompletedV1Beta2Reason))
g.Expect(controlPlane.DeletingMessage).To(BeEmpty())
g.Expect(controlPlane.DeletingMessage).To(Equal("Deletion completed"))
})
}

Expand Down
Loading

0 comments on commit f496ad9

Please sign in to comment.