Give the ScrubVolume() RPC an option to flag found broken volumes as read-only. (#8360)
* Give the `ScrubVolume()` RPC an option to flag found broken volumes as read-only. Also exposes this option in the shell `volume.scrub` command. * Remove redundant test in `TestVolumeMarkReadonlyWritableErrorPaths`. 417051bb slightly rearranges the logic for `VolumeMarkReadonly()` and `VolumeMarkWritable()`, so calling them for invalid volume IDs will actually yield that error, instead of checking maintnenance mode first.
This commit is contained in:
@@ -51,6 +51,7 @@ func (c *commandVolumeScrub) Do(args []string, commandEnv *CommandEnv, writer io
|
||||
nodesStr := volScrubCommand.String("node", "", "comma-separated list of volume server <host>:<port> (optional)")
|
||||
volumeIDsStr := volScrubCommand.String("volumeId", "", "comma-separated volume IDs to process (optional)")
|
||||
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")
|
||||
|
||||
if err = volScrubCommand.Parse(args); err != nil {
|
||||
@@ -103,10 +104,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)
|
||||
return c.scrubVolumes(writer, *maxParallelization, *markBrokenReadonly)
|
||||
}
|
||||
|
||||
func (c *commandVolumeScrub) scrubVolumes(writer io.Writer, maxParallelization int) error {
|
||||
func (c *commandVolumeScrub) scrubVolumes(writer io.Writer, maxParallelization int, markBrokenReadonly bool) error {
|
||||
var brokenVolumesStr []string
|
||||
var details []string
|
||||
var totalVolumes, brokenVolumes, totalFiles uint64
|
||||
@@ -123,8 +124,9 @@ func (c *commandVolumeScrub) scrubVolumes(writer io.Writer, maxParallelization i
|
||||
|
||||
err := operation.WithVolumeServerClient(false, addr, c.env.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||
res, err := volumeServerClient.ScrubVolume(context.Background(), &volume_server_pb.ScrubVolumeRequest{
|
||||
Mode: c.mode,
|
||||
VolumeIds: c.volumeIDs,
|
||||
Mode: c.mode,
|
||||
VolumeIds: c.volumeIDs,
|
||||
MarkBrokenVolumesReadonly: markBrokenReadonly,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user