Skip to content

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

Description

@girafi

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

Activity

  1. added 2 commits that reference this issue on Jul 10, 2024
    0585f73
    22c9b15
  2. github-actions commented on Jul 11, 2024

    @github-actions

    🎉 This issue has been resolved in version 5.9.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  3. girafi commented on Jul 15, 2024

    @girafi
    Author

    Thanks a bunch @christiansiegel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions