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

Unable to write back to git helm values, key not found in the map #877

Open
mimartin12 opened this issue Oct 1, 2024 · 9 comments
Open
Labels
bug Something isn't working helm

Comments

@mimartin12
Copy link

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"
@mimartin12 mimartin12 added the bug Something isn't working label Oct 1, 2024
@chengfang chengfang added the helm label Oct 1, 2024
@chengfang
Copy link
Collaborator

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.

@mimartin12
Copy link
Author

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.

@chengfang
Copy link
Collaborator

The fix is in the current master branch, and will be included in the next release (0.15.0).

@mimartin12
Copy link
Author

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!

@chengfang
Copy link
Collaborator

chengfang commented Oct 3, 2024

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.

@mimartin12
Copy link
Author

Oh yeah, just something I can test with is great. Looking forward to 0.15.0!

@Dimitris-Mil
Copy link

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.

@chengfang
Copy link
Collaborator

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?

@Dimitris-Mil
Copy link

Dimitris-Mil commented Nov 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working helm
Projects
None yet
Development

No branches or pull requests

3 participants