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

Image Updater continuously force-pushes new commits when checkout branch is specified. #895

Closed
katainaka0503 opened this issue Oct 24, 2024 · 5 comments · Fixed by #911
Closed
Labels
blocker bug Something isn't working

Comments

@katainaka0503
Copy link
Contributor

katainaka0503 commented Oct 24, 2024

Describe the bug
After upgrading to v0.15.0, if pushBranch is not the same as checkOutBranch , argocd image updater continuously force pushes new commits.

To Reproduce

  • Set argocd-image-updater.argoproj.io/git-branch to :image-updater/master/account/{{range .Images}}{{.Name}}-{{.NewTag}}{{end}}

Expected behavior
If there is no change, nothing is pushed.

Additional context

Version
After v0.15.0

Logs

@katainaka0503 katainaka0503 added the bug Something isn't working label Oct 24, 2024
@chengfang
Copy link
Collaborator

maybe related to the changes in PR #882 to fix issues: #673 #879

@chengfang
Copy link
Collaborator

If the updates are the same as existing data, the git commit will be skipped. See https://github.com/argoproj-labs/argocd-image-updater/blob/master/pkg/argocd/git.go#L284 and https://github.com/argoproj-labs/argocd-image-updater/blob/master/pkg/argocd/git.go#L366 . So it's a bit surprising to see pushing new commits with no changes.

@ixxeL2097
Copy link

same behaviour on my side, constantly pushes the same update. Very annoying cause it triggers pipeline each time argocd-image-updater pushes a new commit. Had to rollback to v0.14.0 for now

@chengfang
Copy link
Collaborator

I was able to reproduce it with this sample app https://github.com/chengfang/image-updater-examples/tree/main/push-branch-kustomize

For each update cycle, it force-pushes the same update to the target branch, overwriting the previous update commit in the target git branch.

I think in v0.14.0, the same operation occurred too, but the push just failed to go through. In v0.15.0, with the additional --force option, these pushes succeeded.

With no new updates, the update cycle should skip git-commit or git-push steps. Will look into it more.

@chengfang
Copy link
Collaborator

chengfang commented Oct 31, 2024

When using a custom write-back branch in the form of checkoutBranch:pushBranch, currently in each update cycle, we always create the pushBranch from checkoutBranch, and compare the potential update against the content in the newly created pushBranch, which is the same as checkoutBranch. This works fine if the write-back branch is for one off use for a specific tag of a specific image. But for a branch intended for multiple update cycles, the comparison always shows diff, because the new pushBranch based off checkoutBranch does not contain the latest image data.

One way to fix it is modify the current behaviro such that, if the pushBranch does not exist, we create a new pushBranch from checkoutBranch. If it already exists, I think we should honor it and check out the pushBranch from origin, as opposed to creating a new branch from checkoutBranch, for all subsequent updates. Any thoughts, concerns?

chengfang added a commit to chengfang/argocd-image-updater that referenced this issue Nov 1, 2024
…mmits when checkout branch is specified

Signed-off-by: Cheng Fang <[email protected]>
@jannfis jannfis closed this as completed in 17a57da Nov 1, 2024
chengfang added a commit to chengfang/argocd-image-updater that referenced this issue Nov 8, 2024
…mmits when checkout branch is specified (argoproj-labs#911)

Signed-off-by: Cheng Fang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Something isn't working
Projects
None yet
3 participants