Skip to content

Conversation

@will4j
Copy link
Contributor

@will4j will4j commented Aug 9, 2025

I have a multi sources Application like below

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  annotations:
    argocd-image-updater.argoproj.io/write-back-method: git
    argocd-image-updater.argoproj.io/write-back-target: helmvalues:/image-updater/.argocd-source-xyz-app-test.yaml
    argocd-image-updater.argoproj.io/git-repository: https://github.com/abc/xyz
    argocd-image-updater.argoproj.io/git-branch: release/prod
    argocd-image-updater.argoproj.io/image-list: client=harbor.abc.com/xyz-client,job=harbor.abc.com/xyz-job
    argocd-image-updater.argoproj.io/job.allow-tags: regexp:^test-sha-[0-9a-f]{7}$
    argocd-image-updater.argoproj.io/job.helm.image-tag: xyzJob.image.tag
    argocd-image-updater.argoproj.io/job.update-strategy: newest-build
    argocd-image-updater.argoproj.io/client.allow-tags: regexp:^test-sha-[0-9a-f]{7}$
    argocd-image-updater.argoproj.io/client.helm.image-tag: xyzClient.image.tag
    argocd-image-updater.argoproj.io/client.update-strategy: newest-build
  name: xyz-app-test
  namespace: argocd
spec:
  sources:
  - chart: xyz-app
    helm:
      ignoreMissingValueFiles: true
      releaseName: xyz-app
      valueFiles:
      - $values/apps-base/xyz-app/values-test.yaml
      - $values/image-updater/.argocd-source-xyz-app-test.yaml
    repoURL: harbor.abc.com/charts
    targetRevision: 1.0.0
  - ref: values
    repoURL: https://github.com/abc/abc-deploy
    targetRevision: release/prod

after deploy this app, argocd image updater will show failed logs

level=info msg="git checkout --force release/prod" dir=/tmp/git-xyz-app-test execID=49aae
level=info msg=Trace args="[git checkout --force release/prod]" dir=/tmp/git-xyz-app-test operation_name="exec git" time_ms=38.132636
level=info msg="git clean -ffdx" dir=/tmp/git-xyz-app-test execID=9f728
level=info msg=Trace args="[git clean -ffdx]" dir=/tmp/git-xyz-app-test operation_name="exec git" time_ms=2.081065
level=error msg="Could not update application spec: failed to set image parameter version value: unexpected type  for root" application=git-xyz-app-test

I found this is because when target file not exists, it will use nil originalData to marshal params override, which will failed when try to set helm value to wrong kind of yaml Node, like it explained here.

and the call entry is like below:

if targetExists {
originalData, err = os.ReadFile(targetFile)
if err != nil {
return err, false
}
override, err = marshalParamsOverride(app, originalData)
if err != nil {
return
}
if string(originalData) == string(override) {
logCtx.Debugf("target parameter file and marshaled data are the same, skipping commit.")
return nil, true
}
} else {
override, err = marshalParamsOverride(app, nil)
if err != nil {
return
}
}

This pr is intend to solve the problem by create a empy yaml.DocumentNode when originalData is nil, Therefore commit a new file to git when target file is not exists.

a new files likes:

# auto generated by argocd image updater

xyzClient:
  image:
    tag: test-sha-c103907
xyzJob:
  image:
    tag: test-sha-f19def5

This may solve #1108 .

@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.52%. Comparing base (e6c82f2) to head (496c5bf).

Files with missing lines Patch % Lines
pkg/argocd/update.go 85.71% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1212      +/-   ##
==========================================
+ Coverage   63.33%   63.52%   +0.18%     
==========================================
  Files          23       23              
  Lines        3175     3191      +16     
==========================================
+ Hits         2011     2027      +16     
  Misses       1054     1054              
  Partials      110      110              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chengfang
Copy link
Collaborator

I noticed your target helm values file is named ".argocd-source-xyz-app-test.yaml". Do you still see the problem when the name does not start with .argocd-source-*? This prefix is used as the default target for git write-back.

@will4j
Copy link
Contributor Author

will4j commented Aug 12, 2025

I noticed your target helm values file is named ".argocd-source-xyz-app-test.yaml". Do you still see the problem when the name does not start with .argocd-source-*? This prefix is used as the default target for git write-back.

actually the pattern of filename is not limited here, I just named with prefix .argocd-source to identity these files auto generated by argo, which means argocd image updater here.


Further more, as I understand, .argocd-source-*.yaml file is the extra parameter file auto recognized by argocd, and it should placed at the source root dir, which is the dir where the chart is pulled and extracted to in my multiple sources application. so none of .argocd-source-*.yaml files in the ref repo(which is invisible when generate manifests of the helm chart) will take effect, it takes me lots of time to find out.

So in another case, if remove argocd-image-updater.argoproj.io/write-back-target annotation and argocd image updater do successfully generate a .argocd-source-*.yaml file to the ref repo, which is the default behavior, it will not work as the file not used when rendering helm chart, currently i don't see a way to let .argocd-source-*.yaml file to work with remote helm repo source without extra user config, that's why I add .argocd-source-xyz-app-test.yaml to the valuesFiles of helm chart repo in my application.

@will4j will4j force-pushed the feature/allow-no-exists-helmvalues-file branch from 93ab139 to c1f99cc Compare August 15, 2025 08:31
@chengfang chengfang force-pushed the feature/allow-no-exists-helmvalues-file branch from c1f99cc to 496c5bf Compare August 15, 2025 14:37
@chengfang chengfang merged commit cc9f71b into argoproj-labs:master Aug 15, 2025
11 checks passed
dkarpele pushed a commit to dkarpele/argocd-image-updater that referenced this pull request Aug 26, 2025
Signed-off-by: William Wang <[email protected]>
(cherry picked from commit cc9f71b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants