Skip to content

Commit

Permalink
fix: Pass logger to differ in diff command (argoproj#17871)
Browse files Browse the repository at this point in the history
So that log messages are propagated up, this caused issues for me when
trying to diagnose an issue linked to issue argoproj#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 <mhughes@uw.co.uk>
  • Loading branch information
matthewhughes-uw authored and Hariharasuthan99 committed Jun 16, 2024
1 parent a86d0dd commit 6e20d66
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/argocd/commands/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6e20d66

Please sign in to comment.