Skip to content

Commit

Permalink
Set keep alive false to avoid deadlock (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erkan Erol authored Aug 1, 2024
1 parent 12feea8 commit c679a31
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Add more logs to improve debugging.
- Set `EnableKeepAlive=false` to avoid deadlock.

## [0.3.0] - 2024-07-24

### Changed
Expand Down
11 changes: 9 additions & 2 deletions controllers/vspherecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (r *VSphereClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
}

func (r *VSphereClusterReconciler) reconcileNormal(ctx context.Context, log logr.Logger, vsphereCluster *capv.VSphereCluster) (reconcile.Result, error) {
log.V(1).Info("Reconciling for normal state")
// If the vsphereCluster doesn't have the finalizer, add it.
err := r.addFinalizer(ctx, log, vsphereCluster)
if err != nil {
Expand All @@ -124,8 +125,10 @@ func (r *VSphereClusterReconciler) reconcileNormal(ctx context.Context, log logr
}

func (r *VSphereClusterReconciler) reconcileDelete(ctx context.Context, log logr.Logger, vsphereCluster *capv.VSphereCluster) (reconcile.Result, error) {
log.V(1).Info("Reconciling for deletion")
if !controllerutil.ContainsFinalizer(vsphereCluster, key.CleanerFinalizerName) {
// no-op in case the finalizer is not there (it could have been deleted manually)
// the cleanup is already done
log.V(1).Info("There is no finalizer on VsphereCluster CR. Deletion should have already been done")
return ctrl.Result{}, nil
}

Expand All @@ -139,6 +142,7 @@ func (r *VSphereClusterReconciler) reconcileDelete(ctx context.Context, log logr

sess, err := r.getVCenterSession(ctx, vsphereCluster)
if err != nil {
log.V(1).Error(err, "Error while getting vcenter session")
return reconcile.Result{}, microerror.Mask(err)
}

Expand Down Expand Up @@ -186,7 +190,10 @@ func (r *VSphereClusterReconciler) getVCenterSession(ctx context.Context, cluste
return nil, err
}

params = params.WithUserInfo(creds.Username, creds.Password)
params = params.
WithUserInfo(creds.Username, creds.Password).
WithFeatures(session.Feature{EnableKeepAlive: false})

return session.GetOrCreate(ctx, params)
}

Expand Down

0 comments on commit c679a31

Please sign in to comment.