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

Add origin remote if it's not already set on the mirror repo #1685

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

Conversation

KevinGreen
Copy link
Contributor

Problem

We've hit an issue a couple times where agents with a shared git mirror repo fail when trying to set the remote url for origin. The agents sharing the repo will fail consistently but can be recovered by manually running git --git-dir <mirrorDir> remote add origin <url> on the host.

The root cause for the repo getting into this state isn't known yet. From scanning the logs I haven't found any errors or abnormal operation. The only thing I see is that all the agents start picking up jobs at the same time so it could be due to another git operation running without a lock somewhere else.

Proposed Solution

This PR just checks if there's not already a url for origin and runs git remote add if there isn't. This code runs within the update lock so there won't be any issue with multiple agents checking and branching based on the git remote get-url result.

Tests

There aren't any unit tests for this part of the code as far as I've seen. This doesn't reproduce often but we want to have a fix in to avoid issues in the future.

@KevinGreen KevinGreen changed the title Add origin remote if it's not already set on the repo Add origin remote if it's not already set on the mirror repo Jun 28, 2022
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.

1 participant