add a 60 second timeout for initial mounting

This commit is contained in:
Gareth
2025-11-14 22:14:47 -08:00
parent eccfc53356
commit db98a5108e
+7
View File
@@ -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()