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

Avoid clashes when working in parallel on the same repo #229

Closed
girafi opened this issue Jun 18, 2024 · 2 comments · Fixed by #231
Closed

Avoid clashes when working in parallel on the same repo #229

girafi opened this issue Jun 18, 2024 · 2 comments · Fixed by #231
Assignees
Labels

Comments

@girafi
Copy link

girafi commented Jun 18, 2024

TL;DR: Please git pull the branch before pushing it, to avoid clashes of parallel usage

Developers of our solution team are big fans of gitopscli and create-preview.
A consequence of that is, that there is a a lot of activity in our config-repo, as each push to a branch creates a preview environment to run tests against it.
Unfortunately parallel preview creation is currently crashing many times.
Because while Job A is cloning the repo (takes 30-40 seconds), Job B may commit its preview configs onto master.
Then when Job A wants to push its changes, a git error appears like this: "Updates were rejected because the remote contains work that you do have locally"

10:43:43  + gitopscli create-preview --git-provider-url https://bitbucket.balgroupit.com/ --git-user customer-contact-devops-user --git-email ****@balgroupit.com --organisation CIP --repository-name mybaloise-api --preview-id 93b81dce3a794ca0d3aca4ae2fb8bb5a24d85c22_CI --git-hash 23140757b95b0f8da8dabbf3c056a1db4efa69e9
10:44:07  INFO clone: Cloning repository: https://bitbucket.balgroupit.com/scm/dplcaast01/customer-contact-non-prod.git
10:44:17  INFO __create_preview_from_template_if_not_existing: Create new folder for preview: mybaloise-api-65c6c2dc-preview
....
10:44:18  INFO push: Pushing branch: master
10:44:18  ERROR main: Error pushing branch 'master' to origin: 
10:44:18    stderr: 'To https://bitbucket.balgroupit.com/scm/dplcaast01/customer-contact-non-prod.git
10:44:18   ! [rejected]            master -> master (fetch first)
10:44:18  error: failed to push some refs to 'https://bitbucket.balgroupit.com/scm/dplcaast01/customer-contact-non-prod.git'
10:44:18  hint: Updates were rejected because the remote contains work that you do
10:44:18  hint: not have locally. This is usually caused by another repository pushing
10:44:18  hint: to the same ref. You may want to first integrate the remote changes
10:44:18  hint: (e.g., 'git pull ...') before pushing again.

Proposal is to add "git pull --no-rebase" to this line here:
https://github.com/baloise/gitopscli/blame/0e9b8de52d29812990337e3d85d978e899a2706e/gitopscli/commands/create_preview.py#L104

christiansiegel added a commit that referenced this issue Jul 10, 2024
Resolves #229

If another user pushes changes to the remote repo after gitopscli has cloned it,
the subsequent push will fail. Alliviate this problem by pulling and rebasing
local changes on top of any remote changes just before pushing.:

For the case of creating a new branch (for a PR), the pull is skipped because
it would fail due to the missing remote branch.
@christiansiegel christiansiegel self-assigned this Jul 10, 2024
Copy link

🎉 This issue has been resolved in version 5.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@girafi
Copy link
Author

girafi commented Jul 15, 2024

Thanks a bunch @christiansiegel !

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

Successfully merging a pull request may close this issue.

2 participants