Skip to content

Commit 10c54dd

Browse files
authored
Merge pull request #1084 from yastij/cpi-optional
skip cloud provider/CSI install when no cloudprovider config is provided
2 parents 1f40272 + e313fc2 commit 10c54dd

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

controllers/vspherecluster_controller.go

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,14 @@ func (r clusterReconciler) reconcileNormal(ctx *context.ClusterContext) (reconci
252252
// If the VSphereCluster doesn't have our finalizer, add it.
253253
ctrlutil.AddFinalizer(ctx.VSphereCluster, infrav1.ClusterFinalizer)
254254

255-
if err := r.reconcileVCenterConnectivity(ctx); err != nil {
256-
conditions.MarkFalse(ctx.VSphereCluster, infrav1.VCenterAvailableCondition, infrav1.VCenterUnreachableReason, clusterv1.ConditionSeverityError, err.Error())
257-
return reconcile.Result{}, errors.Wrapf(err,
258-
"unexpected error while probing vcenter for %s", ctx)
255+
if cloudProviderConfigurationAvailable(ctx) {
256+
if err := r.reconcileVCenterConnectivity(ctx); err != nil {
257+
conditions.MarkFalse(ctx.VSphereCluster, infrav1.VCenterAvailableCondition, infrav1.VCenterUnreachableReason, clusterv1.ConditionSeverityError, err.Error())
258+
return reconcile.Result{}, errors.Wrapf(err,
259+
"unexpected error while probing vcenter for %s", ctx)
260+
}
261+
conditions.MarkTrue(ctx.VSphereCluster, infrav1.VCenterAvailableCondition)
259262
}
260-
conditions.MarkTrue(ctx.VSphereCluster, infrav1.VCenterAvailableCondition)
261263

262264
// Reconcile the VSphereCluster's load balancer.
263265
if ok, err := r.reconcileLoadBalancer(ctx); !ok {
@@ -295,38 +297,43 @@ func (r clusterReconciler) reconcileNormal(ctx *context.ClusterContext) (reconci
295297
if !r.isAPIServerOnline(ctx) {
296298
return reconcile.Result{}, nil
297299
}
300+
if cloudProviderConfigurationAvailable(ctx) {
301+
// Create the cloud config secret for the target cluster.
302+
if err := r.reconcileCloudConfigSecret(ctx); err != nil {
303+
conditions.MarkFalse(ctx.VSphereCluster, infrav1.CCMAvailableCondition, infrav1.CCMProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
304+
return reconcile.Result{}, errors.Wrapf(err,
305+
"failed to reconcile cloud config secret for VSphereCluster %s/%s",
306+
ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
307+
}
298308

299-
// Create the cloud config secret for the target cluster.
300-
if err := r.reconcileCloudConfigSecret(ctx); err != nil {
301-
conditions.MarkFalse(ctx.VSphereCluster, infrav1.CCMAvailableCondition, infrav1.CCMProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
302-
return reconcile.Result{}, errors.Wrapf(err,
303-
"failed to reconcile cloud config secret for VSphereCluster %s/%s",
304-
ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
305-
}
306-
307-
// Create the external cloud provider addons
308-
if err := r.reconcileCloudProvider(ctx); err != nil {
309-
conditions.MarkFalse(ctx.VSphereCluster, infrav1.CCMAvailableCondition, infrav1.CCMProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
310-
return reconcile.Result{}, errors.Wrapf(err,
311-
"failed to reconcile cloud provider for VSphereCluster %s/%s",
312-
ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
313-
}
309+
// Create the external cloud provider addons
310+
if err := r.reconcileCloudProvider(ctx); err != nil {
311+
conditions.MarkFalse(ctx.VSphereCluster, infrav1.CCMAvailableCondition, infrav1.CCMProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
312+
return reconcile.Result{}, errors.Wrapf(err,
313+
"failed to reconcile cloud provider for VSphereCluster %s/%s",
314+
ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
315+
}
314316

315-
conditions.MarkTrue(ctx.VSphereCluster, infrav1.CCMAvailableCondition)
317+
conditions.MarkTrue(ctx.VSphereCluster, infrav1.CCMAvailableCondition)
316318

317-
// Create the vSphere CSI Driver addons
318-
if err := r.reconcileStorageProvider(ctx); err != nil {
319-
conditions.MarkFalse(ctx.VSphereCluster, infrav1.CSIAvailableCondition, infrav1.CSIProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
320-
return reconcile.Result{}, errors.Wrapf(err,
321-
"failed to reconcile CSI Driver for VSphereCluster %s/%s",
322-
ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
319+
// Create the vSphere CSI Driver addons
320+
if err := r.reconcileStorageProvider(ctx); err != nil {
321+
conditions.MarkFalse(ctx.VSphereCluster, infrav1.CSIAvailableCondition, infrav1.CSIProvisioningFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
322+
return reconcile.Result{}, errors.Wrapf(err,
323+
"failed to reconcile CSI Driver for VSphereCluster %s/%s",
324+
ctx.VSphereCluster.Namespace, ctx.VSphereCluster.Name)
325+
}
323326
}
324327

325328
conditions.MarkTrue(ctx.VSphereCluster, infrav1.CSIAvailableCondition)
326329

327330
return reconcile.Result{}, nil
328331
}
329332

333+
func cloudProviderConfigurationAvailable(ctx *context.ClusterContext) bool {
334+
return !reflect.DeepEqual(ctx.VSphereCluster.Spec.CloudProviderConfiguration, infrav1.CPIConfig{})
335+
}
336+
330337
func (r clusterReconciler) reconcileVCenterConnectivity(ctx *context.ClusterContext) error {
331338
_, err := session.GetOrCreate(ctx, ctx.VSphereCluster.Spec.Server,
332339
ctx.VSphereCluster.Spec.CloudProviderConfiguration.Workspace.Datacenter, ctx.Username, ctx.Password, ctx.VSphereCluster.Spec.Thumbprint)

0 commit comments

Comments
 (0)