From 8458b63a0280a614cf38acb2928c7a6d1e66fb2f Mon Sep 17 00:00:00 2001 From: Zhongcheng Lao Date: Fri, 4 Aug 2023 18:18:11 +0800 Subject: [PATCH] Fixes session active check with datacenter scoped TKG admin account --- pkg/session/session.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/session/session.go b/pkg/session/session.go index 4361148fd2..6b223a5161 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -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") } @@ -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 }