Merge pull request #91726 from bertinatto/fix-flake-sc

Create pod to force volume provisioning in dynamic provisioning storage e2e test
This commit is contained in:
Kubernetes Prow Robot 2020-06-11 00:52:56 -07:00 committed by GitHub
commit 42bf886b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -350,6 +350,23 @@ func (t StorageClassTest) TestDynamicProvisioning() *v1.PersistentVolume {
} }
}() }()
if class == nil {
// StorageClass is nil, so the default one will be used
scName, err := e2epv.GetDefaultStorageClassName(client)
framework.ExpectNoError(err)
defaultSC, err := client.StorageV1().StorageClasses().Get(context.TODO(), scName, metav1.GetOptions{})
framework.ExpectNoError(err)
// If late binding is configured, create and delete a pod to provision the volume
if *defaultSC.VolumeBindingMode == storagev1.VolumeBindingWaitForFirstConsumer {
ginkgo.By("creating a pod referring to the claim")
var pod *v1.Pod
pod, err := e2epod.CreatePod(t.Client, claim.Namespace, nil /* nodeSelector */, []*v1.PersistentVolumeClaim{claim}, true /* isPrivileged */, "" /* command */)
// Delete pod now, otherwise PV can't be deleted below
framework.ExpectNoError(err)
e2epod.DeletePodOrFail(t.Client, pod.Namespace, pod.Name)
}
}
// Run the checker // Run the checker
if t.PvCheck != nil { if t.PvCheck != nil {
t.PvCheck(claim) t.PvCheck(claim)