@@ -1058,6 +1058,25 @@ func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
1058
1058
defer testClient .CoreV1 ().PersistentVolumes ().DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {})
1059
1059
defer testClient .StorageV1 ().StorageClasses ().DeleteCollection (context .TODO (), metav1.DeleteOptions {}, metav1.ListOptions {})
1060
1060
1061
+ // Watch all events in the namespace, and save them to artifacts for debugging.
1062
+ // TODO: This is a temporary solution to debug flaky tests `panic: test timed out after 10m0s`.
1063
+ // We should remove this once https://github.com/kubernetes/kubernetes/issues/124136 is fixed.
1064
+ go func () {
1065
+ w , err := testClient .EventsV1 ().Events (ns .Name ).Watch (tCtx , metav1.ListOptions {})
1066
+ if err != nil {
1067
+ return
1068
+ }
1069
+ for {
1070
+ select {
1071
+ case event := <- w .ResultChan ():
1072
+ reportToArtifacts (t .Name ()+ "-events.text" , event .Object )
1073
+ case <- tCtx .Done ():
1074
+ w .Stop ()
1075
+ return
1076
+ }
1077
+ }
1078
+ }()
1079
+
1061
1080
storageClass := storage.StorageClass {
1062
1081
TypeMeta : metav1.TypeMeta {
1063
1082
Kind : "StorageClass" ,
@@ -1090,7 +1109,7 @@ func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
1090
1109
1091
1110
// Wait until the controller provisions and binds all of them
1092
1111
for i := 0 ; i < objCount ; i ++ {
1093
- waitForAnyPersistentVolumeClaimPhase ( watchPVC , v1 .ClaimBound )
1112
+ waitForAnyPersistentVolumeClaimPhaseAndReportIt ( t , watchPVC , v1 .ClaimBound )
1094
1113
klog .V (1 ).Infof ("%d claims bound" , i + 1 )
1095
1114
}
1096
1115
klog .V (2 ).Infof ("TestPersistentVolumeProvisionMultiPVCs: claims are bound" )
@@ -1474,6 +1493,21 @@ func waitForAnyPersistentVolumeClaimPhase(w watch.Interface, phase v1.Persistent
1474
1493
}
1475
1494
}
1476
1495
1496
+ func waitForAnyPersistentVolumeClaimPhaseAndReportIt (t * testing.T , w watch.Interface , phase v1.PersistentVolumeClaimPhase ) {
1497
+ for {
1498
+ event := <- w .ResultChan ()
1499
+ reportToArtifacts (t .Name ()+ "-watched-pvcs.text" , event )
1500
+ claim , ok := event .Object .(* v1.PersistentVolumeClaim )
1501
+ if ! ok {
1502
+ continue
1503
+ }
1504
+ if claim .Status .Phase == phase {
1505
+ klog .V (2 ).Infof ("claim %q is %s" , claim .Name , phase )
1506
+ break
1507
+ }
1508
+ }
1509
+ }
1510
+
1477
1511
func waitForPersistentVolumeClaimStorageClass (t * testing.T , claimName , scName string , w watch.Interface , duration time.Duration ) (* v1.PersistentVolumeClaim , bool ) {
1478
1512
stopTimer := time .NewTimer (duration )
1479
1513
defer stopTimer .Stop ()
0 commit comments