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

Fix submodule mirror repository remote using main repo URL #1998

Merged

Conversation

francoiscampbell
Copy link
Contributor

@francoiscampbell francoiscampbell commented Mar 7, 2023

Followup to #1959.

Upon updating to 3.44, we started seeing the new submodule mirror directories having their origin remote set to the URL of the pipeline's repo instead of the submodule's repo. This is causing a double git fetch of the main repo to happen, once when checking out the commit to build and once when updating submodules.

We also don't want to be running any fetches in the submodule mirror repo since the only branch or PR information the agent has is for the main repo, and those fetches would most likely fail in the submodule mirror.

Reproed in https://github.com/francoiscampbell/buildkite-submodule-test:

# Acquiring mirror repository update lock
--
  | # Using flock-file-locks experiment 🧪
  | $ git --git-dir /nvme/reference_repos/https---github-com-apache-incubator-airflow-git rev-parse 1e54b01ba9676cf74089a2c50e30495e2c16c0e2^{commit}
  | fatal: ambiguous argument '1e54b01ba9676cf74089a2c50e30495e2c16c0e2^{commit}': unknown revision or path not in the working tree.
  | Use '--' to separate paths from revisions, like this:
  | 'git <command> [<revision>...] -- [<file>...]'
  | # ↳ Command completed in 1.6023ms
  | # Updating existing repository mirror to find commit 1e54b01ba9676cf74089a2c50e30495e2c16c0e2
  | $ git --git-dir /nvme/reference_repos/https---github-com-apache-incubator-airflow-git remote set-url origin git@github.com:francoiscampbell/buildkite-submodule-test.git
  | # ↳ Command completed in 1.5309ms
  | $ git --git-dir /nvme/reference_repos/https---github-com-apache-incubator-airflow-git fetch origin master
  | remote: Enumerating objects: 10, done.
  | remote: Counting objects: 100% (10/10), done.
  | remote: Compressing objects: 100% (7/7), done.
  | remote: Total 10 (delta 1), reused 7 (delta 1), pack-reused 0
  | Unpacking objects: 100% (10/10), 1.35 KiB \| 1.35 MiB/s, done.
  | From github.com:francoiscampbell/buildkite-submodule-test
  | * branch                  master     -> FETCH_HEAD
  | * [new branch]            master     -> master

We can see that it's setting the origin to the wrong URL:

$ git --git-dir /nvme/reference_repos/https---github-com-apache-incubator-airflow-git remote set-url origin git@github.com:francoiscampbell/buildkite-submodule-test.git

and then running a fetch in the submodule mirror directory with the origin of the main repo:

$ git --git-dir /nvme/reference_repos/https---github-com-apache-incubator-airflow-git fetch origin master
...
From github.com:francoiscampbell/buildkite-submodule-test

@francoiscampbell francoiscampbell force-pushed the dont-set-submodule-mirror-origin branch 2 times, most recently from 1c08d2f to 2a4571c Compare March 8, 2023 18:26
@francoiscampbell
Copy link
Contributor Author

Hey @jonahbull since you wrote the original submodule mirror repo implementation, do you think this makes sense?

@jonahbull
Copy link
Contributor

Hey @francoiscampbell I think you've got the right idea here, sorry for the unintended behavior!

@francoiscampbell francoiscampbell marked this pull request as ready for review June 5, 2023 20:17
@francoiscampbell francoiscampbell force-pushed the dont-set-submodule-mirror-origin branch from 2a4571c to e4d77e9 Compare June 5, 2023 20:17
@francoiscampbell
Copy link
Contributor Author

Rebased on the latest main. I've tested this internally and it has the intended effect (the origin remote in the submodule's mirror repo remains correct and the git rev-parse calls for b.Commit don't get emitted in the submodule's mirror repo, where they would fail anyways).

I'm not sure how to unit/integration test this change, any pointers would be appreciated.

Copy link
Contributor

@triarius triarius left a comment

Choose a reason for hiding this comment

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

Sorry we took so long to get to this @francoiscampbell. It looks good to us. Thanks for fixing it!

@triarius triarius merged commit 5d9f8e8 into buildkite:main Jun 14, 2023
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.

3 participants