From 6b4d20a6f3f8ad323301a0c03696015c32cee315 Mon Sep 17 00:00:00 2001 From: Lisandro Pin Date: Wed, 10 Jun 2026 22:29:07 +0200 Subject: [PATCH] `volume.scrub` and `ec.scrub` shell commands: make the display of scrub details optional. (#9911) On volumes failing scrubs, the detail output can get very verbose, which makes reading results difficult. Most users won't care about this information to begin with - just whether or not volumes pass scrub tests. This MR gates the display of scrub result details behind a `--details` flag. --- weed/shell/command_ec_scrub.go | 7 ++++--- weed/shell/command_volume_scrub.go | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/weed/shell/command_ec_scrub.go b/weed/shell/command_ec_scrub.go index ee3235972..e9bd36f6e 100644 --- a/weed/shell/command_ec_scrub.go +++ b/weed/shell/command_ec_scrub.go @@ -51,6 +51,7 @@ func (c *commandEcVolumeScrub) Do(args []string, commandEnv *CommandEnv, writer volumeIDsStr := volScrubCommand.String("volumeId", "", "comma-separated EC volume IDs to process (optional)") mode := volScrubCommand.String("mode", "local", "scrubbing mode (index/local/full/checksum)") maxParallelization := volScrubCommand.Int("maxParallelization", DefaultMaxParallelization, "run up to X tasks in parallel, whenever possible") + showDetails := volScrubCommand.Bool("details", false, "display scrub result details, if available") if err = volScrubCommand.Parse(args); err != nil { return err @@ -104,10 +105,10 @@ func (c *commandEcVolumeScrub) Do(args []string, commandEnv *CommandEnv, writer fmt.Fprintf(writer, "using %s mode\n", c.mode.String()) c.env = commandEnv - return c.scrubEcVolumes(writer, *maxParallelization) + return c.scrubEcVolumes(writer, *maxParallelization, *showDetails) } -func (c *commandEcVolumeScrub) scrubEcVolumes(writer io.Writer, maxParallelization int) error { +func (c *commandEcVolumeScrub) scrubEcVolumes(writer io.Writer, maxParallelization int, showDetails bool) error { var brokenVolumesStr, brokenShardsStr []string var details []string var totalVolumes, brokenVolumes, brokenShards, totalFiles uint64 @@ -164,7 +165,7 @@ func (c *commandEcVolumeScrub) scrubEcVolumes(writer io.Writer, maxParallelizati if len(brokenShardsStr) != 0 { fmt.Fprintf(writer, "Affected shards: %s\n", strings.Join(brokenShardsStr, ", ")) } - if len(details) != 0 { + if showDetails && len(details) != 0 { fmt.Fprintf(writer, "Details:\n\t%s\n", strings.Join(details, "\n\t")) } } diff --git a/weed/shell/command_volume_scrub.go b/weed/shell/command_volume_scrub.go index 1b99678e9..dfac14294 100644 --- a/weed/shell/command_volume_scrub.go +++ b/weed/shell/command_volume_scrub.go @@ -53,6 +53,7 @@ func (c *commandVolumeScrub) Do(args []string, commandEnv *CommandEnv, writer io mode := volScrubCommand.String("mode", "full", "scrubbing mode (index/local/full)") markBrokenReadonly := volScrubCommand.Bool("markBrokenReadonly", false, "whether to flag volumes with scrub failures as read-only") maxParallelization := volScrubCommand.Int("maxParallelization", DefaultMaxParallelization, "run up to X tasks in parallel, whenever possible") + showDetails := volScrubCommand.Bool("details", false, "display scrub result details, if available") if err = volScrubCommand.Parse(args); err != nil { return err @@ -104,10 +105,10 @@ func (c *commandVolumeScrub) Do(args []string, commandEnv *CommandEnv, writer io fmt.Fprintf(writer, "using %s mode\n", c.mode.String()) c.env = commandEnv - return c.scrubVolumes(writer, *maxParallelization, *markBrokenReadonly) + return c.scrubVolumes(writer, *maxParallelization, *markBrokenReadonly, *showDetails) } -func (c *commandVolumeScrub) scrubVolumes(writer io.Writer, maxParallelization int, markBrokenReadonly bool) error { +func (c *commandVolumeScrub) scrubVolumes(writer io.Writer, maxParallelization int, markBrokenReadonly bool, showDetails bool) error { var brokenVolumesStr []string var details []string var totalVolumes, brokenVolumes, totalFiles uint64 @@ -158,7 +159,7 @@ func (c *commandVolumeScrub) scrubVolumes(writer io.Writer, maxParallelization i if brokenVolumes != 0 { fmt.Fprintf(writer, "\nGot scrub failures on %d volumes :(\n", brokenVolumes) fmt.Fprintf(writer, "Affected volumes: %s\n", strings.Join(brokenVolumesStr, ", ")) - if len(details) != 0 { + if showDetails && len(details) != 0 { fmt.Fprintf(writer, "Details:\n\t%s\n", strings.Join(details, "\n\t")) } }