Skip to content

Commit b41bc14

Browse files
committed
roachprod/roachtest/logictest: unconditionally disable Sentry crash reporting
Previously, the environment variable, `COCKROACH_SKIP_ENABLING_DIAGNOSTIC_REPORTING=1` was used to disable both telemetry and crash reporting. However, the default for `diagnostics.reporting.enabled` has flipped from `false` to `true` as of [1]. The same PR added a regression wrt to the environment variable–it no longer disabled crash reporting via Sentry. Recall, we prefer to disable Sentry crash reporting for _all_ tests since our (internal) test artifacts contain a superset of contextual information; i.e., Sentry reports are of limited use for test failures; as such they add more noise than signal. Also recall, unit tests effectively disable Sentry by not invoking `cli.doMain`, which invokes `SetupCrashReporter`. Both integration (docker) and roachtests rely on `COCKROACH_SKIP_ENABLING_DIAGNOSTIC_REPORTING=1`. Mixedversion logic tests until this change, simply assumed that `diagnostics.reporting.enabled` defaulted to `false`. This change fixes the regression, introduced in [1], by correctly updating `diagnostics.reporting.enabled` to affect the environment variable. It also sets `COCKROACH_CRASH_REPORTS` to the empty string, which disables crash reporting _before_ a server is fully initialized. [1] #131097 Fixes: #145457 Epic: none Release note: None
1 parent 15a7aac commit b41bc14

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

pkg/roachprod/install/cockroach.go

+3
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,10 @@ func (c *SyncedCluster) generateStartCmd(
864864
EnvVars: append(append([]string{
865865
fmt.Sprintf("ROACHPROD=%s", c.roachprodEnvValue(node)),
866866
"GOTRACEBACK=crash",
867+
// N.B. disable telemetry (see `TelemetryOptOut`).
867868
"COCKROACH_SKIP_ENABLING_DIAGNOSTIC_REPORTING=1",
869+
// N.B. set crash reporting URL (see `crashReportURL()`) to the empty string to disable Sentry crash reports.
870+
"COCKROACH_CRASH_REPORTS=",
868871
}, c.Env...), getEnvVars()...),
869872
Binary: cockroachNodeBinary(c, node),
870873
Args: args,

pkg/sql/logictest/logic.go

+2
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,8 @@ func (t *logicTest) newTestServerCluster(bootstrapBinaryPath, upgradeBinaryPath
13341334
t.logsDir = logsDir
13351335

13361336
var envVars []string
1337+
// Set crash reporting URL to the empty string to disable Sentry crash reports.
1338+
envVars = append(envVars, "COCKROACH_CRASH_REPORTS=")
13371339
if strings.Contains(upgradeBinaryPath, "cockroach-short") {
13381340
// If we're using a cockroach-short binary, that means it was
13391341
// locally built, so we need to opt-out of version offsetting to

pkg/upgrade/upgrades/permanent_upgrades.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,16 @@ func addRootToAdminRole(ctx context.Context, txn isql.Txn) error {
161161
func optInToDiagnosticsStatReporting(
162162
ctx context.Context, _ clusterversion.ClusterVersion, deps upgrade.TenantDeps,
163163
) error {
164+
// N.B. The default for `diagnostics.reporting.enabled` is `true` as of [1].
165+
// [1] https://github.com/cockroachdb/cockroach/pull/131097
166+
optIn := true
164167
// We're opting-out of the automatic opt-in. See discussion in updates.go.
165168
if cluster.TelemetryOptOut {
166-
return nil
169+
optIn = false
167170
}
168171
_, err := deps.InternalExecutor.Exec(
169172
ctx, "optInToDiagnosticsStatReporting", nil, /* txn */
170-
`SET CLUSTER SETTING diagnostics.reporting.enabled = true`)
173+
fmt.Sprintf(`SET CLUSTER SETTING diagnostics.reporting.enabled = %t`, optIn))
171174
if errors.Is(err, cluster.SettingOverrideErr) {
172175
return nil
173176
}

pkg/util/log/logcrash/crash_reporting.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ var (
4040
// Collecting this data from production clusters helps us understand and improve
4141
// how our storage systems behave in real-world use cases.
4242
//
43-
// Note: while the setting itself is actually defined with a default value of
44-
// `false`, it is usually automatically set to `true` when a cluster is created
45-
// (or is migrated from a earlier beta version). This can be prevented with the
43+
// Note: while the setting defaults to `true`, it can be overridden with the
4644
// env var COCKROACH_SKIP_ENABLING_DIAGNOSTIC_REPORTING.
4745
//
46+
// Note: while this setting also controls crash reporting (see logcrash.ShouldSendReport), the updated setting
47+
// isn't affected until after the server startup sequence is complete. Thus, if you also must disable crash reporting
48+
// during server startup, you should set the env var `COCKROACH_CRASH_REPORTS=` to the empty value.
49+
//
4850
// Doing this, rather than just using a default of `true`, means that a node
4951
// will not errantly send a report using a default before loading settings.
5052
DiagnosticsReportingEnabled = settings.RegisterBoolSetting(

0 commit comments

Comments
 (0)