mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-31 13:17:13 +00:00
fix(restore_finalizer): bound WaitRestoreExecHook poll with resourceT… (#10280)
* fix: reuse DefaultResourceTimeout from server config for hook wait Signed-off-by: Nitish Malang <71919457+nitishmalang@users.noreply.github.com> * Add changelog for PR 10280 Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com> --------- Signed-off-by: Nitish Malang <71919457+nitishmalang@users.noreply.github.com> Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com> Co-authored-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
This commit is contained in:
co-authored by
Tiger Kaovilai
parent
a4b8261ffe
commit
1e26cf7ca0
@@ -39,6 +39,7 @@ import (
|
||||
"github.com/vmware-tanzu/velero/internal/hook"
|
||||
"github.com/vmware-tanzu/velero/internal/volume"
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
serverconfig "github.com/vmware-tanzu/velero/pkg/cmd/server/config"
|
||||
"github.com/vmware-tanzu/velero/pkg/constant"
|
||||
"github.com/vmware-tanzu/velero/pkg/itemoperation"
|
||||
"github.com/vmware-tanzu/velero/pkg/metrics"
|
||||
@@ -577,8 +578,18 @@ func (ctx *finalizerContext) WaitRestoreExecHook() (errs results.Result) {
|
||||
log := ctx.logger.WithField("restore", ctx.restore.Name)
|
||||
log.Info("Waiting for restore exec hooks starts")
|
||||
|
||||
// wait for restore exec hooks to finish
|
||||
err := wait.PollUntilContextCancel(context.Background(), 1*time.Second, true, func(context.Context) (bool, error) {
|
||||
// Bound the wait by resourceTimeout (the same budget Velero already
|
||||
// applies to other finalizer phases). Previously this poll had no
|
||||
// deadline, so a hook that was registered via Add() but never
|
||||
// recorded as executed left the restore stuck in Finalizing forever
|
||||
// and blocked every other restore on the cluster.
|
||||
timeout := ctx.resourceTimeout
|
||||
if timeout <= 0 {
|
||||
timeout = serverconfig.DefaultResourceTimeout
|
||||
}
|
||||
pollCtx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
err := wait.PollUntilContextCancel(pollCtx, 1*time.Second, true, func(context.Context) (bool, error) {
|
||||
log.Debug("Checking the progress of hooks execution")
|
||||
if ctx.multiHookTracker.IsComplete(ctx.restore.Name) {
|
||||
return true, nil
|
||||
|
||||
Reference in New Issue
Block a user