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

Git write back: targetRevision:HEAD will assume 'master' #518

Open
kehao95 opened this issue Jan 10, 2023 · 2 comments · May be fixed by #669
Open

Git write back: targetRevision:HEAD will assume 'master' #518

kehao95 opened this issue Jan 10, 2023 · 2 comments · May be fixed by #669
Labels
bug Something isn't working

Comments

@kehao95
Copy link

kehao95 commented Jan 10, 2023

Describe the bug
When the Application's targetRevision is set to HEAD,
argocd-image-updater will try to check out and write back to master branch with git checkout --force master.
Which will fail when the default branch is not master on GitHub.

Especially:

By default, GitHub names the default branch main in any new repository.

However, this won't be an issue for ArgoCD, which seems correctly find the HEAD ref to default branch.

To Reproduce
create new GitHub repo with default branch as main
create application using that repo, with targetRevision set to HEAD

Version
v0.12.0

Logs

msg="`git checkout --force master` failed exit status 1: error: pathspec 'master' did not match any file(s) known to git" execID=5a0c8

full log

level=info msg="Setting new image to xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@sha256:4bd61a7ab7ba4c4a36bb57e82423be3f3d39df7d5f1d15174815adbb6994a8cb" alias=message-tracker application=my-app image_name=prod-my-app-image image_tag=dummy registry=xxxx.dkr.ecr.us-east-1.amazonaws.com
level=info msg="Successfully updated image 'xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@dummy' to 'xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@sha256:4bd61a7ab7ba4c4a36bb57e82423be3f3d39df7d5f1d15174815adbb6994a8cb', but pending spec update (dry run=true)" alias=message-tracker application=my-app image_name=prod-my-app-image image_tag=dummy registry=xxxx.dkr.ecr.us-east-1.amazonaws.com
level=info msg="Dry run - not commiting 1 changes to application" application=my-app
level=info msg="Finished cache warm-up, pre-loaded 1 meta data entries from 2 registries"
level=info msg="Starting image update cycle, considering 14 annotated application(s) for update"
level=info msg="Setting new image to xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@sha256:4bd61a7ab7ba4c4a36bb57e82423be3f3d39df7d5f1d15174815adbb6994a8cb" alias=message-tracker application=my-app image_name=prod-my-app-image image_tag=dummy registry=xxxx.dkr.ecr.us-east-1.amazonaws.com
level=info msg="Successfully updated image 'xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@dummy' to 'xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@sha256:4bd61a7ab7ba4c4a36bb57e82423be3f3d39df7d5f1d15174815adbb6994a8cb', but pending spec update (dry run=false)" alias=message-tracker application=my-app image_name=prod-my-app-image image_tag=dummy registry=xxxx.dkr.ecr.us-east-1.amazonaws.com
level=info msg="Committing 1 parameter update(s) for application my-app" application=my-app
level=info msg="Starting configmap/secret informers"
level=info msg="Configmap/secret informer synced"
level=info msg="Initializing git@github.com:my/repo.git to /tmp/git-my-app77718050"
level=info msg="secrets informer cancelled"
level=info msg="rm -rf /tmp/git-my-app77718050" dir= execID=77fa7
level=info msg="configmap informer cancelled"
level=info msg=Trace args="[rm -rf /tmp/git-my-app77718050]" dir= operation_name="exec rm" time_ms=1.626754
level=info msg="git fetch origin --tags --force" dir=/tmp/git-my-app77718050 execID=35946
level=info msg=Trace args="[git fetch origin --tags --force]" dir=/tmp/git-my-app77718050 operation_name="exec git" time_ms=455.113817
level=info msg="git config user.name argocd-image-updater" dir=/tmp/git-my-app77718050 execID=95c9b
level=info msg=Trace args="[git config user.name argocd-image-updater]" dir=/tmp/git-my-app77718050 operation_name="exec git" time_ms=1.006842
level=info msg="git config user.email noreply@argoproj.io" dir=/tmp/git-my-app77718050 execID=1ea65
level=info msg=Trace args="[git config user.email noreply@argoproj.io]" dir=/tmp/git-my-app77718050 operation_name="exec git" time_ms=0.914697
level=info msg="git symbolic-ref HEAD" dir=/tmp/git-my-app77718050 execID=38ab8
level=info msg=Trace args="[git symbolic-ref HEAD]" dir=/tmp/git-my-app77718050 operation_name="exec git" time_ms=0.809369
level=info msg="git checkout --force master" dir=/tmp/git-my-app77718050 execID=0b651
level=info msg="resolved remote default branch to 'master' and using that for operations" application=my-app
level=error msg="`git checkout --force master` failed exit status 1: error: pathspec 'master' did not match any file(s) known to git" execID=0b651
level=info msg=Trace args="[git checkout --force master]" dir=/tmp/git-my-app77718050 operation_name="exec git" time_ms=0.963177
level=error msg="Could not update application spec: `git checkout --force master` failed exit status 1: error: pathspec 'master' did not match any file(s) known to git" application=my-app
level=info msg="Processing results: applications=14 images_considered=1 images_skipped=13 images_updated=0 errors=1"
level=info msg="Starting image update cycle, considering 14 annotated application(s) for update"
level=info msg="Setting new image to xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@sha256:4bd61a7ab7ba4c4a36bb57e82423be3f3d39df7d5f1d15174815adbb6994a8cb" alias=message-tracker application=my-app image_name=prod-my-app-image image_tag=dummy registry=xxxx.dkr.ecr.us-east-1.amazonaws.com
level=info msg="Successfully updated image 'xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@dummy' to 'xxxx.dkr.ecr.us-east-1.amazonaws.com/prod-my-app-image@sha256:4bd61a7ab7ba4c4a36bb57e82423be3f3d39df7d5f1d15174815adbb6994a8cb', but pending spec update (dry run=false)" alias=message-tracker application=my-app image_name=prod-my-app-image image_tag=dummy registry=xxxx.dkr.ecr.us-east-1.amazonaws.com
level=info msg="Committing 1 parameter update(s) for application my-app" application=my-app
level=info msg="Starting configmap/secret informers"
level=info msg="Configmap/secret informer synced"
level=info msg="Initializing git@github.com:my/repo.git to /tmp/git-my-app3522197020"
level=info msg="secrets informer cancelled"
level=info msg="configmap informer cancelled"
level=info msg="rm -rf /tmp/git-my-app3522197020" dir= execID=15bd0
level=info msg=Trace args="[rm -rf /tmp/git-my-app3522197020]" dir= operation_name="exec rm" time_ms=0.626327
level=info msg="git fetch origin --tags --force" dir=/tmp/git-my-app3522197020 execID=0e98a
level=info msg=Trace args="[git fetch origin --tags --force]" dir=/tmp/git-my-app3522197020 operation_name="exec git" time_ms=448.326862
level=info msg="git config user.name argocd-image-updater" dir=/tmp/git-my-app3522197020 execID=36bda
level=info msg=Trace args="[git config user.name argocd-image-updater]" dir=/tmp/git-my-app3522197020 operation_name="exec git" time_ms=0.972059
level=info msg="git config user.email noreply@argoproj.io" dir=/tmp/git-my-app3522197020 execID=9014b
level=info msg=Trace args="[git config user.email noreply@argoproj.io]" dir=/tmp/git-my-app3522197020 operation_name="exec git" time_ms=0.937039
level=info msg="git symbolic-ref HEAD" dir=/tmp/git-my-app3522197020 execID=3ddfb
level=info msg=Trace args="[git symbolic-ref HEAD]" dir=/tmp/git-my-app3522197020 operation_name="exec git" time_ms=0.779517
level=info msg="resolved remote default branch to 'master' and using that for operations" application=my-app
level=info msg="git checkout --force master" dir=/tmp/git-my-app3522197020 execID=5a0c8
level=error msg="`git checkout --force master` failed exit status 1: error: pathspec 'master' did not match any file(s) known to git" execID=5a0c8
level=info msg=Trace args="[git checkout --force master]" dir=/tmp/git-my-app3522197020 operation_name="exec git" time_ms=1.028894
level=error msg="Could not update application spec: `git checkout --force master` failed exit status 1: error: pathspec 'master' did not match any file(s) known to git" application=my-app
level=info msg="Processing results: applications=14 images_considered=1 images_skipped=13 images_updated=0 errors=1"
@kehao95 kehao95 added the bug Something isn't working label Jan 10, 2023
@jannfis
Copy link
Contributor

jannfis commented Jan 22, 2023

Oops. Seems that the symbolic-ref is not resolving to the remote's default branch, but to the one used by git init (or rather, go-git's version of it) locally.

While we'll be looking for an alternative way to get the remote's default branch to resolve HEAD to, I think as a workaround you can specify the branch to use manually via the argocd-image-updater.argoproj.io/git-branch annotation.

@nahum-landa
Copy link

same issue :(
will really help if you resolve this as main branch names are not 100% consistent here.

@gugu gugu linked a pull request Jan 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants