Skip to content

Commit

Permalink
attempt to logout and clear idle sessions before creating new one (#2930
Browse files Browse the repository at this point in the history
)
  • Loading branch information
adikul30 authored Jun 28, 2024
1 parent 094faf4 commit 89e4fc9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/common/cns-lib/volume/listview.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,16 @@ func (l *ListViewImpl) isClientValid(reconnect bool) error {
return ErrSessionNotAuthenticated
}

log.Infof("logging out current session and clearing idle sessions")

err := l.govmomiClient.Logout(l.ctx)
if err != nil {
log.Errorf("failed to logout current listview session. still cleared idle sessions. err: %v", err)
}

log.Infof("creating a new session...")

err := cnsvsphere.ReadVCConfigs(l.ctx, l.virtualCenter)
err = cnsvsphere.ReadVCConfigs(l.ctx, l.virtualCenter)
if err != nil {
return logger.LogNewErrorf(log, "failed to read VC config. err: %v", err)
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/common/cns-lib/vsphere/virtualcenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ func (vc *VirtualCenter) connect(ctx context.Context, requestNewSession bool) er
return nil
}
}

log.Infof("logging out current session and clearing idle sessions")

err = vc.Client.Logout(ctx)
if err != nil {
log.Errorf("failed to logout current session. still clearing idle sessions. err: %v", err)
}

// If session has expired, create a new instance.
log.Infof("Creating a new client session as the existing one isn't valid or not authenticated")
if vc.Config.ReloadVCConfigForNewClient {
Expand Down

0 comments on commit 89e4fc9

Please sign in to comment.