From 543858f7862f3abc76554afa510d438e7c2c8cf5 Mon Sep 17 00:00:00 2001 From: Matt Hughes Date: Wed, 17 Apr 2024 13:14:59 +0100 Subject: [PATCH] fix: Pass logger to differ in diff command So that log messages are propagated up, this caused issues for me when trying to diagnose an issue linked to issue #17811. I've just copied the approach used e.g. in `controller/appcontroller.go` when calling `argodiff.NewDiffConfigBuilder`. Sample output before this change: $ argocd --loglevel debug --server argocd-system.dev.aws.uw.systems app diff dev-enablement/dev-enablement ===== apps/Deployment dev-enablement/go-docs ====== 272c272 < cpu: "0" --- > cpu: 0m 275c275 < cpu: "0" --- > cpu: 0m Output with this change: $ argocd --loglevel debug --server argocd-system.dev.aws.uw.systems app diff dev-enablement/dev-enablement INFO[0000] Could not unmarshal to object of type apps/v1, Kind=Deployment: json: unknown field "restartPolicy" INFO[0000] Could not unmarshal to object of type apps/v1, Kind=Deployment: json: unknown field "restartPolicy" ===== apps/Deployment dev-enablement/go-docs ====== 272c272 < cpu: "0" --- > cpu: 0m 275c275 < cpu: "0" --- > cpu: 0m INFO[0000] Could not create new object of type argoproj.io/v1alpha1, Kind=Application: no kind "Application" is registered for version "argoproj.io/v1alpha1" in scheme "pkg/runtime/scheme.go:100" INFO[0000] Could not create new object of type argoproj.io/v1alpha1, Kind=Application: no kind "Application" is registered for version "argoproj.io/v1alpha1" in scheme "pkg/runtime/scheme.go:100" INFO[0000] Could not create new object of type traefik.containo.us/v1alpha1, Kind=IngressRoute: no kind "IngressRoute" is registered for version "traefik.containo.us/v1alpha1" in scheme "pkg/runtime/scheme.go:100" INFO[0000] Could not create new object of type traefik.containo.us/v1alpha1, Kind=IngressRoute: no kind "IngressRoute" is registered for version "traefik.containo.us/v1alpha1" in scheme "pkg/runtime/scheme.go:100" INFO[0000] Could not create new object of type traefik.containo.us/v1alpha1, Kind=IngressRoute: no kind "IngressRoute" is registered for version "traefik.containo.us/v1alpha1" in scheme "pkg/runtime/scheme.go:100" INFO[0000] Could not create new object of type traefik.containo.us/v1alpha1, Kind=IngressRoute: no kind "IngressRoute" is registered for version "traefik.containo.us/v1alpha1" in scheme "pkg/runtime/scheme.go:100" Signed-off-by: Matt Hughes --- cmd/argocd/commands/app.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/argocd/commands/app.go b/cmd/argocd/commands/app.go index 0bfa8a72428010..0f9d8a3e9ef727 100644 --- a/cmd/argocd/commands/app.go +++ b/cmd/argocd/commands/app.go @@ -53,6 +53,7 @@ import ( "github.com/argoproj/argo-cd/v2/util/manifeststream" "github.com/argoproj/argo-cd/v2/util/templates" "github.com/argoproj/argo-cd/v2/util/text/label" + logutils "github.com/argoproj/argo-cd/v2/util/log" ) // NewApplicationCommand returns a new instance of an `argocd app` command @@ -1309,6 +1310,7 @@ func findandPrintDiff(ctx context.Context, app *argoappv1.Application, proj *arg WithDiffSettings(app.Spec.IgnoreDifferences, overrides, ignoreAggregatedRoles). WithTracking(argoSettings.AppLabelKey, argoSettings.TrackingMethod). WithNoCache(). + WithLogger(logutils.NewLogrusLogger(logutils.NewWithCurrentConfig())). Build() errors.CheckError(err) diffRes, err := argodiff.StateDiff(item.live, item.target, diffConfig)