Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS-111-mirrors use withTimeout that will cancel after expiry #3007

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SorchaAbel
Copy link
Contributor

@SorchaAbel SorchaAbel commented Sep 23, 2024

Description

There is an error (intermittently) mirror fails when a node trying to acquire the lock and checkout

if err != nil {
return fmt.Errorf("getting/updating git mirror: %w", err)
}

Ideally the customer wants a new exit code for the git mirror failure so they can retry on that
or
any time element so the lock would get auto-released after a certain period

This PR attempts the latter but I could be way off

Context

Plain: https://app.plain.com/workspace/w_01J0T5SBKJHGBT6FZZHAMH3GRB/thread/th_01J80NPYZRCDEGXAVPNYRD5NT1/
Coda:
https://coda.io/d/Escalations-Feedback_dHnUHNps1YO/Pipelines-Escalations_suQ4B7FT#Pipelines-Escalations-Board_tu66S__K/r711&view=modal

Linear
https://linear.app/buildkite/issue/PS-111/new-exit-code-when-lock-for-git-mirrors

Changes

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go fmt ./...)

Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitMirrorsLockTimeout should already apply within updateGitMirrors, e.g.:

lockTimeout := time.Second * time.Duration(e.GitMirrorsLockTimeout)
if e.Debug {
e.shell.Commentf("Acquiring mirror repository clone lock")
}
// Lock the mirror dir to prevent concurrent clones
cloneCtx, canc := context.WithTimeout(ctx, lockTimeout)
defer canc()
mirrorCloneLock, err := e.shell.LockFile(cloneCtx, mirrorDir+".clonelock")
if err != nil {
return "", err
}
defer mirrorCloneLock.Unlock()

updateCtx, canc := context.WithTimeout(ctx, lockTimeout)
defer canc()
mirrorUpdateLock, err := e.shell.LockFile(updateCtx, mirrorDir+".updatelock")
if err != nil {
return "", err
}
defer mirrorUpdateLock.Unlock()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants