@@ -34,6 +34,7 @@ import (
3434 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/context"
3535 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/record"
3636 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/services/cloudprovider"
37+ "sigs.k8s.io/cluster-api-provider-vsphere/pkg/session"
3738 infrautilv1 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/util"
3839 clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
3940 clusterutilv1 "sigs.k8s.io/cluster-api/util"
@@ -251,6 +252,13 @@ func (r clusterReconciler) reconcileNormal(ctx *context.ClusterContext) (reconci
251252 // If the VSphereCluster doesn't have our finalizer, add it.
252253 ctrlutil .AddFinalizer (ctx .VSphereCluster , infrav1 .ClusterFinalizer )
253254
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 )
259+ }
260+ conditions .MarkTrue (ctx .VSphereCluster , infrav1 .VCenterAvailableCondition )
261+
254262 // Reconcile the VSphereCluster's load balancer.
255263 if ok , err := r .reconcileLoadBalancer (ctx ); ! ok {
256264 if err != nil {
@@ -319,6 +327,12 @@ func (r clusterReconciler) reconcileNormal(ctx *context.ClusterContext) (reconci
319327 return reconcile.Result {}, nil
320328}
321329
330+ func (r clusterReconciler ) reconcileVCenterConnectivity (ctx * context.ClusterContext ) error {
331+ _ , err := session .GetOrCreate (ctx , ctx .VSphereCluster .Spec .Server ,
332+ ctx .VSphereCluster .Spec .CloudProviderConfiguration .Workspace .Datacenter , ctx .Username , ctx .Password , ctx .VSphereCluster .Spec .Thumbprint )
333+ return err
334+ }
335+
322336func (r clusterReconciler ) reconcileLoadBalancer (ctx * context.ClusterContext ) (bool , error ) {
323337
324338 if ctx .VSphereCluster .Spec .LoadBalancerRef == nil {
0 commit comments