Skip to content

Show error stack trace if --debug is given#2789

Merged
AkihiroSuda merged 1 commit intoopencontainers:masterfrom
kolyshkin:error-trace
Feb 5, 2021
Merged

Show error stack trace if --debug is given#2789
AkihiroSuda merged 1 commit intoopencontainers:masterfrom
kolyshkin:error-trace

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

We use github.com/pkg/errors to produce an error in many places.
One of its benefits is error comes with a stack trace.

Let's print that stack trace if --debug is given.

Example:

# ../runc --debug run -d ''
ERRO[0000] container id cannot be empty
DEBU[0000] container id cannot be empty
main.init
	github.com/opencontainers/runc/utils_linux.go:28
runtime.doInit
	runtime/proc.go:5652
runtime.main
	runtime/proc.go:191
runtime.goexit
	runtime/asm_amd64.s:1374

We use github.com/pkg/errors to produce an error in many places.
One of its benefits is error comes with a stack trace.

Let's print that stack trace if --debug is set.

Example:

	# ../runc --debug run -d ''
	ERRO[0000] container id cannot be empty
	DEBU[0000] container id cannot be empty
	main.init
		github.com/opencontainers/runc/utils_linux.go:28
	runtime.doInit
		runtime/proc.go:5652
	runtime.main
		runtime/proc.go:191
	runtime.goexit
		runtime/asm_amd64.s:1374

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Copy link
Copy Markdown
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm kinda surprised we weren't doing this already.

@cyphar cyphar added this to the 1.0.0-rc94 milestone Feb 5, 2021
@AkihiroSuda AkihiroSuda merged commit 072ed87 into opencontainers:master Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants