From 22d3e81bf2654bc07b676fb08d48c1643938a1b7 Mon Sep 17 00:00:00 2001 From: Xuhui zhang Date: Fri, 1 Nov 2024 11:05:18 +0800 Subject: [PATCH] add timeout for resolveTarget Signed-off-by: Xuhui zhang --- pkg/controller/pod_driver.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/controller/pod_driver.go b/pkg/controller/pod_driver.go index 4bf0e7d8c7..619a4bd692 100644 --- a/pkg/controller/pod_driver.go +++ b/pkg/controller/pod_driver.go @@ -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 }