argoproj-labs / argocd-image-updater

Automatic container image update for Argo CD
https://argocd-image-updater.readthedocs.io/en/stable/
Apache License 2.0
1.27k stars 261 forks source link

Could not update application spec: could not get creds for repo '': credentials for '' are not configured in Argo CD settings #683

Open clambin opened 8 months ago

clambin commented 8 months ago

Describe the bug I have an Application in ArgoCD with the following configuration:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: ledswitcher
  namespace: argocd
  annotations:
    argocd-image-updater.argoproj.io/write-back-method: git
    argocd-image-updater.argoproj.io/write-back-target: kustomization
    argocd-image-updater.argoproj.io/image-list: ledswitcher=ghcr.io/clambin/ledswitcher
    argocd-image-updater.argoproj.io/ledswitcher.update-strategy: latest
spec:
  destination:
    namespace: infra
    server: https://kubernetes.default.svc
  project: default
  sources:
  - path: argocd/conf/infra/ledswitcher/resources
    repoURL: https://github.com/clambin/gitops
    targetRevision: HEAD
  syncPolicy:
    automated:
      prune: true
    syncOptions:
    - CreateNamespace=true

This leads to a DaemonSet in argocd/conf/infra/ledswitcher/resources:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ledswitcher
  labels:
    app: ledswitcher
spec:
    spec:
      containers:
      - name: ledswitcher
        image: ghcr.io/clambin/ledswitcher
...

and the image tag is set in a kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- rbac.yaml
- daemonset.yaml
images:
- name: ghcr.io/clambin/ledswitcher
  newTag: sha-ad4c2e3-2024030411003510

Whenever argocd-image-updater tries to update the version, it reports the following error:

time="2024-03-04T19:14:14Z" level=error msg="Could not update application spec: could not get creds for repo '': credentials for '' are not configured in Argo CD settings" application=ledswitcher

Additional context Similar setups exist in my cluster for deployments. Those work without any problem. The only difference that I found is that in this case, it's trying to update a daemonset, rather than a deployment.

Version quay.io/argoprojlabs/argocd-image-updater:v0.12.2

Logs

time="2024-03-04T19:14:14Z" level=info msg="Setting new image to ghcr.io/clambin/ledswitcher:sha-092c297-2024030415280045" alias=ledswitcher application=ledswitcher image_name=clambin/ledswitcher image_tag=sha-ad4c2e3-2024030411003510 registry=ghcr.io
time="2024-03-04T19:14:14Z" level=info msg="Successfully updated image 'ghcr.io/clambin/ledswitcher:sha-ad4c2e3-2024030411003510' to 'ghcr.io/clambin/ledswitcher:sha-092c297-2024030415280045', but pending spec update (dry run=false)" alias=ledswitcher application=ledswitcher image_name=clambin/ledswitcher image_tag=sha-ad4c2e3-2024030411003510 registry=ghcr.io
time="2024-03-04T19:14:14Z" level=info msg="Committing 1 parameter update(s) for application ledswitcher" application=ledswitcher
time="2024-03-04T19:14:14Z" level=info msg="Starting configmap/secret informers"
time="2024-03-04T19:14:14Z" level=info msg="Configmap/secret informer synced"
time="2024-03-04T19:14:14Z" level=error msg="Could not update application spec: could not get creds for repo '': credentials for '' are not configured in Argo CD settings" application=ledswitcher
time="2024-03-04T19:14:14Z" level=info msg="secrets informer cancelled"
time="2024-03-04T19:14:14Z" level=info msg="configmap informer cancelled"
clambin commented 8 months ago

I accidentally found that this can also happen for a Deployment. The root cause seems to be related to using multiple sources in your application:

Does not work (even if there's only one source):

  sources:
  - path: argocd/conf/infra/ledswitcher/resources
    repoURL: https://github.com/clambin/gitops
    targetRevision: HEAD

Works:

  source:
    path: argocd/conf/infra/ledswitcher/resources
    repoURL: https://github.com/clambin/gitops
    targetRevision: HEAD

In the first confirmation, image updates are broken with the error in the first comment. If we change it to the 2nd version (one source, rather than multiple), then image upgrades works fine.