Skip to content

Commit

Permalink
rpk: controller log collection err improvement
Browse files Browse the repository at this point in the history
If a user provides a configuration file without
redpanda.data_directory, rpk won't know where to
find the controller log dirs. We now provide a
better error message instead of:

* lstat redpanda/controller/0_0: no such file or directory

Either way, a configuration file (redpanda.yaml)
without a data_directory is an invalid config
file,
  • Loading branch information
r-vasquez committed Jun 12, 2024
1 parent 87927b3 commit 3ec0d6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/go/rpk/pkg/cli/debug/bundle/bundle_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,16 @@ func sliceControllerDir(cFiles []fileSize, logLimitBytes int64) (slice []fileSiz

func saveControllerLogDir(ps *stepParams, y *config.RedpandaYaml, logLimitBytes int) step {
return func() error {
if y.Redpanda.Directory == "" {
return fmt.Errorf("failed to save controller logs: 'redpanda.data_directory' is empty on the provided configuration file")
}
controllerDir := filepath.Join(y.Redpanda.Directory, "redpanda", "controller", "0_0")

// We don't need the .base_index files to parse out the messages.
exclude := regexp.MustCompile(`^*.base_index$`)
cFiles, size, err := walkSizeDir(controllerDir, exclude)
if err != nil {
return err
return fmt.Errorf("unable to save controller logs: %v", err)
}

if int(size) < logLimitBytes {
Expand All @@ -969,11 +972,11 @@ func saveControllerLogDir(ps *stepParams, y *config.RedpandaYaml, logLimitBytes
for _, cLog := range slice {
file, err := os.ReadFile(cLog.path)
if err != nil {
return err
return fmt.Errorf("unable to save controller logs: %v", err)
}
err = writeFileToZip(ps, filepath.Join("controller", filepath.Base(cLog.path)), file)
if err != nil {
return err
return fmt.Errorf("unable to save controller logs: %v", err)
}
}
return nil
Expand Down

0 comments on commit 3ec0d6c

Please sign in to comment.