mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
vSphere Cloud Provider: avoid read race during logout
The Client nil check was added in6d1c4a3
, but there was not any go test coverage of that code path untile22f9ca
Fixes #65696
This commit is contained in:
parent
91b729342d
commit
9a219513dc
@ -131,7 +131,14 @@ func (connection *VSphereConnection) login(ctx context.Context, client *vim25.Cl
|
||||
|
||||
// Logout calls SessionManager.Logout for the given connection.
|
||||
func (connection *VSphereConnection) Logout(ctx context.Context) {
|
||||
m := session.NewManager(connection.Client)
|
||||
clientLock.Lock()
|
||||
c := connection.Client
|
||||
clientLock.Unlock()
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
|
||||
m := session.NewManager(c)
|
||||
|
||||
hasActiveSession, err := m.SessionIsActive(ctx)
|
||||
if err != nil {
|
||||
|
@ -510,11 +510,8 @@ func buildVSphereFromConfig(cfg VSphereConfig) (*VSphere, error) {
|
||||
|
||||
func logout(vs *VSphere) {
|
||||
for _, vsphereIns := range vs.vsphereInstanceMap {
|
||||
if vsphereIns.conn.Client != nil {
|
||||
vsphereIns.conn.Logout(context.TODO())
|
||||
}
|
||||
vsphereIns.conn.Logout(context.TODO())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Instances returns an implementation of Instances for vSphere.
|
||||
|
Loading…
Reference in New Issue
Block a user