Skip to content

Commit 0ad60b3

Browse files
authored
Merge pull request kubernetes#88801 from jsafrane/snapshot-test-timeout
Fix GCE PD snapshot flakiness
2 parents 2f145e9 + 98b9c7b commit 0ad60b3

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

test/e2e/framework/volume/fixtures.go

+25-5
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func TestServerCleanup(f *framework.Framework, config TestConfig) {
341341
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete pod %v in namespace %v", config.Prefix+"-server", config.Namespace)
342342
}
343343

344-
func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix string, privileged bool, fsGroup *int64, tests []Test) (*v1.Pod, error) {
344+
func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix string, privileged bool, fsGroup *int64, tests []Test, slow bool) (*v1.Pod, error) {
345345
ginkgo.By(fmt.Sprint("starting ", config.Prefix, "-", podSuffix))
346346
var gracePeriod int64 = 1
347347
var command string
@@ -417,8 +417,13 @@ func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix
417417
if err != nil {
418418
return nil, err
419419
}
420-
err = e2epod.WaitForPodRunningInNamespace(client, clientPod)
420+
if slow {
421+
err = e2epod.WaitForPodRunningInNamespaceSlow(client, clientPod.Name, clientPod.Namespace)
422+
} else {
423+
err = e2epod.WaitForPodRunningInNamespace(client, clientPod)
424+
}
421425
if err != nil {
426+
e2epod.DeletePodOrFail(client, clientPod.Namespace, clientPod.Name)
422427
e2epod.WaitForPodToDisappear(client, clientPod.Namespace, clientPod.Name, labels.Everything(), framework.Poll, framework.PodDeleteTimeout)
423428
return nil, err
424429
}
@@ -471,8 +476,24 @@ func testVolumeContent(f *framework.Framework, pod *v1.Pod, fsGroup *int64, fsTy
471476
// and check that the pod sees expected data, e.g. from the server pod.
472477
// Multiple Tests can be specified to mount multiple volumes to a single
473478
// pod.
479+
// Timeout for dynamic provisioning (if "WaitForFirstConsumer" is set && provided PVC is not bound yet),
480+
// pod creation, scheduling and complete pod startup (incl. volume attach & mount) is pod.podStartTimeout.
481+
// It should be used for cases where "regular" dynamic provisioning of an empty volume is requested.
474482
func TestVolumeClient(f *framework.Framework, config TestConfig, fsGroup *int64, fsType string, tests []Test) {
475-
clientPod, err := runVolumeTesterPod(f.ClientSet, config, "client", false, fsGroup, tests)
483+
testVolumeClient(f, config, fsGroup, fsType, tests, false)
484+
}
485+
486+
// TestVolumeClientSlow is the same as TestVolumeClient except for its timeout.
487+
// Timeout for dynamic provisioning (if "WaitForFirstConsumer" is set && provided PVC is not bound yet),
488+
// pod creation, scheduling and complete pod startup (incl. volume attach & mount) is pod.slowPodStartTimeout.
489+
// It should be used for cases where "special" dynamic provisioning is requested, such as volume cloning
490+
// or snapshot restore.
491+
func TestVolumeClientSlow(f *framework.Framework, config TestConfig, fsGroup *int64, fsType string, tests []Test) {
492+
testVolumeClient(f, config, fsGroup, fsType, tests, true)
493+
}
494+
495+
func testVolumeClient(f *framework.Framework, config TestConfig, fsGroup *int64, fsType string, tests []Test, slow bool) {
496+
clientPod, err := runVolumeTesterPod(f.ClientSet, config, "client", false, fsGroup, tests, slow)
476497
if err != nil {
477498
framework.Failf("Failed to create client pod: %v", err)
478499
}
@@ -481,7 +502,6 @@ func TestVolumeClient(f *framework.Framework, config TestConfig, fsGroup *int64,
481502
e2epod.WaitForPodToDisappear(f.ClientSet, clientPod.Namespace, clientPod.Name, labels.Everything(), framework.Poll, framework.PodDeleteTimeout)
482503
}()
483504

484-
framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(f.ClientSet, clientPod))
485505
testVolumeContent(f, clientPod, fsGroup, fsType, tests)
486506
}
487507

@@ -493,7 +513,7 @@ func InjectContent(f *framework.Framework, config TestConfig, fsGroup *int64, fs
493513
if framework.NodeOSDistroIs("windows") {
494514
privileged = false
495515
}
496-
injectorPod, err := runVolumeTesterPod(f.ClientSet, config, "injector", privileged, fsGroup, tests)
516+
injectorPod, err := runVolumeTesterPod(f.ClientSet, config, "injector", privileged, fsGroup, tests, false /*slow*/)
497517
if err != nil {
498518
framework.Failf("Failed to create injector pod: %v", err)
499519
return

test/e2e/storage/testsuites/provisioning.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (p *provisioningTestSuite) DefineTests(driver TestDriver, pattern testpatte
229229
ExpectedContent: expectedContent,
230230
},
231231
}
232-
volume.TestVolumeClient(f, testConfig, nil, "", tests)
232+
volume.TestVolumeClientSlow(f, testConfig, nil, "", tests)
233233
}
234234
l.testCase.TestDynamicProvisioning()
235235
})
@@ -257,7 +257,7 @@ func (p *provisioningTestSuite) DefineTests(driver TestDriver, pattern testpatte
257257
ExpectedContent: expectedContent,
258258
},
259259
}
260-
volume.TestVolumeClient(f, testConfig, nil, "", tests)
260+
volume.TestVolumeClientSlow(f, testConfig, nil, "", tests)
261261
}
262262
l.testCase.TestDynamicProvisioning()
263263
})
@@ -305,7 +305,7 @@ func (p *provisioningTestSuite) DefineTests(driver TestDriver, pattern testpatte
305305
ExpectedContent: expectedContent,
306306
},
307307
}
308-
volume.TestVolumeClient(f, myTestConfig, nil, "", tests)
308+
volume.TestVolumeClientSlow(f, myTestConfig, nil, "", tests)
309309
}
310310
myTestCase.TestDynamicProvisioning()
311311
}(i)

0 commit comments

Comments
 (0)