Skip to content

Commit 1a05ebe

Browse files
authored
Merge pull request kubernetes#93655 from liggitt/deflake-test-controller-sync
Deflake TestControllerSync
2 parents 0d2299e + c4c946d commit 1a05ebe

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/controller/volume/persistentvolume/pv_controller_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
v1 "k8s.io/api/core/v1"
2626
storagev1 "k8s.io/api/storage/v1"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28+
"k8s.io/apimachinery/pkg/util/wait"
2829
"k8s.io/apimachinery/pkg/watch"
2930
utilfeature "k8s.io/apiserver/pkg/util/feature"
3031
"k8s.io/client-go/informers"
@@ -160,11 +161,15 @@ func TestControllerSync(t *testing.T) {
160161
for len(ctrl.claims.ListKeys()) > 0 {
161162
time.Sleep(10 * time.Millisecond)
162163
}
163-
// make sure the operation timestamp cache is NOT empty
164-
if !ctrl.operationTimestamps.Has("volume5-6") {
165-
return errors.New("failed checking timestamp cache: should not be empty")
166-
}
167-
return nil
164+
// wait for volume delete operation to appear once volumeWorker() runs
165+
return wait.PollImmediate(10*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
166+
// make sure the operation timestamp cache is NOT empty
167+
if ctrl.operationTimestamps.Has("volume5-6") {
168+
return true, nil
169+
}
170+
t.Logf("missing volume5-6 from timestamp cache, will retry")
171+
return false, nil
172+
})
168173
},
169174
},
170175
{

0 commit comments

Comments
 (0)