Skip to content

Commit

Permalink
rpk: collect crash_reports in debug bundle
Browse files Browse the repository at this point in the history
Same as startup_log, we will only collect the
directory if it's present
  • Loading branch information
r-vasquez committed Jan 14, 2025
1 parent 706a3b7 commit 4d54c8a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/go/rpk/pkg/cli/debug/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ COMMON FILES
- Broker metrics: The broker's Prometheus metrics, fetched through its
admin API (/metrics and /public_metrics).
- Crash information: Both startup_log and crash_reports will be collected if
present in the configured data directory.
BARE-METAL
- Kernel: The kernel logs ring buffer (syslog) and parameters (sysctl).
Expand Down
1 change: 1 addition & 0 deletions src/go/rpk/pkg/cli/debug/bundle/bundle_k8s_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func executeK8SBundle(ctx context.Context, bp bundleParams) error {
saveCmdLine(ps),
saveConfig(ps, bp.yActual),
saveControllerLogDir(ps, bp.y, bp.controllerLogLimitBytes),
saveCrashReports(ps, bp.y),
saveDataDirStructure(ps, bp.y),
saveDiskUsage(ctx, ps, bp.y),
saveInterrupts(ps),
Expand Down
22 changes: 22 additions & 0 deletions src/go/rpk/pkg/cli/debug/bundle/bundle_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func executeBundle(ctx context.Context, bp bundleParams) error {
saveCmdLine(ps),
saveConfig(ps, bp.y),
saveControllerLogDir(ps, bp.y, bp.controllerLogLimitBytes),
saveCrashReports(ps, bp.y),
saveDNSData(ctx, ps),
saveDataDirStructure(ps, bp.y),
saveDiskUsage(ctx, ps, bp.y),
Expand Down Expand Up @@ -1047,6 +1048,27 @@ func saveStartupLog(ps *stepParams, y *config.RedpandaYaml) step {
}
}

func saveCrashReports(ps *stepParams, y *config.RedpandaYaml) step {
return func() error {
if y.Redpanda.Directory == "" {
return fmt.Errorf("failed to save crash_reports: 'redpanda.data_directory' is empty on the provided configuration file")
}
crashReportDir := filepath.Join(y.Redpanda.Directory, "crash_reports")
exists, err := afero.Exists(ps.fs, crashReportDir)
if err != nil {
return fmt.Errorf("failed to save crash_reports: unable to check existence of the crash_reports directory")
}
if !exists {
return fmt.Errorf("skipping crash_reports collection: directory %q does not exists", crashReportDir)
}
err = writeDirToZip(ps, crashReportDir, "crash_reports", nil)
if err != nil {
return fmt.Errorf("failed to save crash_reports: %v", err)
}
return nil
}
}

func walkDir(root string, files map[string]*fileInfo) error {
return filepath.WalkDir(
root,
Expand Down
7 changes: 7 additions & 0 deletions tests/rptest/tests/rpk_debug_bundle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def test_debug_bundle(self):
continue
if re.match(r".* error querying .*\.ntp\..* i\/o timeout", l):
self.logger.error(f"Non-fatal transitory NTP error: {l}")
if re.match(
r".*skipping\s+(startup_log collection|crash_reports collection):\s*(unable to find file|directory).*",
l):
# this tests runs a development container, it will not have a
# startup_log and we don't expect a crash_reports dir to be
# in the data_directory as the container is new.
continue
else:
self.logger.error(f"Bad output line: {l}")
filtered_errors.append(l)
Expand Down

0 comments on commit 4d54c8a

Please sign in to comment.