Skip to content

Commit d4e5e0a

Browse files
authored
[test] Fix concurrent map writes panic (#18801)
1 parent f123be6 commit d4e5e0a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/pkg/integration/apis.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type ComponentAPI struct {
107107
wsmanStatusMu sync.Mutex
108108
contentServiceStatusMu sync.Mutex
109109
imgbldStatusMu sync.Mutex
110+
serverStatusMu sync.Mutex
110111
}
111112

112113
type EncryptionKeyMetadata struct {
@@ -285,7 +286,11 @@ func (c *ComponentAPI) GitpodServer(opts ...GitpodServerOpt) (gitpod.APIInterfac
285286
if err != nil {
286287
return err
287288
}
288-
c.serverStatus.Token[options.User] = tkn
289+
func() {
290+
c.serverStatusMu.Lock()
291+
defer c.serverStatusMu.Unlock()
292+
c.serverStatus.Token[options.User] = tkn
293+
}()
289294
}
290295

291296
var pods corev1.PodList
@@ -322,7 +327,12 @@ func (c *ComponentAPI) GitpodServer(opts ...GitpodServerOpt) (gitpod.APIInterfac
322327
return err
323328
}
324329

325-
c.serverStatus.Client[options.User] = cl
330+
func() {
331+
c.serverStatusMu.Lock()
332+
defer c.serverStatusMu.Unlock()
333+
c.serverStatus.Client[options.User] = cl
334+
}()
335+
326336
res = cl
327337
c.appendCloser(cl.Close)
328338

0 commit comments

Comments
 (0)