argocd-image-updater
argocd-image-updater copied to clipboard
Unable to write back to git helm values, key not found in the map
Describe the bug
When using the git writeback method, image updater is unable to create the file in the branch with the helm value updates with an error:
time="2024-10-01T15:32:52Z" level=error msg="Could not update application spec: failed to set image parameter name value: key component not found in the map" application=test
To Reproduce Steps to reproduce the behavior: Using the annotations:
argocd-image-updater.argoproj.io/image-list: admin=somewhere.azurecr.io/admin:{{.branch}}
argocd-image-updater.argoproj.io/update-strategy: digest
argocd-image-updater.argoproj.io/admin.helm.image-name: component.admin.image.name
argocd-image-updater.argoproj.io/admin.helm.image-tag: component.admin.image.tag
argocd-image-updater.argoproj.io/write-back-method: git
argocd-image-updater.argoproj.io/git-repository: [email protected]:company/admin.git
argocd-image-updater.argoproj.io/write-back-target: 'helmvalues:/envs/{{.branch}}.yaml'
argocd-image-updater.argoproj.io/git-branch: '{{.branch}}'
The Helm chart supports the structure:
component:
admin:
image:
name: somewhere.azurecr.io/admin
tag: dev
Expected behavior A clear and concise description of what you expected to happen.
When a new image is added to the ACR, the updater creates a file /envs/{{.branch}}.yaml on the branch {{.branch}} with the newly set values, component.admin.image.name and component.admin.image.tag.
Additional context Add any other context about the problem here.
It's worth noting, if I create the file manually at /envs/{{.branch}}.yaml and add the structure:
component:
admin:
image:
name: somewhere.azurecr.io/admin
tag: dev
The updates work.
Version
0.14.0
Logs
time="2024-10-01T15:32:52Z" level=error msg="Could not update application spec: failed to set image parameter name value: key component not found in the map" application=test
time="2024-10-01T15:32:52Z" level=info msg="Processing results: applications=1 images_considered=1 images_skipped=0 images_updated=0 errors=1"
time="2024-10-01T15:33:43Z" level=info msg="configmap informer cancelled"
time="2024-10-01T15:33:43Z" level=info msg="secrets informer cancelled"
looks like https://github.com/argoproj-labs/argocd-image-updater/pull/838 should have already fixed it.
In release-0.14 (the version you're testing with), https://github.com/argoproj-labs/argocd-image-updater/blob/release-0.14/pkg/argocd/update.go#L573 is where the error was raised.
In the above PR, this part has been rewritten to handle non-existing file or keys.
looks like #838 should have already fixed it.
In release-0.14 (the version you're testing with), https://github.com/argoproj-labs/argocd-image-updater/blob/release-0.14/pkg/argocd/update.go#L573 is where the error was raised.
In the above PR, this part has been rewritten to handle non-existing file or keys.
Yes, I expect this to just create the file, but that doesn't seem to be the case. It can update an existing values file in the branch, but when pointing the config argocd-image-updater.argoproj.io/write-back-target to a file that doesn't exist just yet, it fails with the error above, time="2024-10-02T16:09:35Z" level=error msg="Could not update application spec: failed to set image parameter name value: key component not found in the map" application=test.
The fix is in the current master branch, and will be included in the next release (0.15.0).
The fix is in the current master branch, and will be included in the next release (0.15.0).
Great! Am I able to get those changes from the latest image tags, so I can test? Thanks!
there is a latest snapshot tag https://quay.io/repository/argoprojlabs/argocd-image-updater?tab=tags but no guarantee of quality. 0.15.0 is forthcoming.
update: 0.15.1 was released on 2024-11-08.
Oh yeah, just something I can test with is great. Looking forward to 0.15.0!
Hello. Any updates on this? I've tried with 0.15.1 and I get a similar error. A difference in the describe case, is that in mine I use multiple images in the image-list annotation and 2 argocd application sources.
I tested write-back to helm value files with this sample https://github.com/chengfang/image-updater-examples/tree/main/write-helmvalues . Can you take a look and suggest how to reproduce the problem with this app?
Thanks for the sample. Apparently the log was a bit misguiding. I had a bad config in one of the allow-tags regexp and didnt get any image tags, which resulted to this error log. Now I made it work with both creating a new file or writing on an existing one. I am using image version 0.15.1 and the argo-cd image updater helm chart