Skip to content

Commit

Permalink
add timeout for resolveTarget
Browse files Browse the repository at this point in the history
Signed-off-by: Xuhui zhang <[email protected]>
  • Loading branch information
zxh326 committed Nov 1, 2024
1 parent ac303d2 commit 22d3e81
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/controller/pod_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,15 @@ func (p *PodDriver) recover(ctx context.Context, pod *corev1.Pod, mntPath string
}
for k, target := range pod.Annotations {
if k == util.GetReferenceKey(target) {
mi := p.mit.resolveTarget(ctx, target)
if mi == nil {
log.Info("pod target resolve fail", "target", target)
var mi *mountItem
err := util.DoWithTimeout(ctx, defaultCheckoutTimeout, func() error {
mi = p.mit.resolveTarget(ctx, target)
return nil
})
if err != nil || mi == nil {
log.Info("pod target resolve fail", "target", target, "err", err)
continue
}

if err := p.recoverTarget(ctx, pod.Name, mntPath, mi.baseTarget, mi); err != nil {
return err
}
Expand Down

0 comments on commit 22d3e81

Please sign in to comment.