mirror of https://github.com/k3s-io/k3s
Merge pull request #65913 from dougm/vcp-logout-race
Automatic merge from submit-queue (batch tested with PRs 65946, 65904, 65913, 65906, 65920). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. vSphere Cloud Provider: avoid read race during logout **What this PR does / why we need it**: The `go test -race` will sometimes detect a read race in the vSphere Cloud Provider logout function, causing tests to fail. **Which issue(s) this PR fixes**: Fixes #65696 **Special notes for your reviewer**: The Client nil check was added inpull/8/head6d1c4a3
, but there was not any go test coverage of that code path untile22f9ca
**Release note**: ```release-note none ```
commit
c899ccf441
|
@ -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