-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
pkg/util/log: timezone options parsed using crdb-v2, even when format is json #113321
Comments
Hi @abarganier, please add branch-* labels to identify which branch(es) this release-blocker affects. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Hi @dhartunian, please add branch-* labels to identify which branch(es) this release-blocker affects. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
It appears that this bug happens with any For example, this also errored:
I believe the error is actually occurring when attempting to apply the default stderr config - we're not even hitting the file sink config apply step. |
We propagate the CommonSinkConfig component of the cockroach/pkg/util/log/logconfig/validate.go Line 173 in 250bb36
Why doesn't the format get propagated along with it, while the format-options do? EDIT: Ah! I see now: https://www.cockroachlabs.com/docs/stable/configure-logs#output-to-stderr
If that's the case, then we should only propagate the format options if they're supported by the With some added logging, here are the results of how the
|
113532: pkg/util/log: selectively apply file-defaults.format-options to stderr r=dhartunian a=abarganier Fixes: #113321 The stderr sink in the log config is only allowed to use the `crdb-v2-tty` format, and therefore, only `format-options` supported by the `crdb-v2-tty` format should be applied to the stderr sink. Unfortunately, a bug in the log config parse & validation code didn't follow this rule. The configuration that's part of the `file-defaults` is propagated to the stderr sink, and this included the `format-options`, even if they were only relevant to another log format type (e.g. `json`). This caused an error when trying to apply the options to the stderr log sink on startup, e.g.: ``` ERROR: unknown format option: "datetime-format" ``` To solve this problem, we should only propagate the `format-options` used in `file-defaults` to the stderr sink's config IFF the `file-defaults` format is of a `crdb-v2` variety. Since the stderr sink also uses the `crdb-v2-tty` format, we can only be sure that the `format-options` used in `file-defaults` is supported by the stderr sink if the `format` used in `file-defaults` is also part of `crdb-v2`. However, if `format-options` is explicitly defined within the `sinks.stderr` config, we need to be careful not to overwrite them with those defined in `file-defaults`. This patch accomplishes fixes for all these issues, and adds new tests to cover all these scenarios. Release note: none 113534: roachtest: test AOST restore in backup-restore/* roachtests r=renatolabs a=msbutler This patch allows the backup-restore driver to run and validate AOST restores from revision history backups. If the driver created a revision history backup, there's a 50% chance it will restore from an AOST between the full backup end time and the last incremental start time. A future patch will allow for AOST restores from non-revision history backups. Epic: none Release note: none Co-authored-by: Alex Barganier <[email protected]> Co-authored-by: Michael Butler <[email protected]>
Fixes: #113321 The stderr sink in the log config is only allowed to use the `crdb-v2-tty` format, and therefore, only `format-options` supported by the `crdb-v2-tty` format should be applied to the stderr sink. Unfortunately, a bug in the log config parse & validation code didn't follow this rule. The configuration that's part of the `file-defaults` is propagated to the stderr sink, and this included the `format-options`, even if they were only relevant to another log format type (e.g. `json`). This caused an error when trying to apply the options to the stderr log sink on startup, e.g.: ``` ERROR: unknown format option: "datetime-format" ``` To solve this problem, we should only propagate the `format-options` used in `file-defaults` to the stderr sink's config IFF the `file-defaults` format is of a `crdb-v2` variety. Since the stderr sink also uses the `crdb-v2-tty` format, we can only be sure that the `format-options` used in `file-defaults` is supported by the stderr sink if the `format` used in `file-defaults` is also part of `crdb-v2`. However, if `format-options` is explicitly defined within the `sinks.stderr` config, we need to be careful not to overwrite them with those defined in `file-defaults`. This patch accomplishes fixes for all these issues, and adds new tests to cover all these scenarios. Release note: none
Fixes: #113321 The stderr sink in the log config is only allowed to use the `crdb-v2-tty` format, and therefore, only `format-options` supported by the `crdb-v2-tty` format should be applied to the stderr sink. Unfortunately, a bug in the log config parse & validation code didn't follow this rule. The configuration that's part of the `file-defaults` is propagated to the stderr sink, and this included the `format-options`, even if they were only relevant to another log format type (e.g. `json`). This caused an error when trying to apply the options to the stderr log sink on startup, e.g.: ``` ERROR: unknown format option: "datetime-format" ``` To solve this problem, we should only propagate the `format-options` used in `file-defaults` to the stderr sink's config IFF the `file-defaults` format is of a `crdb-v2` variety. Since the stderr sink also uses the `crdb-v2-tty` format, we can only be sure that the `format-options` used in `file-defaults` is supported by the stderr sink if the `format` used in `file-defaults` is also part of `crdb-v2`. However, if `format-options` is explicitly defined within the `sinks.stderr` config, we need to be careful not to overwrite them with those defined in `file-defaults`. This patch accomplishes fixes for all these issues, and adds new tests to cover all these scenarios. Release note (bug fix): A bug in the log config code prevented users from setting the `datetime-format` and `datetime-timezone` log format options (set via the `format-options` structure) within their log config. Specifically, when users tried to use these options in `file-defaults` with any `json` type log format, the log config was previously unable to be parsed due to validation errors. This was because the `file-defaults.format-options` were propagated to the `sinks.stderr.format-options`. `sinks.stderr` only supports a format of `crdb-v2-tty`. Therefore, the incorrectly propagated `format-options`, which are only supported by the `json` log format, were identified as not being supported when validating `sinks.stderr`. With this patch, the `file-defaults.format-options` are only propagated to `sinks.stderr.format-options` if both of these conditions are true: 1. `file-defaults.format` is one of `crdb-v2` or `crdb-v2-tty`. 2. `sinks.stderr.format-options` are not explicitly set in the log config.
Describe the problem
#104265 introduced some new log config fields to add configurability around timezones and datetime formats used in logs.
the available options should be:
timezone
datetime-timezone
anddatetime-format
However, the following config causes an error of:
ERROR: unknown format option: "datetime-format"
After some debugging, I found that this is because the
crdb-v2
format options parser is being used, even when we state theformat: json
.Expected behavior
The
format-options
should be parsed properly for thejson
log format.Jira issue: CRDB-32868
The text was updated successfully, but these errors were encountered: