Skip to content

Commit d048d87

Browse files
authored
Merge pull request #878 from Shaad7/fix-clusterctl-move
Fix clusterctl move command by updating ControlPlane initialized cond…
2 parents 33c0f10 + ac1190f commit d048d87

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

cloud/services/container/clusters/reconcile.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
4343

4444
cluster, err := s.describeCluster(ctx, &log)
4545
if err != nil {
46+
s.scope.GCPManagedControlPlane.Status.Initialized = false
4647
s.scope.GCPManagedControlPlane.Status.Ready = false
4748
conditions.MarkFalse(s.scope.ConditionSetter(), clusterv1.ReadyCondition, infrav1exp.GKEControlPlaneReconciliationFailedReason, clusterv1.ConditionSeverityError, err.Error())
4849
return ctrl.Result{}, err
4950
}
5051
if cluster == nil {
5152
log.Info("Cluster not found, creating")
53+
s.scope.GCPManagedControlPlane.Status.Initialized = false
5254
s.scope.GCPManagedControlPlane.Status.Ready = false
5355

5456
nodePools, _, err := s.scope.GetAllNodePools(ctx)
@@ -99,18 +101,21 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
99101
conditions.MarkFalse(s.scope.ConditionSetter(), clusterv1.ReadyCondition, infrav1exp.GKEControlPlaneCreatingReason, clusterv1.ConditionSeverityInfo, "")
100102
conditions.MarkFalse(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneReadyCondition, infrav1exp.GKEControlPlaneCreatingReason, clusterv1.ConditionSeverityInfo, "")
101103
conditions.MarkTrue(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneCreatingCondition)
104+
s.scope.GCPManagedControlPlane.Status.Initialized = false
102105
s.scope.GCPManagedControlPlane.Status.Ready = false
103106
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
104107
case containerpb.Cluster_RECONCILING:
105108
log.Info("Cluster reconciling in progress")
106109
conditions.MarkTrue(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneUpdatingCondition)
110+
s.scope.GCPManagedControlPlane.Status.Initialized = true
107111
s.scope.GCPManagedControlPlane.Status.Ready = true
108112
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
109113
case containerpb.Cluster_STOPPING:
110114
log.Info("Cluster stopping in progress")
111115
conditions.MarkFalse(s.scope.ConditionSetter(), clusterv1.ReadyCondition, infrav1exp.GKEControlPlaneDeletingReason, clusterv1.ConditionSeverityInfo, "")
112116
conditions.MarkFalse(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneReadyCondition, infrav1exp.GKEControlPlaneDeletingReason, clusterv1.ConditionSeverityInfo, "")
113117
conditions.MarkTrue(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneDeletingCondition)
118+
s.scope.GCPManagedControlPlane.Status.Initialized = false
114119
s.scope.GCPManagedControlPlane.Status.Ready = false
115120
return ctrl.Result{RequeueAfter: reconciler.DefaultRetryTime}, nil
116121
case containerpb.Cluster_ERROR, containerpb.Cluster_DEGRADED:
@@ -121,6 +126,7 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
121126
log.Error(errors.New("Cluster in error/degraded state"), msg, "name", s.scope.ClusterName())
122127
conditions.MarkFalse(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneReadyCondition, infrav1exp.GKEControlPlaneErrorReason, clusterv1.ConditionSeverityError, "")
123128
s.scope.GCPManagedControlPlane.Status.Ready = false
129+
s.scope.GCPManagedControlPlane.Status.Initialized = false
124130
return ctrl.Result{}, nil
125131
case containerpb.Cluster_RUNNING:
126132
log.Info("Cluster running")
@@ -139,6 +145,7 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
139145
}
140146
log.Info("Cluster updating in progress")
141147
conditions.MarkTrue(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneUpdatingCondition)
148+
s.scope.GCPManagedControlPlane.Status.Initialized = true
142149
s.scope.GCPManagedControlPlane.Status.Ready = true
143150
return ctrl.Result{}, nil
144151
}
@@ -161,6 +168,7 @@ func (s *Service) Reconcile(ctx context.Context) (ctrl.Result, error) {
161168
conditions.MarkTrue(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneReadyCondition)
162169
conditions.MarkFalse(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneCreatingCondition, infrav1exp.GKEControlPlaneCreatedReason, clusterv1.ConditionSeverityInfo, "")
163170
s.scope.GCPManagedControlPlane.Status.Ready = true
171+
s.scope.GCPManagedControlPlane.Status.Initialized = true
164172

165173
log.Info("Cluster reconciled")
166174

@@ -203,6 +211,7 @@ func (s *Service) Delete(ctx context.Context) (ctrl.Result, error) {
203211
return ctrl.Result{}, err
204212
}
205213
log.Info("Cluster deleting in progress")
214+
s.scope.GCPManagedControlPlane.Status.Initialized = false
206215
s.scope.GCPManagedControlPlane.Status.Ready = false
207216
conditions.MarkFalse(s.scope.ConditionSetter(), clusterv1.ReadyCondition, infrav1exp.GKEControlPlaneDeletingReason, clusterv1.ConditionSeverityInfo, "")
208217
conditions.MarkFalse(s.scope.ConditionSetter(), infrav1exp.GKEControlPlaneReadyCondition, infrav1exp.GKEControlPlaneDeletingReason, clusterv1.ConditionSeverityInfo, "")

config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmanagedcontrolplanes.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ spec:
162162
description: CurrentVersion shows the current version of the GKE control
163163
plane.
164164
type: string
165+
initialized:
166+
description: Initialized is true when the control plane is available
167+
for initial contact. This may occur before the control plane is
168+
fully ready.
169+
type: boolean
165170
ready:
166171
default: false
167172
description: Ready denotes that the GCPManagedControlPlane API Server

exp/api/v1beta1/gcpmanagedcontrolplane_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ type GCPManagedControlPlaneStatus struct {
6161
// +kubebuilder:default=false
6262
Ready bool `json:"ready"`
6363

64+
// Initialized is true when the control plane is available for initial contact.
65+
// This may occur before the control plane is fully ready.
66+
// +optional
67+
Initialized bool `json:"initialized,omitempty"`
68+
6469
// Conditions specifies the conditions for the managed control plane
6570
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
6671

0 commit comments

Comments
 (0)