Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e storage: wait for PV deletion also for late binding #90335

Merged
merged 1 commit into from May 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 25 additions & 3 deletions test/e2e/storage/testsuites/base.go
Expand Up @@ -308,15 +308,37 @@ func (r *VolumeResource) CleanupResource() error {
r.Pv.Name, v1.PersistentVolumeReclaimDelete)
}
if r.Pvc != nil {
cs := f.ClientSet
pv := r.Pv
if pv == nil && r.Pvc.Name != "" {
// This happens for late binding. Check whether we have a volume now that we need to wait for.
pvc, err := cs.CoreV1().PersistentVolumeClaims(r.Pvc.Namespace).Get(context.TODO(), r.Pvc.Name, metav1.GetOptions{})
switch {
case err == nil:
if pvc.Spec.VolumeName != "" {
pv, err = cs.CoreV1().PersistentVolumes().Get(context.TODO(), pvc.Spec.VolumeName, metav1.GetOptions{})
if err != nil {
cleanUpErrs = append(cleanUpErrs, errors.Wrapf(err, "Failed to find PV %v", pvc.Spec.VolumeName))
}
}
case apierrors.IsNotFound(err):
// Without the PVC, we cannot locate the corresponding PV. Let's
// hope that it is gone.
default:
cleanUpErrs = append(cleanUpErrs, errors.Wrapf(err, "Failed to find PVC %v", r.Pvc.Name))
}
}

err := e2epv.DeletePersistentVolumeClaim(f.ClientSet, r.Pvc.Name, f.Namespace.Name)
if err != nil {
cleanUpErrs = append(cleanUpErrs, errors.Wrapf(err, "Failed to delete PVC %v", r.Pvc.Name))
}
if r.Pv != nil {
err = e2epv.WaitForPersistentVolumeDeleted(f.ClientSet, r.Pv.Name, 5*time.Second, 5*time.Minute)

if pv != nil {
err = e2epv.WaitForPersistentVolumeDeleted(f.ClientSet, pv.Name, 5*time.Second, 5*time.Minute)
if err != nil {
cleanUpErrs = append(cleanUpErrs, errors.Wrapf(err,
"Persistent Volume %v not deleted by dynamic provisioner", r.Pv.Name))
"Persistent Volume %v not deleted by dynamic provisioner", pv.Name))
}
}
}
Expand Down