Skip to content

Commit

Permalink
fix reconcile owned clusters only
Browse files Browse the repository at this point in the history
  • Loading branch information
sadysnaat committed Jan 4, 2022
1 parent a877e9d commit fc16bbd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion controllers/vspheredeploymentzone_controller.go
Expand Up @@ -102,6 +102,21 @@ func (r vsphereDeploymentZoneReconciler) Reconcile(ctx goctx.Context, request re
}
return reconcile.Result{}, err
}

vsphereClusterList := &infrav1.VSphereClusterList{}
if err := r.Client.List(ctx, vsphereClusterList, client.InNamespace(r.Namespace)); err != nil {
return reconcile.Result{}, err
}

if len(vsphereClusterList.Items) != 1 {
logr.V(4).Info("found more than one cluster in namespace", "namespace", r.Namespace)
return reconcile.Result{}, nil
}

if !shouldIncludeZone(*vsphereDeploymentZone, &vsphereClusterList.Items[0]) {
logr.V(4).Info("deploymentzone not belonging to this cluster skip reconcile", "name", vsphereDeploymentZone.Name)
return reconcile.Result{}, nil
}

failureDomain := &infrav1.VSphereFailureDomain{}
failureDomainKey := client.ObjectKey{Name: vsphereDeploymentZone.Spec.FailureDomain}
Expand Down Expand Up @@ -212,7 +227,7 @@ func (r vsphereDeploymentZoneReconciler) getVCenterSession(ctx *context.VSphereD
}

for _, vsphereCluster := range clusterList.Items {
if ctx.VSphereDeploymentZone.Spec.Server == vsphereCluster.Spec.Server && vsphereCluster.Spec.IdentityRef != nil {
if shouldIncludeZone(*ctx.VSphereDeploymentZone, &vsphereCluster) && vsphereCluster.Spec.IdentityRef != nil {
logger := ctx.Logger.WithValues("cluster", vsphereCluster.Name)
params = params.WithThumbprint(vsphereCluster.Spec.Thumbprint)
creds, err := identity.GetCredentials(ctx, r.Client, &vsphereCluster, r.Namespace) // nolint:scopelint
Expand Down

0 comments on commit fc16bbd

Please sign in to comment.