Skip to content

[WIP] 🌱 Drop usage of v1beta1 conditions #12109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
01ee7eb
Accept usage of clusterv1.ResizedV1Beta1Condition (it is for v1beta1 …
fabriziopandini Apr 17, 2025
faa9cc2
Stop using clusterv1.ClusterClassVariablesReconciledV1Beta1Condition …
fabriziopandini Apr 17, 2025
3a05bf5
Stop using clusterv1.TopologyReconciledV1Beta1Condition in controllers
fabriziopandini Apr 17, 2025
036ccae
Stop using clusterv1.MachineNodeHealthyV1Beta1Condition in controllers
fabriziopandini Apr 17, 2025
75a62c4
Stop using clusterv1.PreTerminateDeleteHookSucceededV1Beta1Condition …
fabriziopandini Apr 18, 2025
7f7744d
Stop using clusterv1.DrainingSucceededV1Beta1Condition in controllers
fabriziopandini Apr 18, 2025
38333f3
Stop using clusterv1.VolumeDetachSucceededV1Beta1Condition in control…
fabriziopandini Apr 18, 2025
5ab00ee
Stop using clusterv1.BootstrapReadyV1Beta1Condition in controllers
fabriziopandini Apr 18, 2025
be38f19
Stop using clusterv1.ControlPlaneInitializedV1Beta1Condition in contr…
fabriziopandini Apr 18, 2025
fa65d1c
Stop using clusterv1.InfrastructureReadyV1Beta1Condition in controllers
fabriziopandini Apr 18, 2025
dae842f
Stop using clusterv1.ReadyV1Beta1Condition in controllers
fabriziopandini Apr 22, 2025
02e9359
Stop using clusterv1.MachineOwnerRemediatedV1Beta1Condition and clust…
fabriziopandini Apr 22, 2025
63fec21
Stop using clusterv1.bootstrapv1.DataSecretAvailableV1Beta1Condition …
fabriziopandini Apr 22, 2025
ef3d0d2
Stop using controlplanev1.KubeadmControlPlaneMachine*HealthyCondition…
fabriziopandini Apr 22, 2025
c9c604d
Stop using controlplanev1.controlplanev1.AvailableV1Beta1Condition in…
fabriziopandini Apr 22, 2025
c639a9a
Stop using controlplanev1..EtcdClusterHealthyV1Beta1Condition and con…
fabriziopandini Apr 22, 2025
15c42b8
Drop unnecessary TODO
fabriziopandini Apr 23, 2025
7c0d63c
Stop using FailureReason and FailureMessage in controllers
fabriziopandini Apr 23, 2025
59af9c5
Small cleanups
fabriziopandini Apr 23, 2025
754995b
Stop using deprecated counters in controllers
fabriziopandini Apr 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v1beta2/cluster_phase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const (

// ClusterPhaseFailed is the Cluster state when the system
// might require user intervention.
//
// Deprecated: This phase is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
ClusterPhaseFailed = ClusterPhase("Failed")

// ClusterPhaseUnknown is returned if the Cluster state cannot be determined.
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta2/machine_phase_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const (

// MachinePhaseFailed is the Machine state when the system
// might require user intervention.
//
// Deprecated: This phase is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
MachinePhaseFailed = MachinePhase("Failed")

// MachinePhaseUnknown is returned if the Machine state cannot be determined.
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta2/machinedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ const (
MachineDeploymentPhaseRunning = MachineDeploymentPhase("Running")

// MachineDeploymentPhaseFailed indicates there was a problem scaling and user intervention might be required.
//
// Deprecated: This phase is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
//
MachineDeploymentPhaseFailed = MachineDeploymentPhase("Failed")

// MachineDeploymentPhaseUnknown indicates the state of the MachineDeployment cannot be determined.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ func (r *KubeadmConfigReconciler) reconcile(ctx context.Context, scope *Scope, c
}

// Note: can't use IsFalse here because we need to handle the absence of the condition as well as false.
// TODO (v1beta2): test for v1beta2 conditions
if !v1beta1conditions.IsTrue(cluster, clusterv1.ControlPlaneInitializedV1Beta1Condition) {
if !conditions.IsTrue(cluster, clusterv1.ClusterControlPlaneInitializedCondition) {
return r.handleClusterNotInitialized(ctx, scope)
}

Expand Down Expand Up @@ -483,8 +482,7 @@ func (r *KubeadmConfigReconciler) handleClusterNotInitialized(ctx context.Contex
// initialize the DataSecretAvailableCondition if missing.
// this is required in order to avoid the condition's LastTransitionTime to flicker in case of errors surfacing
// using the DataSecretGeneratedFailedReason
// TODO (v1beta2): test for v1beta2 conditions
if v1beta1conditions.GetReason(scope.Config, bootstrapv1.DataSecretAvailableV1Beta1Condition) != bootstrapv1.DataSecretGenerationFailedV1Beta1Reason {
if !conditions.Has(scope.Config, bootstrapv1.KubeadmConfigDataSecretAvailableCondition) {
v1beta1conditions.MarkFalse(scope.Config, bootstrapv1.DataSecretAvailableV1Beta1Condition, clusterv1.WaitingForControlPlaneAvailableV1Beta1Reason, clusterv1.ConditionSeverityInfo, "")
conditions.Set(scope.Config, metav1.Condition{
Type: bootstrapv1.KubeadmConfigDataSecretAvailableCondition,
Expand Down

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions cmd/clusterctl/client/cluster/mover.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
v1beta1conditions "sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/cluster-api/util/yaml"
)
Expand Down Expand Up @@ -246,8 +246,7 @@ func (o *objectMover) checkProvisioningCompleted(ctx context.Context, graph *obj
}

// Note: can't use IsFalse here because we need to handle the absence of the condition as well as false.
// TODO (v1beta2): test for v1beta2 conditions
if !v1beta1conditions.IsTrue(clusterObj, clusterv1.ControlPlaneInitializedV1Beta1Condition) {
if !conditions.IsTrue(clusterObj, clusterv1.ClusterControlPlaneInitializedCondition) {
errList = append(errList, errors.Errorf("cannot start the move operation while the control plane for %q %s/%s is not yet initialized", clusterObj.GroupVersionKind(), clusterObj.GetNamespace(), clusterObj.GetName()))
continue
}
Expand Down
41 changes: 10 additions & 31 deletions cmd/clusterctl/client/cluster/mover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
"sigs.k8s.io/cluster-api/cmd/clusterctl/internal/test"
"sigs.k8s.io/cluster-api/cmd/clusterctl/internal/test/providers/infrastructure"
v1beta1conditions "sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1"
)

type moveTestsFields struct {
Expand Down Expand Up @@ -1483,12 +1482,8 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
},
Status: clusterv1.ClusterStatus{
Initialization: &clusterv1.ClusterInitializationStatus{InfrastructureProvisioned: false},
Deprecated: &clusterv1.ClusterDeprecatedStatus{
V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{
Conditions: clusterv1.Conditions{
*v1beta1conditions.TrueCondition(clusterv1.ControlPlaneInitializedV1Beta1Condition),
},
},
Conditions: []metav1.Condition{
{Type: clusterv1.ClusterControlPlaneInitializedCondition, Status: metav1.ConditionTrue},
},
},
},
Expand Down Expand Up @@ -1532,12 +1527,8 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
},
Status: clusterv1.ClusterStatus{
Initialization: &clusterv1.ClusterInitializationStatus{InfrastructureProvisioned: true},
Deprecated: &clusterv1.ClusterDeprecatedStatus{
V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{
Conditions: clusterv1.Conditions{
*v1beta1conditions.FalseCondition(clusterv1.ControlPlaneInitializedV1Beta1Condition, "", clusterv1.ConditionSeverityInfo, ""),
},
},
Conditions: []metav1.Condition{
{Type: clusterv1.ClusterControlPlaneInitializedCondition, Status: metav1.ConditionFalse},
},
},
},
Expand All @@ -1563,12 +1554,8 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
},
Status: clusterv1.ClusterStatus{
Initialization: &clusterv1.ClusterInitializationStatus{InfrastructureProvisioned: true},
Deprecated: &clusterv1.ClusterDeprecatedStatus{
V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{
Conditions: clusterv1.Conditions{
*v1beta1conditions.TrueCondition(clusterv1.ControlPlaneInitializedV1Beta1Condition),
},
},
Conditions: []metav1.Condition{
{Type: clusterv1.ClusterControlPlaneInitializedCondition, Status: metav1.ConditionTrue},
},
},
},
Expand All @@ -1592,12 +1579,8 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
},
Status: clusterv1.ClusterStatus{
Initialization: &clusterv1.ClusterInitializationStatus{InfrastructureProvisioned: true},
Deprecated: &clusterv1.ClusterDeprecatedStatus{
V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{
Conditions: clusterv1.Conditions{
*v1beta1conditions.TrueCondition(clusterv1.ControlPlaneInitializedV1Beta1Condition),
},
},
Conditions: []metav1.Condition{
{Type: clusterv1.ClusterControlPlaneInitializedCondition, Status: metav1.ConditionTrue},
},
},
},
Expand Down Expand Up @@ -1642,12 +1625,8 @@ func Test_objectMover_checkProvisioningCompleted(t *testing.T) {
},
Status: clusterv1.ClusterStatus{
Initialization: &clusterv1.ClusterInitializationStatus{InfrastructureProvisioned: true, ControlPlaneInitialized: true},
Deprecated: &clusterv1.ClusterDeprecatedStatus{
V1Beta1: &clusterv1.ClusterV1Beta1DeprecatedStatus{
Conditions: clusterv1.Conditions{
*v1beta1conditions.TrueCondition(clusterv1.ControlPlaneInitializedV1Beta1Condition),
},
},
Conditions: []metav1.Condition{
{Type: clusterv1.ClusterControlPlaneInitializedCondition, Status: metav1.ConditionTrue},
},
},
},
Expand Down
54 changes: 27 additions & 27 deletions cmd/clusterctl/client/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (ad

// Get a small set of conditions that will be used to determine e.g. when grouping or when an object is just an echo of
// its parent.
var objReady, parentReady *clusterv1.Condition
var objAvailableV1Beta2, objReadyV1Beta2, objUpToDateV1Beta2, parentReadyV1Beta2 *metav1.Condition
var objReadyV1Beta1, parentReadyV1Beta1 *clusterv1.Condition
var objAvailable, objReady, objUpToDate, parentReady *metav1.Condition
switch od.options.V1Beta2 {
case true:
objAvailableV1Beta2 = GetAvailableV1Beta2Condition(obj)
objReadyV1Beta2 = GetReadyV1Beta2Condition(obj)
objUpToDateV1Beta2 = GetMachineUpToDateV1Beta2Condition(obj)
parentReadyV1Beta2 = GetReadyV1Beta2Condition(parent)
default:
objAvailable = GetAvailableCondition(obj)
objReady = GetReadyCondition(obj)
objUpToDate = GetMachineUpToDateCondition(obj)
parentReady = GetReadyCondition(parent)
default:
objReadyV1Beta1 = GetV1Beta1ReadyCondition(obj)
parentReadyV1Beta1 = GetV1Beta1ReadyCondition(parent)
}

// If it is requested to show all the conditions for the object, add
Expand All @@ -121,11 +121,11 @@ func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (ad
if addOpts.NoEcho && !od.options.Echo {
switch od.options.V1Beta2 {
case true:
if (objReadyV1Beta2 != nil && objReadyV1Beta2.Status == metav1.ConditionTrue) || hasSameAvailableReadyUptoDateStatusAndReason(nil, nil, parentReadyV1Beta2, objReadyV1Beta2, nil, nil) {
if (objReady != nil && objReady.Status == metav1.ConditionTrue) || hasSameAvailableReadyUptoDateStatusAndReason(nil, nil, parentReady, objReady, nil, nil) {
return false, false
}
default:
if (objReady != nil && objReady.Status == corev1.ConditionTrue) || hasSameReadyStatusSeverityAndReason(parentReady, objReady) {
if (objReadyV1Beta1 != nil && objReadyV1Beta1.Status == corev1.ConditionTrue) || hasSameReadyStatusSeverityAndReason(parentReadyV1Beta1, objReadyV1Beta1) {
return false, false
}
}
Expand Down Expand Up @@ -154,24 +154,24 @@ func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (ad
for i := range siblings {
s := siblings[i]

var sReady *clusterv1.Condition
var sAvailableV1Beta2, sReadyV1Beta2, sUpToDateV1Beta2 *metav1.Condition
var sReadyV1Beta1 *clusterv1.Condition
var sAvailable, sReady, sUpToDate *metav1.Condition
switch od.options.V1Beta2 {
case true:
// If the object's ready condition has a different Available/ReadyUpToDate condition than the sibling object,
// move on (they should not be grouped).
sAvailableV1Beta2 = GetAvailableV1Beta2Condition(s)
sReadyV1Beta2 = GetReadyV1Beta2Condition(s)
sUpToDateV1Beta2 = GetMachineUpToDateV1Beta2Condition(s)
if !hasSameAvailableReadyUptoDateStatusAndReason(objAvailableV1Beta2, sAvailableV1Beta2, objReadyV1Beta2, sReadyV1Beta2, objUpToDateV1Beta2, sUpToDateV1Beta2) {
sAvailable = GetAvailableCondition(s)
sReady = GetReadyCondition(s)
sUpToDate = GetMachineUpToDateCondition(s)
if !hasSameAvailableReadyUptoDateStatusAndReason(objAvailable, sAvailable, objReady, sReady, objUpToDate, sUpToDate) {
continue
}
default:
sReady = GetReadyCondition(s)
sReadyV1Beta1 = GetV1Beta1ReadyCondition(s)

// If the object's ready condition has a different Status, Severity and Reason than the sibling object,
// move on (they should not be grouped).
if !hasSameReadyStatusSeverityAndReason(objReady, sReady) {
if !hasSameReadyStatusSeverityAndReason(objReadyV1Beta1, sReadyV1Beta1) {
continue
}
}
Expand All @@ -183,9 +183,9 @@ func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (ad
if s.GetObjectKind().GroupVersionKind().Kind == obj.GetObjectKind().GroupVersionKind().Kind+"Group" {
switch od.options.V1Beta2 {
case true:
updateGroupNode(s, sReadyV1Beta2, obj, objAvailableV1Beta2, objReadyV1Beta2, objUpToDateV1Beta2)
updateGroupNode(s, sReady, obj, objAvailable, objReady, objUpToDate)
default:
updateV1Beta1GroupNode(s, sReady, obj, objReady)
updateV1Beta1GroupNode(s, sReadyV1Beta1, obj, objReadyV1Beta1)
}

return true, false
Expand All @@ -201,9 +201,9 @@ func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (ad
var groupNode *NodeObject
switch od.options.V1Beta2 {
case true:
groupNode = createGroupNode(s, sReadyV1Beta2, obj, objAvailableV1Beta2, objReadyV1Beta2, objUpToDateV1Beta2)
groupNode = createGroupNode(s, sReady, obj, objAvailable, objReady, objUpToDate)
default:
groupNode = createV1Beta1GroupNode(s, sReady, obj, objReady)
groupNode = createV1Beta1GroupNode(s, sReadyV1Beta1, obj, objReadyV1Beta1)
}

// By default, grouping objects should be sorted last.
Expand Down Expand Up @@ -332,7 +332,7 @@ func createGroupNode(sibling client.Object, siblingReady *metav1.Condition, obj
if objAvailable != nil {
objAvailable.LastTransitionTime = metav1.Time{}
objAvailable.Message = ""
setAvailableV1Beta2Condition(groupNode, objAvailable)
setAvailableCondition(groupNode, objAvailable)
if objAvailable.Status == metav1.ConditionTrue {
// When creating a group, it is already the sum of obj and its own sibling,
// and they all have same conditions.
Expand All @@ -345,7 +345,7 @@ func createGroupNode(sibling client.Object, siblingReady *metav1.Condition, obj
if objReady != nil {
objReady.LastTransitionTime = minLastTransitionTime(objReady, siblingReady)
objReady.Message = ""
setReadyV1Beta2Condition(groupNode, objReady)
setReadyCondition(groupNode, objReady)
if objReady.Status == metav1.ConditionTrue {
// When creating a group, it is already the sum of obj and its own sibling,
// and they all have same conditions.
Expand All @@ -358,7 +358,7 @@ func createGroupNode(sibling client.Object, siblingReady *metav1.Condition, obj
if objUpToDate != nil {
objUpToDate.LastTransitionTime = metav1.Time{}
objUpToDate.Message = ""
setUpToDateV1Beta2Condition(groupNode, objUpToDate)
setUpToDateCondition(groupNode, objUpToDate)
if objUpToDate.Status == metav1.ConditionTrue {
// When creating a group, it is already the sum of obj and its own sibling,
// and they all have same conditions.
Expand All @@ -370,7 +370,7 @@ func createGroupNode(sibling client.Object, siblingReady *metav1.Condition, obj
}

func readyStatusReasonUID(obj client.Object) string {
ready := GetReadyV1Beta2Condition(obj)
ready := GetReadyCondition(obj)
if ready == nil {
return fmt.Sprintf("zzz_%s", util.RandomString(6))
}
Expand Down Expand Up @@ -417,7 +417,7 @@ func createV1Beta1GroupNode(sibling client.Object, siblingReady *clusterv1.Condi
}

func readyStatusSeverityAndReasonUID(obj client.Object) string {
ready := GetReadyCondition(obj)
ready := GetV1Beta1ReadyCondition(obj)
if ready == nil {
return fmt.Sprintf("zzz_%s", util.RandomString(6))
}
Expand Down Expand Up @@ -459,7 +459,7 @@ func updateGroupNode(groupObj client.Object, groupReady *metav1.Condition, obj c
if groupReady != nil {
groupReady.LastTransitionTime = minLastTransitionTime(objReady, groupReady)
groupReady.Message = ""
setReadyV1Beta2Condition(groupObj, groupReady)
setReadyCondition(groupObj, groupReady)
}

if objReady != nil && objReady.Status == metav1.ConditionTrue {
Expand Down
8 changes: 4 additions & 4 deletions cmd/clusterctl/client/tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func Test_createGroupNode(t *testing.T) {
}

g := NewWithT(t)
got := createGroupNode(sibling, GetReadyV1Beta2Condition(sibling), obj, GetAvailableV1Beta2Condition(obj), GetReadyV1Beta2Condition(obj), GetMachineUpToDateV1Beta2Condition(obj))
got := createGroupNode(sibling, GetReadyCondition(sibling), obj, GetAvailableCondition(obj), GetReadyCondition(obj), GetMachineUpToDateCondition(obj))

// Some values are generated randomly, so pick up them.
want.SetName(got.GetName())
Expand Down Expand Up @@ -653,7 +653,7 @@ func Test_createV1Beta1GroupNode(t *testing.T) {
}

g := NewWithT(t)
got := createV1Beta1GroupNode(sibling, GetReadyCondition(sibling), obj, GetReadyCondition(obj))
got := createV1Beta1GroupNode(sibling, GetV1Beta1ReadyCondition(sibling), obj, GetV1Beta1ReadyCondition(obj))

// Some values are generated randomly, so pick up them.
want.SetName(got.GetName())
Expand Down Expand Up @@ -738,7 +738,7 @@ func Test_updateGroupNode(t *testing.T) {
}

g := NewWithT(t)
updateGroupNode(group, GetReadyV1Beta2Condition(group), obj, GetAvailableV1Beta2Condition(obj), GetReadyV1Beta2Condition(obj), GetMachineUpToDateV1Beta2Condition(obj))
updateGroupNode(group, GetReadyCondition(group), obj, GetAvailableCondition(obj), GetReadyCondition(obj), GetMachineUpToDateCondition(obj))

g.Expect(group).To(BeComparableTo(want))
}
Expand Down Expand Up @@ -827,7 +827,7 @@ func Test_updateV1Beta1GroupNode(t *testing.T) {
}

g := NewWithT(t)
updateV1Beta1GroupNode(group, GetReadyCondition(group), obj, GetReadyCondition(obj))
updateV1Beta1GroupNode(group, GetV1Beta1ReadyCondition(group), obj, GetV1Beta1ReadyCondition(obj))

g.Expect(group).To(BeComparableTo(want))
}
Expand Down
Loading