Skip to content

Conversation

@dkarpele
Copy link
Collaborator

@dkarpele dkarpele commented Jun 21, 2025

  • Change signatures and implementations for GetApplication, ListApplications, UpdateSpec for type k8sClient. These functions now rely on controller-runtime client.Client.
  • Constructor NewK8SClient was simplified.
  • ArgoCD tests were updated.
  • ListApplications misses labelSelector feature (will be added in GITOPS-7119). 
  • GetApplication misses NamePattern feature (will be added in GITOPS-7119).
  • bin/controller-gen* were removed because they should be generated on each machine separately depending on arch, os, etc.
  • I propose to deprecate ArgoCD client. See GITOPS-7123.

Log looks like this. Have a look at logger=warmup-cache or logger=reconcile that were propagated to the respectful functions.

time="2025-06-21T18:09:22+02:00" level=info msg="argocd-image-updater v9.9.99+unknown starting [loglevel:TRACE, interval:2m0s, healthport:8080]"
time="2025-06-21T18:09:22+02:00" level=warning msg="commit message template at /app/config/commit.template does not exist, using default"
time="2025-06-21T18:09:22+02:00" level=debug msg="Successfully parsed commit message template"
time="2025-06-21T18:09:22+02:00" level=warning msg="Registry configuration at /app/config/registries.conf could not be read: stat /app/config/registries.conf: no such file or directory -- using default configuration"
time="2025-06-21T18:09:22+02:00" level=debug msg="Starting askpass server"
time="2025-06-21T18:09:22+02:00" level=info msg="ArgoCD configuration: [apiKind=kubernetes, server=argocd-server.default, auth_token=false, insecure=false, grpc_web=false, plaintext=false]"
time="2025-06-21T18:09:22+02:00" level=info msg="webhook server is disabled" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=controller-setup
time="2025-06-21T18:09:22+02:00" level=info msg="Adding cache warmer to the manager." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=controller-setup
time="2025-06-21T18:09:22+02:00" level=info msg="starting manager" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=controller-setup
time="2025-06-21T18:09:22+02:00" level=info msg="starting server" addr="[::]:8081" name="health probe"
time="2025-06-21T18:09:22+02:00" level=debug msg="Caches are synced. Warming up image cache..." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=debug msg="Listing all ImageUpdater CRs before starting manager..." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=info msg="Starting EventSource" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater source="kind source: *v1alpha1.ImageUpdater"
time="2025-06-21T18:09:22+02:00" level=info msg="Starting Controller" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater
time="2025-06-21T18:09:22+02:00" level=info msg="Controller runtime logger initialized." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=controller-setup setAppLogLevel=trace
time="2025-06-21T18:09:22+02:00" level=info msg="Starting workers" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater worker count=1
time="2025-06-21T18:09:22+02:00" level=debug msg="Found 1 ImageUpdater CRs to process for cache warm-up." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=debug msg="Found CR imageupdater-sample-short, namespace=default" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=debug msg="Attempting to fetch application 'image-updater-001' in namespace 'argocd-image-updater-e2e'" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=debug msg="Reconciliation for default/imageupdater-sample-short is waiting for cache warm-up to complete..." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater cr_name=imageupdater-sample-short cr_namespace=default logger=reconcile
time="2025-06-21T18:09:22+02:00" level=debug msg="Application 'image-updater-001' in namespace 'argocd-image-updater-e2e' found" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=debug msg="Attempting to fetch application 'image-updater-001-1' in namespace 'argocd-image-updater-e2e'" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=warning msg="Application 'image-updater-001-1' in namespace 'argocd-image-updater-e2e' specified in ImageUpdater 'imageupdater-sample-short' was not found, skipping." controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache
time="2025-06-21T18:09:22+02:00" level=debug msg="Applications listed: 1" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater logger=warmup-cache

@dkarpele dkarpele changed the title night 21.6 commit Recreate ArgoCD interface for accessing Argo CD functions. Jun 21, 2025
@dkarpele dkarpele marked this pull request as ready for review June 21, 2025 21:05
@chengfang
Copy link
Collaborator

I've merged the other log-related PR into master, and rebased crd branch, hence the conflicts in this PR. Can you rebase your pr branch on the latest crd branch?

@dkarpele dkarpele force-pushed the dk-GITOPS-6156-6 branch 2 times, most recently from a045d0f to b4be96a Compare June 24, 2025 11:15
@dkarpele
Copy link
Collaborator Author

Thanks Cheng! I've updated go.mod with the new version of registry-scanner and changed commit message.

kc := &ImageUpdaterKubernetesClient{}
kc.KubeClient = kube.NewKubernetesClient(ctx, clientset, namespace)
kc.ApplicationsClientset = applicationsClientset
kc.ApplicationsClientSet = applicationsClientset
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clientset is a convention used in many other places in argo-cd and kubernetes, I think we should keep it.

cmd/run.go Outdated
argocd.GetPrintableInterval(cfg.CheckInterval),
argocd.GetPrintableHealthPort(cfg.HealthPort),
setupLogger.Info("starting",
"app", version.BinaryName()+version.Version(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no space between binary name and version. How about:
version.BinaryName(), version.Version(), which should produce something like "argocd-image-updater: v9.9.0"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to:

setupLogger.Info("starting",
"app", version.BinaryName()+": "+version.Version(),

that produces

time="2025-06-25T11:53:55+02:00" level=info msg=starting app="argocd-image-updater: v9.9.99+unknown" controller=imageupdater controllerGroup=argocd-image-updater.argoproj.io controllerKind=ImageUpdater healthport=8080 interval=2m0s logger=controller-setup loglevel=TRACE


if tpl, err := template.New("commitMessage").Parse(commitMessageTpl); err != nil {
log.Fatalf("could not parse commit message template: %v", err)
setupLogger.Error(err, "could not parse commit message template")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return err here? Previously log.Fatalf would exit after logging, but setupLogger.Error() does not exit.

cfg.KubeClient, err = argocd.GetKubeConfig(ctx, cfg.ArgocdNamespace, kubeConfig)
if err != nil {
log.Fatalf("could not create K8s client: %v", err)
setupLogger.Error(err, "could not create K8s client")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return err here? Previously log.Fatalf would exit after logging, but setupLogger.Error() does not exit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I forgot about it in few places.

}

// Type of the application
// ApplicationType Type of the applicationdisableKubernetes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"disableKubernetes" doesn't seem to belong here.

// ListApplications returns a list of all application names that the API user
// has access to.
func (client *argoCD) ListApplications(labelSelector string) ([]v1alpha1.Application, error) {
func (client *argoCD) ListApplications(ctx context.Context, cr *api.ImageUpdater, labelSelector string) ([]v1alpha1.Application, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the param ctx be used below in line 334, instead of context.TODO()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Updated.
Although I propose to remove this method for argoCD client. See GITOPS-7123.

@chengfang
Copy link
Collaborator

also pls resolve lint errors in some tests.

- Change signatures and implementations for GetApplication, ListApplications, UpdateSpec for type k8sClient. These functions now rely on controller-runtime client.Client.
- Constructor NewK8SClient was simplified.
- ArgoCD tests were updated.
- `ListApplications` misses `labelSelector` feature (will be added in GITOPS-7119).
- `GetApplication` misses `NamePattern` feature (will be added in GITOPS-7119).
- bin/controller-gen* files were removed because they should be generated on each machine separately depending on arch, os, etc.
- update go.mod

Signed-off-by: Denis Karpelevich <[email protected]>
@dkarpele dkarpele requested a review from chengfang June 25, 2025 10:22
@chengfang chengfang merged commit d304605 into argoproj-labs:crd Jun 25, 2025
8 of 10 checks passed
dkarpele added a commit to dkarpele/argocd-image-updater that referenced this pull request Jul 21, 2025
dkarpele added a commit to dkarpele/argocd-image-updater that referenced this pull request Aug 9, 2025
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.

2 participants