Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
crenshaw-dev opened this issue Nov 24, 2024 · 0 comments · Fixed by #20925
Closed

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

crenshaw-dev opened this issue Nov 24, 2024 · 0 comments · Fixed by #20925
Labels
enhancement New feature or request

Comments

@crenshaw-dev
Copy link
Member

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.

@crenshaw-dev crenshaw-dev added the enhancement New feature or request label Nov 24, 2024
crenshaw-dev added a commit to crenshaw-dev/argo-cd that referenced this issue Nov 24, 2024
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
crenshaw-dev added a commit that referenced this issue Nov 25, 2024
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
adriananeci pushed a commit to adriananeci/argo-cd that referenced this issue Dec 4, 2024
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Adrian Aneci <aneci@adobe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant