From d095c325e878bc47092593426dce907863aaf067 Mon Sep 17 00:00:00 2001 From: Sorcha Abel Date: Mon, 23 Sep 2024 17:19:22 +1000 Subject: [PATCH] PS-111-mirrors use withTimeout that will cancel after expiry --- internal/job/checkout.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/job/checkout.go b/internal/job/checkout.go index e5caa25f80..756b1999bd 100644 --- a/internal/job/checkout.go +++ b/internal/job/checkout.go @@ -484,10 +484,14 @@ func (e *Executor) defaultCheckoutPhase(ctx context.Context) error { var mirrorDir string + lockTimeout := time.Second * time.Duration(e.GitMirrorsLockTimeout) + getCtx, canc := context.WithTimeout(ctx, lockTimeout) + defer canc() + // If we can, get a mirror of the git repository to use for reference later if e.ExecutorConfig.GitMirrorsPath != "" && e.ExecutorConfig.Repository != "" { span.AddAttributes(map[string]string{"checkout.is_using_git_mirrors": "true"}) - mirrorDir, err = e.getOrUpdateMirrorDir(ctx, e.Repository) + mirrorDir, err = e.getOrUpdateMirrorDir(getCtx, e.Repository) if err != nil { return fmt.Errorf("getting/updating git mirror: %w", err) }