Skip to content

Commit f8e0afd

Browse files
Merge pull request #335 from elmiko/remove-cloud-controller-owner-condition
OCPCLOUD-2515: remove CloudControllerOwner condition logic
2 parents 7c8ece7 + 65c07a6 commit f8e0afd

File tree

4 files changed

+59
-485
lines changed

4 files changed

+59
-485
lines changed

docs/user/troubleshooting.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Pay attention to the status of auxiliary controllers: Cloud Config Sync and Trus
1616

1717
## Migration from KCM to CCM got stuck
1818

19+
**Please note that KCM to CCM migration is only relevent for OpenShift version 4.14 and earlier.**
20+
1921
To troubleshoot the issue we need to understand how the migration works. When `ExternalCloudProvider` feature gate is set, Kube Controller Manager Operator updates all Kube Controller Manager (KCM) pods by setting `--cloud-provider external` there, and starts observing the pods statuses. If all of them started successfully, the operator sets condition `CloudControllerOwner: False` to the `kubecontrollermanager` resource. You can check it with `oc get kubecontrollermanager cluster -o yaml`.
2022

2123
In parallel with that CCCMO also monitors the `kubecontrollermanager` resource. It doesn't provision any Cloud Controller Manager related resources until the condition is set to False there.

pkg/controllers/clusteroperator_controller.go

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ func (r *CloudOperatorReconciler) Reconcile(ctx context.Context, _ ctrl.Request)
133133
return ctrl.Result{}, err
134134
}
135135

136-
if err := r.setCloudControllerOwnerCondition(ctx); err != nil {
137-
klog.Errorf("Unable to sync cluster operator status: %s", err)
136+
if err := r.clearCloudControllerOwnerCondition(ctx); err != nil {
137+
klog.Errorf("Unable to clear CloudControllerOwner condition: %s", err)
138138
return ctrl.Result{}, err
139139
}
140140

@@ -264,56 +264,9 @@ func (r *CloudOperatorReconciler) provisioningAllowed(ctx context.Context, infra
264264
return false, nil
265265
}
266266

267-
ownedByKCM, err := r.isCloudControllersOwnedByKCM(ctx, conditionOverrides)
268-
if err != nil {
269-
return false, err
270-
}
271-
if ownedByKCM {
272-
// KCM resource found and it owns Cloud provider
273-
klog.Infof("KubeControllerManager still owns Cloud Controllers. Skipping...")
274-
275-
if err := r.setStatusAvailable(ctx, conditionOverrides); err != nil {
276-
klog.Errorf("Unable to sync cluster operator status: %s", err)
277-
return false, err
278-
}
279-
280-
return false, nil
281-
}
282-
283267
return true, nil
284268
}
285269

286-
func (r *CloudOperatorReconciler) isCloudControllersOwnedByKCM(ctx context.Context, conditionOverrides []configv1.ClusterOperatorStatusCondition) (bool, error) {
287-
kcm := &operatorv1.KubeControllerManager{}
288-
err := r.Get(ctx, client.ObjectKey{Name: kcmResourceName}, kcm)
289-
if err != nil {
290-
klog.Errorf("Unable to retrive KubeControllerManager object: %v", err)
291-
292-
if err := r.setStatusDegraded(ctx, err, conditionOverrides); err != nil {
293-
klog.Errorf("Error syncing ClusterOperatorStatus: %v", err)
294-
return false, fmt.Errorf("error syncing ClusterOperatorStatus: %v", err)
295-
}
296-
return false, err
297-
}
298-
299-
if len(kcm.Status.Conditions) == 0 {
300-
// If KCM Conditions object doesn't exist, we assume that we are in bootstrapping process and
301-
// the controllers are not owned by KCM.
302-
klog.Info("KubeControllerManager status not found, cluster is bootstrapping with external cloud providers")
303-
return false, nil
304-
}
305-
306-
// If there is no condition, we assume that KCM owns the Cloud Controllers
307-
ownedByKCM := true
308-
for _, cond := range kcm.Status.Conditions {
309-
if cond.Type == cloudControllerOwnershipCondition {
310-
ownedByKCM = cond.Status == operatorv1.ConditionTrue
311-
}
312-
}
313-
314-
return ownedByKCM, nil
315-
}
316-
317270
func (r *CloudOperatorReconciler) isCloudControllersOwnedByCCM(ctx context.Context, conditionOverrides []configv1.ClusterOperatorStatusCondition) (bool, error) {
318271
co, err := r.getOrCreateClusterOperator(ctx)
319272
if err != nil {

0 commit comments

Comments
 (0)