mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
Merge pull request #115799 from pohly/test-util-data-race
test/utils: avoid data race during parallel create
This commit is contained in:
commit
1e84987bac
@ -1346,7 +1346,10 @@ func CreatePod(ctx context.Context, client clientset.Interface, namespace string
|
||||
var createError error
|
||||
lock := sync.Mutex{}
|
||||
createPodFunc := func(i int) {
|
||||
if err := makeCreatePod(client, namespace, podTemplate); err != nil {
|
||||
// client-go writes into the object that is passed to Create,
|
||||
// causing a data race unless we create a new copy for each
|
||||
// parallel call.
|
||||
if err := makeCreatePod(client, namespace, podTemplate.DeepCopy()); err != nil {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
createError = err
|
||||
|
Loading…
Reference in New Issue
Block a user