Skip to content

Commit

Permalink
Merge pull request #1066 from yastij/probe-vcenter
Browse files Browse the repository at this point in the history
probe vcenter as part of the vspherecluster reconciliation
  • Loading branch information
k8s-ci-robot authored Jan 11, 2021
2 parents 03b6af5 + 556d6cc commit 9aac384
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/v1alpha3/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ const (
// while installing the container storage interface addon; those kind of errors are usually transient
// the operation is automatically re-tried by the controller.
CSIProvisioningFailedReason = "CSIProvisioningFailed"

// VCenterAvailableCondition documents the connectivity with vcenter
// for a given VSphereCluster
VCenterAvailableCondition clusterv1.ConditionType = "VCenterAvailable"

// VCenterUnreachableReason (Severity=Error) documents a VSphereCluster controller detecting
// issues with VCenter reachability;
VCenterUnreachableReason = "VCenterUnreachable"
)

// Conditions and condition Reasons for the VSphereMachine and the VSphereVM object.
Expand Down
14 changes: 14 additions & 0 deletions controllers/vspherecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/context"
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/record"
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/services/cloudprovider"
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/session"
infrautilv1 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/util"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterutilv1 "sigs.k8s.io/cluster-api/util"
Expand Down Expand Up @@ -251,6 +252,13 @@ func (r clusterReconciler) reconcileNormal(ctx *context.ClusterContext) (reconci
// If the VSphereCluster doesn't have our finalizer, add it.
ctrlutil.AddFinalizer(ctx.VSphereCluster, infrav1.ClusterFinalizer)

if err := r.reconcileVCenterConnectivity(ctx); err != nil {
conditions.MarkFalse(ctx.VSphereCluster, infrav1.VCenterAvailableCondition, infrav1.VCenterUnreachableReason, clusterv1.ConditionSeverityError, err.Error())
return reconcile.Result{}, errors.Wrapf(err,
"unexpected error while probing vcenter for %s", ctx)
}
conditions.MarkTrue(ctx.VSphereCluster, infrav1.VCenterAvailableCondition)

// Reconcile the VSphereCluster's load balancer.
if ok, err := r.reconcileLoadBalancer(ctx); !ok {
if err != nil {
Expand Down Expand Up @@ -319,6 +327,12 @@ func (r clusterReconciler) reconcileNormal(ctx *context.ClusterContext) (reconci
return reconcile.Result{}, nil
}

func (r clusterReconciler) reconcileVCenterConnectivity(ctx *context.ClusterContext) error {
_, err := session.GetOrCreate(ctx, ctx.VSphereCluster.Spec.Server,
ctx.VSphereCluster.Spec.CloudProviderConfiguration.Workspace.Datacenter, ctx.Username, ctx.Password, ctx.VSphereCluster.Spec.Thumbprint)
return err
}

func (r clusterReconciler) reconcileLoadBalancer(ctx *context.ClusterContext) (bool, error) {

if ctx.VSphereCluster.Spec.LoadBalancerRef == nil {
Expand Down

0 comments on commit 9aac384

Please sign in to comment.