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

Wrong default write branch is used in multi-source app #932

Open
chengfang opened this issue Nov 11, 2024 · 1 comment
Open

Wrong default write branch is used in multi-source app #932

chengfang opened this issue Nov 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@chengfang
Copy link
Collaborator

chengfang commented Nov 11, 2024

Describe the bug
In a multi-source application, when a custom write-back git repo is specified, but the git branch is not specified, image-updater selects the branch from the primary source, instead of the targetRevison of the chosen source.

To Reproduce

    argocd-image-updater.argoproj.io/nginx.helm.image-name: image.repository
    argocd-image-updater.argoproj.io/nginx.helm.image-tag: image.tag
    argocd-image-updater.argoproj.io/git-repository: https://github.com/chengfang/image-updater-examples.git
    # argocd-image-updater.argoproj.io/git-branch: main
    argocd-image-updater.argoproj.io/write-back-method: git:secret:argocd/git-creds
    argocd-image-updater.argoproj.io/write-back-target: helmvalues:/write-helmvalues/source2/values.yaml

Expected behavior
the branch of the specified source repo is selected as the default write-back git branch, unless overridden with git-branch annotation.

Additional context
The workaround is to always specify git-branch annotation.

Version
v0.15.1

Logs

INFO[0001] Committing 1 parameter update(s) for application write-helmvalues  application=write-helmvalues
INFO[0001] Initializing https://github.com/chengfang/image-updater-examples.git to /var/folders/sc/bblzy4t15995h2zs1s4bztc00000gn/T/git-write-helmvalues2791939777
INFO[0001] git fetch origin 18.2.3 --force --prune --depth 1  dir=/var/folders/sc/bblzy4t15995h2zs1s4bztc00000gn/T/git-write-helmvalues2791939777 execID=a6d31
ERRO[0002] `git fetch origin 18.2.3 --force --prune --depth 1` failed exit status 128: fatal: couldn't find remote ref 18.2.3  execID=a6d31
INFO[0002] Trace                                         args="[git fetch origin 18.2.3 --force --prune --depth 1]" dir=/var/folders/sc/bblzy4t15995h2zs1s4bztc00000gn/T/git-write-helmvalues2791939777 operation_name="exec git" time_ms=284.635333
ERRO[0002] Could not update application spec: `git fetch origin 18.2.3 --force --prune --depth 1` failed exit status 128: fatal: couldn't find remote ref 18.2.3  application=write-helmvalues
INFO[0002] Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=0 errors=1
@chengfang chengfang added the bug Something isn't working label Nov 11, 2024
@chengfang
Copy link
Collaborator Author

chengfang commented Nov 12, 2024

// The branch to checkout is either a configured branch in the write-back
// config, or taken from the application spec's targetRevision. If the
// target revision is set to the special value HEAD, or is the empty
// string, we'll try to resolve it to a branch name.
checkOutBranch := getApplicationSource(app).TargetRevision

Need to improve this block to choose a source matching the git-repository annotation value. If not found, then default to the primary source.

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

No branches or pull requests

1 participant