Merge pull request #102477 from yuzhiquan/master

FIx failing tests: [sig-storage] Test_ADC_VolumeAttachmentRecovery/Deleted_Pod_with_migrated_PV
This commit is contained in:
Kubernetes Prow Robot 2021-06-03 20:53:26 -07:00 committed by GitHub
commit adf8df7b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,29 +173,38 @@ func CreateTestClient() *fake.Clientset {
obj.Items = append(obj.Items, nodes.Items...)
return true, obj, nil
})
var mu sync.Mutex
volumeAttachments = &storagev1.VolumeAttachmentList{}
fakeClient.AddReactor("list", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) {
obj := &storagev1.VolumeAttachmentList{}
mu.Lock()
obj.Items = append(obj.Items, volumeAttachments.Items...)
mu.Unlock()
return true, obj, nil
})
fakeClient.AddReactor("create", "volumeattachments", func(action core.Action) (handled bool, ret runtime.Object, err error) {
createAction := action.(core.CreateAction)
va := createAction.GetObject().(*storagev1.VolumeAttachment)
mu.Lock()
volumeAttachments.Items = append(volumeAttachments.Items, *va)
mu.Unlock()
return true, createAction.GetObject(), nil
})
pvs = &v1.PersistentVolumeList{}
fakeClient.AddReactor("list", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) {
obj := &v1.PersistentVolumeList{}
mu.Lock()
obj.Items = append(obj.Items, pvs.Items...)
mu.Unlock()
return true, obj, nil
})
fakeClient.AddReactor("create", "persistentvolumes", func(action core.Action) (handled bool, ret runtime.Object, err error) {
createAction := action.(core.CreateAction)
pv := createAction.GetObject().(*v1.PersistentVolume)
mu.Lock()
pvs.Items = append(pvs.Items, *pv)
mu.Unlock()
return true, createAction.GetObject(), nil
})