mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 19:56:06 +00:00
Harden "patchDynamicPVWithVolumeInfo" (#10271)
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
e2e-test-kind.yaml / extract (push) Failing after 6s
Run the E2E test on kind / get-go-version (push) Failing after 6s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 8s
Main CI / Build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
e2e-test-kind.yaml / extract (push) Failing after 6s
Run the E2E test on kind / get-go-version (push) Failing after 6s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 8s
Main CI / Build (push) Skipped
This commit hardens the func "patchDynamicPVWithVolumeInfo": 1. Add nil checks for storageClass and the attributes. 2. Remove the double reported errors. Signed-off-by: Daniel Jiang <daniel.jiang@broadcom.com>
This commit is contained in:
@@ -374,19 +374,20 @@ func (ctx *finalizerContext) patchDynamicPVWithVolumeInfo() (errs results.Result
|
||||
// failures due to the PVC not being bound, which could cause a timeout and result in a failed restore.
|
||||
if pvc.Status.Phase == corev1api.ClaimPending {
|
||||
// check if storage class used has VolumeBindingMode as WaitForFirstConsumer
|
||||
scName := *pvc.Spec.StorageClassName
|
||||
sc := &storagev1api.StorageClass{}
|
||||
err = ctx.crClient.Get(context.Background(), client.ObjectKey{Name: scName}, sc)
|
||||
if pvc.Spec.StorageClassName != nil && *pvc.Spec.StorageClassName != "" {
|
||||
scName := *pvc.Spec.StorageClassName
|
||||
sc := &storagev1api.StorageClass{}
|
||||
err = ctx.crClient.Get(context.Background(), client.ObjectKey{Name: scName}, sc)
|
||||
|
||||
if err != nil {
|
||||
errs.Add(restoredNamespace, err)
|
||||
return false, err
|
||||
}
|
||||
// skip PV patch step for this scenario
|
||||
// because pvc would not be bound and the PV patch step would fail due to timeout thus failing the restore
|
||||
if *sc.VolumeBindingMode == storagev1api.VolumeBindingWaitForFirstConsumer {
|
||||
log.Warnf("skipping PV patch to restore custom reclaim policy, if any: StorageClass %s used by PVC %s has VolumeBindingMode set to WaitForFirstConsumer, and the PVC is also in a pending state", scName, pvc.Name)
|
||||
return true, nil
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
// skip PV patch step for this scenario
|
||||
// because pvc would not be bound and the PV patch step would fail due to timeout thus failing the restore
|
||||
if sc.VolumeBindingMode != nil && *sc.VolumeBindingMode == storagev1api.VolumeBindingWaitForFirstConsumer {
|
||||
log.Warnf("skipping PV patch to restore custom reclaim policy, if any: StorageClass %s used by PVC %s has VolumeBindingMode set to WaitForFirstConsumer, and the PVC is also in a pending state", scName, pvc.Name)
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user