-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
core/server: Add environment variable to write stacktrace to file #17929
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, otherwise looks good!
command/server.go
Outdated
if os.Getenv("VAULT_WRITE_STACKTRACE_TO_FILE") != "" { | ||
c.logger.Info("Writing stacktrace to file..") | ||
|
||
tmpFile, err := ioutil.TempFile("", fmt.Sprintf("%s-", filepath.Base(os.Args[0]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like ioutil.TemFile has been deprecated. Shall we use os.CreateTemp
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed!
When Vault receives a SIGUSR2 signal it will write a stacktrace of the running goroutines to Vault's log file. These can be hard to parse due to log prefixes and in some cases, the logger is unable to log the entire stacktrace. This adds an environment variable will force Vault to also write the stacktrace to a temporary file on the server.
The environment variables are as follows:
VAULT_STACKTRACE_WRITE_TO_FILE=true
: this forces the stacktrace to a file.VAULT_STACKTRACE_FILE_PATH=/some/path
: if left unset, Vault will create a temp directory and file for your OS. This let's the user override the path.Vault will write the locations to the server logs: