Skip to content

Commit

Permalink
Merge pull request #16626 from vbotbuildovich/backport-pr-16576-v23.2…
Browse files Browse the repository at this point in the history
….x-165

[v23.2.x] rpk: Improve tuner output script
  • Loading branch information
r-vasquez authored Feb 17, 2024
2 parents 5c3a836 + f0a10aa commit 61166dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/go/rpk/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ run:
# those tools ever.
issues:
exclude-use-default: false

new-from-rev: HEAD

# We opt out of all suggested linters and manually pick what we want.
# Please do not use enable-all.
linters:
Expand Down
9 changes: 8 additions & 1 deletion src/go/rpk/pkg/cli/redpanda/tune/tune.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ To learn more about a tuner, run 'rpk redpanda tune help <tuner name>'.
out.MaybeDie(err, "unable to load config: %v", err)
var tunerFactory factory.TunersFactory
if outTuneScriptFile != "" {
exists, err := afero.Exists(fs, outTuneScriptFile)
out.MaybeDie(err, "unable to determine if file %q exists: %v", outTuneScriptFile, err)
if !exists {
zap.L().Sugar().Debugf("provided output-script file %q does not exists, creating one", outTuneScriptFile)
_, err = fs.Create(outTuneScriptFile)
out.MaybeDie(err, "unable to create file %q: %v", outTuneScriptFile, err)
}
isDir, err := afero.IsDir(fs, outTuneScriptFile)
out.MaybeDie(err, "unable to check if %q is a dir or a file: %v", outTuneScriptFile, err)
if isDir {
Expand All @@ -111,7 +118,7 @@ To learn more about a tuner, run 'rpk redpanda tune help <tuner name>'.
}
addTunerParamsFlags(cmd, &tunerParams)
cmd.Flags().StringVar(&cpuSet, "cpu-set", "all", "Set of CPUs for tuners to use in cpuset(7) format; if not specified, tuners will use all available CPUs")
cmd.Flags().StringVar(&outTuneScriptFile, "output-script", "", "Generate a tuning file that can later be used to tune the system")
cmd.Flags().StringVar(&outTuneScriptFile, "output-script", "", "If a filename is provided, it will generate a tuning file that can later be used to tune the system")
cmd.Flags().DurationVar(&timeout, "timeout", 10*time.Second, "The maximum time to wait for the tune processes to complete (e.g. 300ms, 1.5s, 2h45m)")
// Deprecated
cmd.Flags().BoolVar(new(bool), "interactive", false, "Ask for confirmation on every step (e.g. configuration generation)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c *writeSizedFileCommand) RenderScript(w *bufio.Writer) error {
// See 'man truncate'.
fmt.Fprintf(
w,
"truncate -s %d %s",
"truncate -s %d %s\n",
c.sizeBytes,
c.path,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestWriteSizedFileCmdRender(t *testing.T) {
int64(1),
)

expected := "truncate -s 1 /some/made/up/filepath.txt"
expected := "truncate -s 1 /some/made/up/filepath.txt\n"
var buf bytes.Buffer

w := bufio.NewWriter(&buf)
Expand Down

0 comments on commit 61166dd

Please sign in to comment.