From 41ee33ac90aad7e4f3b57398db9e75a2f7cab434 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Thu, 18 Jul 2024 16:41:41 +0200 Subject: [PATCH] Partially revert changes for ":bug: Cluster should be provisoned when cpRef and endpoint is set" --- api/v1beta1/cluster_phase_types.go | 9 +++++---- .../controllers/cluster/cluster_controller_phases.go | 4 +--- .../cluster/cluster_controller_phases_test.go | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/api/v1beta1/cluster_phase_types.go b/api/v1beta1/cluster_phase_types.go index afcd872456d6..68777cf75792 100644 --- a/api/v1beta1/cluster_phase_types.go +++ b/api/v1beta1/cluster_phase_types.go @@ -33,12 +33,13 @@ const ( // Cluster API Cluster controller after being created. ClusterPhasePending = ClusterPhase("Pending") - // ClusterPhaseProvisioning is the state when the Cluster has a provider infrastructure - // object associated and can start provisioning. + // ClusterPhaseProvisioning is the state when the Cluster has a infrastructure + // object or a control plane object that can start provisioning the control plane endpoint. ClusterPhaseProvisioning = ClusterPhase("Provisioning") - // ClusterPhaseProvisioned is the state when its - // infrastructure has been created and configured. + // ClusterPhaseProvisioned is the state when its control plane endpoint has been created and configured + // and the infrastructure object is ready (if defined). + // Note: When a cluster reaches this phase parts of the control plane or worker machines might be still provisioning. ClusterPhaseProvisioned = ClusterPhase("Provisioned") // ClusterPhaseDeleting is the Cluster state when a delete diff --git a/internal/controllers/cluster/cluster_controller_phases.go b/internal/controllers/cluster/cluster_controller_phases.go index 50ce66720a38..cdc8e62fb09d 100644 --- a/internal/controllers/cluster/cluster_controller_phases.go +++ b/internal/controllers/cluster/cluster_controller_phases.go @@ -52,9 +52,7 @@ func (r *Reconciler) reconcilePhase(_ context.Context, cluster *clusterv1.Cluste cluster.Status.SetTypedPhase(clusterv1.ClusterPhaseProvisioning) } - if (cluster.Spec.InfrastructureRef == nil || cluster.Status.InfrastructureReady) && - (cluster.Spec.ControlPlaneRef == nil || cluster.Status.ControlPlaneReady) && - cluster.Spec.ControlPlaneEndpoint.IsValid() { + if cluster.Status.InfrastructureReady && cluster.Spec.ControlPlaneEndpoint.IsValid() { cluster.Status.SetTypedPhase(clusterv1.ClusterPhaseProvisioned) } diff --git a/internal/controllers/cluster/cluster_controller_phases_test.go b/internal/controllers/cluster/cluster_controller_phases_test.go index e1b7bc07a044..f7242c71da28 100644 --- a/internal/controllers/cluster/cluster_controller_phases_test.go +++ b/internal/controllers/cluster/cluster_controller_phases_test.go @@ -573,14 +573,14 @@ func TestClusterReconciler_reconcilePhase(t *testing.T) { Name: "test-cluster", }, Spec: clusterv1.ClusterSpec{ - ControlPlaneEndpoint: clusterv1.APIEndpoint{ + ControlPlaneEndpoint: clusterv1.APIEndpoint{ // This is set by the control plane ref controller when the cluster endpoint is available. Host: "1.2.3.4", Port: 8443, }, ControlPlaneRef: &corev1.ObjectReference{}, }, Status: clusterv1.ClusterStatus{ - ControlPlaneReady: true, + InfrastructureReady: true, // Note, this is automatically set when there is no cluster infrastructure (no-op). }, },