Skip to content

Commit

Permalink
rpk: save startup_log to debug bundle if present
Browse files Browse the repository at this point in the history
If not we just warn that we skipped the collection
but the bundle will still be completed
  • Loading branch information
r-vasquez committed Jan 10, 2025
1 parent f7e0746 commit 706a3b7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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 @@ -79,6 +79,7 @@ func executeK8SBundle(ctx context.Context, bp bundleParams) error {
saveMountedFilesystems(ps),
saveNTPDrift(ps),
saveResourceUsageData(ps, bp.y),
saveStartupLog(ps, bp.y),
saveSlabInfo(ps),
saveUname(ctx, ps),
}
Expand Down
26 changes: 26 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 @@ -152,6 +152,7 @@ func executeBundle(ctx context.Context, bp bundleParams) error {
saveResourceUsageData(ps, bp.y),
saveSingleAdminAPICalls(ctx, ps, bp.fs, bp.p, addrs, bp.cpuProfilerWait),
saveMetricsAPICalls(ctx, ps, bp.fs, bp.p, addrs, bp.metricsInterval, bp.metricsSampleCount),
saveStartupLog(ps, bp.y),
saveSlabInfo(ps),
saveSocketData(ctx, ps),
saveSysctl(ctx, ps),
Expand Down Expand Up @@ -1021,6 +1022,31 @@ func saveControllerLogDir(ps *stepParams, y *config.RedpandaYaml, logLimitBytes
}
}

func saveStartupLog(ps *stepParams, y *config.RedpandaYaml) step {
return func() error {
if y.Redpanda.Directory == "" {
return fmt.Errorf("failed to save startup_log: 'redpanda.data_directory' is empty on the provided configuration file")
}
path := filepath.Join(y.Redpanda.Directory, "startup_log")
exists, err := afero.Exists(ps.fs, path)
if err != nil {
return fmt.Errorf("failed to save startup_log: unable to check existence of startup_log: %v", err)
}
if !exists {
return fmt.Errorf("skipping startup_log collection: unable to find file %q", path)
}
content, err := afero.ReadFile(ps.fs, path)
if err != nil {
return fmt.Errorf("failed to save startup_log: unable to read startup_log: %v", err)
}
err = writeFileToZip(ps, "startup_log", content)
if err != nil {
return fmt.Errorf("failed to save startup_log: %v", err)
}
return nil
}
}

func walkDir(root string, files map[string]*fileInfo) error {
return filepath.WalkDir(
root,
Expand Down

0 comments on commit 706a3b7

Please sign in to comment.