Skip to content

Log panic stack trace as JSON when JSON logging is enabled #20924

@crenshaw-dev

Description

@crenshaw-dev

Summary

When there are panics in Argo CD components today, they're logged as plain text, even if JSON logging is enabled.

Example (manually added a panic for demonstration):

{"built":"1970-01-01T00:00:00Z","commit":"","level":"info","msg":"ArgoCD API Server is starting","namespace":"argocd","port":8080,"time":"2024-11-24T14:54:08-05:00","version":"v99.99.99+unknown"}
panic: yikes

goroutine 1 [running]:
github.com/argoproj/argo-cd/v2/cmd/argocd-server/commands.NewCommand.func1(0x140008d0000?, {0x107c13006?, 0x4?, 0x107c1300a?})
        /Users/mcrenshaw/go/src/github.com/argoproj/argo-cd/cmd/argocd-server/commands/argocd_server.go:129 +0x200
github.com/spf13/cobra.(*Command).execute(0x14000d70c08, {0x140001aa0b0, 0x9, 0x9})
        /Users/mcrenshaw/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:989 +0x828
github.com/spf13/cobra.(*Command).ExecuteC(0x14000d70c08)
        /Users/mcrenshaw/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/mcrenshaw/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
main.main()
        /Users/mcrenshaw/go/src/github.com/argoproj/argo-cd/cmd/main.go:67 +0x364

Motivation

Logging utilities work best when all the logs are in the same format.

Proposal

Add a defer/recover to each long-lived Argo CD component to log the panic in the configured format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions