Skip to content

Commit 7816ad7

Browse files
committed
persistentvolume-controller: fix data race of non-deepcopied objects in fake client
1 parent 533daf6 commit 7816ad7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pkg/controller/volume/persistentvolume/pv_controller_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"testing"
2222
"time"
2323

24-
"k8s.io/api/core/v1"
24+
v1 "k8s.io/api/core/v1"
2525
storagev1 "k8s.io/api/storage/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/watch"
@@ -260,12 +260,14 @@ func TestControllerSync(t *testing.T) {
260260

261261
reactor := newVolumeReactor(client, ctrl, fakeVolumeWatch, fakeClaimWatch, test.errors)
262262
for _, claim := range test.initialClaims {
263+
claim = claim.DeepCopy()
263264
reactor.AddClaim(claim)
264265
go func(claim *v1.PersistentVolumeClaim) {
265266
fakeClaimWatch.Add(claim)
266267
}(claim)
267268
}
268269
for _, volume := range test.initialVolumes {
270+
volume = volume.DeepCopy()
269271
reactor.AddVolume(volume)
270272
go func(volume *v1.PersistentVolume) {
271273
fakeVolumeWatch.Add(volume)

0 commit comments

Comments
 (0)