diff --git a/internal/orchestrator/repo/repo.go b/internal/orchestrator/repo/repo.go index ff267078..210cbd5b 100644 --- a/internal/orchestrator/repo/repo.go +++ b/internal/orchestrator/repo/repo.go @@ -114,14 +114,21 @@ func (r *RepoOrchestrator) Mount(ctx context.Context) (string, func(), error) { return "", func() {}, r.mountErr } + // Give mount 60 seconds to succeed, but if it succeeds allow it to run indefinitely in the background. mountCtx, cancel := context.WithCancel(context.Background()) + cancelMounting := time.AfterFunc(60*time.Second, func() { + cancel() + }) + if err := r.repo.Mount(mountCtx, r.mountDir); err != nil { r.logger(ctx).Warn("failed to mount repo", zap.Error(err)) r.mountErr = fmt.Errorf("mount repo %v: %w", r.repoConfig.Id, err) cancel() + cancelMounting.Stop() os.Remove(r.mountDir) return "", func() {}, r.mountErr } + cancelMounting.Stop() r.mountTimer = time.AfterFunc(1000*time.Hour, func() { r.mountMu.Lock() defer r.mountMu.Unlock()