Skip to content

Commit

Permalink
Fixes session active check with datacenter scoped TKG admin account
Browse files Browse the repository at this point in the history
  • Loading branch information
laozc committed Aug 28, 2023
1 parent 2f371d7 commit 8458b63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ func GetOrCreate(ctx context.Context, params *Params) (*Session, error) {
if cachedSession, ok := sessionCache.Load(sessionKey); ok {
s := cachedSession.(*Session)

vimSessionActive, err := s.SessionManager.SessionIsActive(ctx)
// Retrieve the current session from Managed Object.
// The userSession is active when the value is not nil.
userSession, err := s.SessionManager.UserSession(ctx)
if err != nil {
logger.Error(err, "unable to check if vim session is active")
}
Expand All @@ -141,7 +143,7 @@ func GetOrCreate(ctx context.Context, params *Params) (*Session, error) {
logger.Error(err, "unable to check if rest session is active")
}

if vimSessionActive && tagManagerSession != nil {
if userSession != nil && tagManagerSession != nil {
logger.V(2).Info("found active cached vSphere client session")
return s, nil
}
Expand Down

0 comments on commit 8458b63

Please sign in to comment.