Skip to content

Commit f0bb8a2

Browse files
committed
fix: owner cluster handling
1 parent 34989ac commit f0bb8a2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,14 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
154154
// Fetch the Cluster.
155155
cluster, err := util.GetOwnerCluster(ctx, r.Client, kcp.ObjectMeta)
156156
if err != nil {
157-
if apierrors.IsNotFound(err) {
158-
log.Info("Cluster Controller has not yet set OwnerRef")
159-
return ctrl.Result{}, nil
157+
if !apierrors.IsNotFound(err) {
158+
log.Error(err, "Failed to retrieve owner Cluster from the API Server")
159+
return ctrl.Result{}, err
160160
}
161-
log.Error(err, "Failed to retrieve owner Cluster from the API Server")
162-
return ctrl.Result{}, err
161+
}
162+
if apierrors.IsNotFound(err) || cluster == nil {
163+
log.Info("Cluster Controller has not yet set OwnerRef")
164+
return ctrl.Result{}, nil
163165
}
164166

165167
log = log.WithValues("Cluster", klog.KObj(cluster))

0 commit comments

Comments
 (0)