mirror of
https://github.com/vmware-tanzu/velero.git
synced 2025-12-23 06:15:21 +00:00
Expose PVPatchMaximumDuration timeout for custom configuration
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com> remove debug log Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com> use resource timeout server arg Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com> add changelog Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com> remove hardcoded PVPatchMaximumtimeout const usagDe Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
This commit is contained in:
1
changelogs/unreleased/8021-shubham-pampattiwar
Normal file
1
changelogs/unreleased/8021-shubham-pampattiwar
Normal file
@@ -0,0 +1 @@
|
||||
Make PVPatchMaximumDuration timeout configurable
|
||||
@@ -1022,6 +1022,7 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
|
||||
s.metrics,
|
||||
s.crClient,
|
||||
multiHookTracker,
|
||||
s.config.resourceTimeout,
|
||||
).SetupWithManager(s.mgr); err != nil {
|
||||
s.logger.Fatal(err, "unable to create controller", "controller", controller.RestoreFinalizer)
|
||||
}
|
||||
|
||||
@@ -45,10 +45,6 @@ import (
|
||||
"github.com/vmware-tanzu/velero/pkg/util/results"
|
||||
)
|
||||
|
||||
const (
|
||||
PVPatchMaximumDuration = 10 * time.Minute
|
||||
)
|
||||
|
||||
type restoreFinalizerReconciler struct {
|
||||
client.Client
|
||||
namespace string
|
||||
@@ -59,6 +55,7 @@ type restoreFinalizerReconciler struct {
|
||||
clock clock.WithTickerAndDelayedExecution
|
||||
crClient client.Client
|
||||
multiHookTracker *hook.MultiHookTracker
|
||||
resourceTimeout time.Duration
|
||||
}
|
||||
|
||||
func NewRestoreFinalizerReconciler(
|
||||
@@ -70,6 +67,7 @@ func NewRestoreFinalizerReconciler(
|
||||
metrics *metrics.ServerMetrics,
|
||||
crClient client.Client,
|
||||
multiHookTracker *hook.MultiHookTracker,
|
||||
resourceTimeout time.Duration,
|
||||
) *restoreFinalizerReconciler {
|
||||
return &restoreFinalizerReconciler{
|
||||
Client: client,
|
||||
@@ -81,6 +79,7 @@ func NewRestoreFinalizerReconciler(
|
||||
clock: &clock.RealClock{},
|
||||
crClient: crClient,
|
||||
multiHookTracker: multiHookTracker,
|
||||
resourceTimeout: resourceTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +162,7 @@ func (r *restoreFinalizerReconciler) Reconcile(ctx context.Context, req ctrl.Req
|
||||
volumeInfo: volumeInfo,
|
||||
restoredPVCList: restoredPVCList,
|
||||
multiHookTracker: r.multiHookTracker,
|
||||
resourceTimeout: r.resourceTimeout,
|
||||
}
|
||||
warnings, errs := finalizerCtx.execute()
|
||||
|
||||
@@ -246,6 +246,7 @@ type finalizerContext struct {
|
||||
volumeInfo []*volume.BackupVolumeInfo
|
||||
restoredPVCList map[string]struct{}
|
||||
multiHookTracker *hook.MultiHookTracker
|
||||
resourceTimeout time.Duration
|
||||
}
|
||||
|
||||
func (ctx *finalizerContext) execute() (results.Result, results.Result) { //nolint:unparam //temporarily ignore the lint report: result 0 is always nil (unparam)
|
||||
@@ -268,6 +269,7 @@ func (ctx *finalizerContext) patchDynamicPVWithVolumeInfo() (errs results.Result
|
||||
|
||||
var pvWaitGroup sync.WaitGroup
|
||||
var resultLock sync.Mutex
|
||||
|
||||
maxConcurrency := 3
|
||||
semaphore := make(chan struct{}, maxConcurrency)
|
||||
|
||||
@@ -294,7 +296,7 @@ func (ctx *finalizerContext) patchDynamicPVWithVolumeInfo() (errs results.Result
|
||||
log := ctx.logger.WithField("PVC", volInfo.PVCName).WithField("PVCNamespace", restoredNamespace)
|
||||
log.Debug("patching dynamic PV is in progress")
|
||||
|
||||
err := wait.PollUntilContextTimeout(context.Background(), 10*time.Second, PVPatchMaximumDuration, true, func(context.Context) (bool, error) {
|
||||
err := wait.PollUntilContextTimeout(context.Background(), 10*time.Second, ctx.resourceTimeout, true, func(context.Context) (bool, error) {
|
||||
// wait for PVC to be bound
|
||||
pvc := &v1.PersistentVolumeClaim{}
|
||||
err := ctx.crClient.Get(context.Background(), client.ObjectKey{Name: volInfo.PVCName, Namespace: restoredNamespace}, pvc)
|
||||
|
||||
@@ -138,6 +138,7 @@ func TestRestoreFinalizerReconcile(t *testing.T) {
|
||||
metrics.NewServerMetrics(),
|
||||
fakeClient,
|
||||
hook.NewMultiHookTracker(),
|
||||
10*time.Minute,
|
||||
)
|
||||
r.clock = testclocks.NewFakeClock(now)
|
||||
|
||||
@@ -200,6 +201,7 @@ func TestUpdateResult(t *testing.T) {
|
||||
metrics.NewServerMetrics(),
|
||||
fakeClient,
|
||||
hook.NewMultiHookTracker(),
|
||||
10*time.Minute,
|
||||
)
|
||||
restore := builder.ForRestore(velerov1api.DefaultNamespace, "restore-1").Result()
|
||||
res := map[string]results.Result{"warnings": {}, "errors": {}}
|
||||
|
||||
Reference in New Issue
Block a user