From 2367f835cc0486eddea396616203c055c8fcfd81 Mon Sep 17 00:00:00 2001 From: Matt Hughes <128392218+matthewhughes-uw@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:24:56 +0100 Subject: [PATCH] fix: Pass logger to differ in diff command (#17871) 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..0c0659b38302f7 100644 --- a/cmd/argocd/commands/app.go +++ b/cmd/argocd/commands/app.go @@ -50,6 +50,7 @@ import ( "github.com/argoproj/argo-cd/v2/util/git" "github.com/argoproj/argo-cd/v2/util/grpc" argoio "github.com/argoproj/argo-cd/v2/util/io" + logutils "github.com/argoproj/argo-cd/v2/util/log" "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" @@ -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)