Skip to content

Commit

Permalink
Skip PV patch step in Restoe workflow for WaitForFirstConsumer Volume…
Browse files Browse the repository at this point in the history
…BindingMode Pending state PVCs

Signed-off-by: Shubham Pampattiwar <[email protected]>
  • Loading branch information
shubham-pampattiwar committed Jun 28, 2024
1 parent c827fd0 commit 8c03287
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/controller/restore_finalizer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controller
import (
"context"
"fmt"
storagev1api "k8s.io/api/storage/v1"
"sync"
"time"

Expand Down Expand Up @@ -304,6 +305,24 @@ func (ctx *finalizerContext) patchDynamicPVWithVolumeInfo() (errs results.Result
return false, err
}

// check if pvc is not nil and has a pending status
if pvc != nil && pvc.Status.Phase == v1.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 err != nil {
errs.Add(restoredNamespace, 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 backup
if *sc.VolumeBindingMode == storagev1api.VolumeBindingWaitForFirstConsumer {
log.Infof("skipping PV patch step: 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 pvc.Status.Phase != v1.ClaimBound || pvc.Spec.VolumeName == "" {
log.Debugf("PVC: %s not ready", pvc.Name)
return false, nil
Expand Down

0 comments on commit 8c03287

Please sign in to comment.