Skip to content

Commit

Permalink
Do not requeue forever if only cluster is deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsinrahman committed Sep 30, 2019
1 parent bf790fc commit 1bfff7c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions controllers/cluster_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,35 @@ func (r *ClusterReconciler) reconcileKubeconfig(ctx context.Context, cluster *cl
return nil
}

_, err := secret.Get(r.Client, cluster, secret.Kubeconfig)
machines, err := getActiveMachinesInCluster(ctx, r.Client, cluster.Namespace, cluster.Name)
if err != nil {
return errors.Wrap(err, "failed to get active machines in cluster")
}

foundControlPlane := false
for _, m := range machines {
if util.IsControlPlaneMachine(m) {
foundControlPlane = true
break
}
}

if !foundControlPlane {
// TODO: fix this after #1456 is merged
r.Log.Info("no controlPlane machine found, skip reconciling kuberconfig secret")
return nil
}

_, err = secret.Get(r.Client, cluster, secret.Kubeconfig)
switch {
case apierrors.IsNotFound(err):
return kubeconfig.CreateSecret(ctx, r.Client, cluster)
err = kubeconfig.CreateSecret(ctx, r.Client, cluster)
if apierrors.IsNotFound(err) {
return errors.Wrapf(&capierrors.RequeueAfterError{RequeueAfter: 30 * time.Second},
"could not find secret %q for Cluster %q in namespace %q, requeuing",
secret.ClusterCA, cluster.Name, cluster.Namespace)
}
return err
case err != nil:
return errors.Wrapf(err, "failed to retrieve Kubeconfig Secret for Cluster %q in namespace %q", cluster.Name, cluster.Namespace)
}
Expand Down

0 comments on commit 1bfff7c

Please sign in to comment.