Browse Source

Unify the parameter to disable dry-run on weed shell commands to --apply (instead of --force).

pull/7450/head
Lisandro Pin 2 months ago
parent
commit
9214ed8b92
Failed to extract signature
  1. 15
      weed/shell/command_collection_delete.go
  2. 14
      weed/shell/command_ec_balance.go
  3. 13
      weed/shell/command_ec_rebuild.go
  4. 22
      weed/shell/command_fs_meta_change_volume_id.go
  5. 12
      weed/shell/command_volume_balance.go
  6. 10
      weed/shell/command_volume_check_disk.go
  7. 12
      weed/shell/command_volume_delete_empty.go
  8. 12
      weed/shell/command_volume_fix_replication.go
  9. 13
      weed/shell/command_volume_server_evacuate.go
  10. 10
      weed/shell/command_volume_tier_move.go

15
weed/shell/command_collection_delete.go

@ -23,7 +23,7 @@ func (c *commandCollectionDelete) Name() string {
func (c *commandCollectionDelete) Help() string {
return `delete specified collection
collection.delete -collection <collection_name> -force
collection.delete -collection <collection_name> -apply
`
}
@ -36,16 +36,23 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ
colDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
collectionName := colDeleteCommand.String("collection", "", "collection to delete. Use '_default_' for the empty-named collection.")
applyBalancing := colDeleteCommand.Bool("force", false, "apply the collection")
applyBalancing := colDeleteCommand.Bool("apply", false, "apply the collection")
// TODO: remove this alias
applyBalancingAlias := colDeleteCommand.Bool("force", false, "apply the collection (alias for -apply)")
if err = colDeleteCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyBalancing, "-force")
infoAboutSimulationMode(writer, *applyBalancing, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyBalancing = *applyBalancingAlias
}
if *collectionName == "" {
return fmt.Errorf("empty collection name is not allowed")
}
@ -55,7 +62,7 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ
}
if !*applyBalancing {
fmt.Fprintf(writer, "collection '%s' will be deleted. Use -force to apply the change.\n", *collectionName)
fmt.Fprintf(writer, "collection '%s' will be deleted. Use -apply to apply the change.\n", *collectionName)
return nil
}

14
weed/shell/command_ec_balance.go

@ -20,7 +20,7 @@ func (c *commandEcBalance) Name() string {
func (c *commandEcBalance) Help() string {
return `balance all ec shards among all racks and volume servers
ec.balance [-c EACH_COLLECTION|<collection_name>] [-force] [-dataCenter <data_center>] [-shardReplicaPlacement <replica_placement>]
ec.balance [-c EACH_COLLECTION|<collection_name>] [-apply] [-dataCenter <data_center>] [-shardReplicaPlacement <replica_placement>]
Algorithm:
` + ecBalanceAlgorithmDescription
@ -36,16 +36,24 @@ func (c *commandEcBalance) Do(args []string, commandEnv *CommandEnv, writer io.W
dc := balanceCommand.String("dataCenter", "", "only apply the balancing for this dataCenter")
shardReplicaPlacement := balanceCommand.String("shardReplicaPlacement", "", "replica placement for EC shards, or master default if empty")
maxParallelization := balanceCommand.Int("maxParallelization", DefaultMaxParallelization, "run up to X tasks in parallel, whenever possible")
applyBalancing := balanceCommand.Bool("force", false, "apply the balancing plan")
applyBalancing := balanceCommand.Bool("apply", false, "apply the balancing plan")
// TODO: remove this alias
applyBalancingAlias := balanceCommand.Bool("force", false, "apply the balancing plan (alias for -apply)")
if err = balanceCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyBalancing, "-force")
infoAboutSimulationMode(writer, *applyBalancing, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyBalancing = *applyBalancingAlias
}
var collections []string
if *collection == "EACH_COLLECTION" {
collections, err = ListCollectionNames(commandEnv, false, true)

13
weed/shell/command_ec_rebuild.go

@ -28,7 +28,7 @@ func (c *commandEcRebuild) Name() string {
func (c *commandEcRebuild) Help() string {
return `find and rebuild missing ec shards among volume servers
ec.rebuild [-c EACH_COLLECTION|<collection_name>] [-force]
ec.rebuild [-c EACH_COLLECTION|<collection_name>] [-apply]
Algorithm:
@ -63,16 +63,23 @@ func (c *commandEcRebuild) Do(args []string, commandEnv *CommandEnv, writer io.W
fixCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
collection := fixCommand.String("collection", "EACH_COLLECTION", "collection name, or \"EACH_COLLECTION\" for each collection")
applyChanges := fixCommand.Bool("force", false, "apply the changes")
applyChanges := fixCommand.Bool("apply", false, "apply the changes")
// TODO: remove this alias
applyChangesAlias := fixCommand.Bool("force", false, "apply the changes (alias for -apply)")
if err = fixCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyChanges, "-force")
infoAboutSimulationMode(writer, *applyChanges, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyChanges = *applyChangesAlias
}
// collect all ec nodes
allEcNodes, _, err := collectEcNodes(commandEnv)
if err != nil {

22
weed/shell/command_fs_meta_change_volume_id.go

@ -4,13 +4,14 @@ import (
"context"
"flag"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/util"
"io"
"os"
"strconv"
"strings"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/util"
)
func init() {
@ -27,8 +28,8 @@ func (c *commandFsMetaChangeVolumeId) Name() string {
func (c *commandFsMetaChangeVolumeId) Help() string {
return `change volume id in existing metadata.
fs.meta.changeVolumeId -dir=/path/to/a/dir -fromVolumeId=x -toVolumeId=y -force
fs.meta.changeVolumeId -dir=/path/to/a/dir -mapping=/path/to/mapping/file -force
fs.meta.changeVolumeId -dir=/path/to/a/dir -fromVolumeId=x -toVolumeId=y -apply
fs.meta.changeVolumeId -dir=/path/to/a/dir -mapping=/path/to/mapping/file -apply
The mapping file should have these lines, each line is: [fromVolumeId]=>[toVolumeId]
e.g.
@ -49,11 +50,18 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv,
mappingFileName := fsMetaChangeVolumeIdCommand.String("mapping", "", "a file with multiple volume id changes, with each line as x=>y")
fromVolumeId := fsMetaChangeVolumeIdCommand.Uint("fromVolumeId", 0, "change metadata with this volume id")
toVolumeId := fsMetaChangeVolumeIdCommand.Uint("toVolumeId", 0, "change metadata to this volume id")
isForce := fsMetaChangeVolumeIdCommand.Bool("force", false, "applying the metadata changes")
applyChanges := fsMetaChangeVolumeIdCommand.Bool("apply", false, "apply the metadata changes")
// TODO: remove this alias
applyChangesAlias := fsMetaChangeVolumeIdCommand.Bool("force", false, "apply the metadata changes (alias for -apply)")
if err = fsMetaChangeVolumeIdCommand.Parse(args); err != nil {
return err
}
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyChanges = *applyChangesAlias
}
// load the mapping
mapping := make(map[needle.VolumeId]needle.VolumeId)
if *mappingFileName != "" {
@ -86,7 +94,7 @@ func (c *commandFsMetaChangeVolumeId) Do(args []string, commandEnv *CommandEnv,
}
if hasChanges {
println("Updating", parentPath, entry.Name)
if *isForce {
if *applyChanges {
if updateErr := filer_pb.UpdateEntry(context.Background(), client, &filer_pb.UpdateEntryRequest{
Directory: string(parentPath),
Entry: entry,

12
weed/shell/command_volume_balance.go

@ -39,7 +39,7 @@ func (c *commandVolumeBalance) Name() string {
func (c *commandVolumeBalance) Help() string {
return `balance all volumes among volume servers
volume.balance [-collection ALL_COLLECTIONS|EACH_COLLECTION|<collection_name>] [-force] [-dataCenter=<data_center_name>] [-racks=rack_name_one,rack_name_two] [-nodes=192.168.0.1:8080,192.168.0.2:8080]
volume.balance [-collection ALL_COLLECTIONS|EACH_COLLECTION|<collection_name>] [-apply] [-dataCenter=<data_center_name>] [-racks=rack_name_one,rack_name_two] [-nodes=192.168.0.1:8080,192.168.0.2:8080]
The -collection parameter supports:
- ALL_COLLECTIONS: balance across all collections
@ -92,14 +92,20 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer
nodes := balanceCommand.String("nodes", "", "only apply the balancing for this nodes")
writable := balanceCommand.Bool("writable", false, "only apply the balancing for writable volumes")
noLock := balanceCommand.Bool("noLock", false, "do not lock the admin shell at one's own risk")
applyBalancing := balanceCommand.Bool("force", false, "apply the balancing plan.")
applyBalancing := balanceCommand.Bool("apply", false, "apply the balancing plan.")
// TODO: remove this alias
applyBalancingAlias := balanceCommand.Bool("force", false, "apply the balancing plan (alias for -apply)")
if err = balanceCommand.Parse(args); err != nil {
return nil
}
if *applyBalancingAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyBalancing = *applyBalancingAlias
}
c.writable = *writable
c.applyBalancing = *applyBalancing
infoAboutSimulationMode(writer, c.applyBalancing, "-force")
infoAboutSimulationMode(writer, c.applyBalancing, "-apply")
if *noLock {
commandEnv.noLock = true

10
weed/shell/command_volume_check_disk.go

@ -120,18 +120,24 @@ func (c *commandVolumeCheckDisk) Do(args []string, commandEnv *CommandEnv, write
slowMode := fsckCommand.Bool("slow", false, "slow mode checks all replicas even file counts are the same")
verbose := fsckCommand.Bool("v", false, "verbose mode")
volumeId := fsckCommand.Uint("volumeId", 0, "the volume id")
applyChanges := fsckCommand.Bool("force", false, "apply the fix")
applyChanges := fsckCommand.Bool("apply", false, "apply the fix")
// TODO: remove this alias
applyChangesAlias := fsckCommand.Bool("force", false, "apply the fix (alias for -apply)")
syncDeletions := fsckCommand.Bool("syncDeleted", false, "sync of deletions the fix")
nonRepairThreshold := fsckCommand.Float64("nonRepairThreshold", 0.3, "repair when missing keys is not more than this limit")
if err = fsckCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyChanges, "-force")
infoAboutSimulationMode(writer, *applyChanges, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyChanges = *applyChangesAlias
}
c.env = commandEnv
c.writer = writer

12
weed/shell/command_volume_delete_empty.go

@ -26,7 +26,7 @@ func (c *commandVolumeDeleteEmpty) Name() string {
func (c *commandVolumeDeleteEmpty) Help() string {
return `delete empty volumes from all volume servers
volume.deleteEmpty -quietFor=24h -force
volume.deleteEmpty -quietFor=24h -apply
This command deletes all empty volumes from one volume server.
@ -41,15 +41,21 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri
volDeleteCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
quietPeriod := volDeleteCommand.Duration("quietFor", 24*time.Hour, "select empty volumes with no recent writes, avoid newly created ones")
applyBalancing := volDeleteCommand.Bool("force", false, "apply to delete empty volumes")
applyBalancing := volDeleteCommand.Bool("apply", false, "apply to delete empty volumes")
// TODO: remove this alias
applyBalancingAlias := volDeleteCommand.Bool("force", false, "apply the balancing plan (alias for -apply)")
if err = volDeleteCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyBalancing, "-force")
infoAboutSimulationMode(writer, *applyBalancing, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyBalancingAlias != false {
log.Printf("WARNING: -force is deprecated, please use -apply instead")
*applyBalancing = *applyBalancingAlias
}
// collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)

12
weed/shell/command_volume_fix_replication.go

@ -46,7 +46,7 @@ func (c *commandVolumeFixReplication) Help() string {
If the free slots satisfy the replication requirement, the volume content is copied over and mounted.
volume.fix.replication # do not take action
volume.fix.replication -force # actually deleting or copying the volume files and mount the volume
volume.fix.replication -apply # actually deleting or copying the volume files and mount the volume
volume.fix.replication -collectionPattern=important* # fix any collections with prefix "important"
Note:
@ -66,7 +66,9 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
volFixReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
c.collectionPattern = volFixReplicationCommand.String("collectionPattern", "", "match with wildcard characters '*' and '?'")
applyChanges := volFixReplicationCommand.Bool("force", false, "apply the fix")
applyChanges := volFixReplicationCommand.Bool("apply", false, "apply the fix")
// TODO: remove this alias
applyChangesAlias := volFixReplicationCommand.Bool("force", false, "apply the fix (alias for -apply)")
doDelete := volFixReplicationCommand.Bool("doDelete", true, "Also delete over-replicated volumes besides fixing under-replication")
doCheck := volFixReplicationCommand.Bool("doCheck", true, "Also check synchronization before deleting")
maxParallelization := volFixReplicationCommand.Int("maxParallelization", DefaultMaxParallelization, "run up to X tasks in parallel, whenever possible")
@ -76,8 +78,12 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
if err = volFixReplicationCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyChanges, "-force")
infoAboutSimulationMode(writer, *applyChanges, "-apply")
if *applyChangesAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyChanges = *applyChangesAlias
}
commandEnv.noLock = !*applyChanges
if err = commandEnv.confirmIsLocked(args); *applyChanges && err != nil {

13
weed/shell/command_volume_server_evacuate.go

@ -6,12 +6,13 @@ import (
"io"
"os"
"slices"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"slices"
)
func init() {
@ -57,17 +58,23 @@ func (c *commandVolumeServerEvacuate) Do(args []string, commandEnv *CommandEnv,
c.volumeRack = vsEvacuateCommand.String("rack", "", "source rack for the volume servers")
c.targetServer = vsEvacuateCommand.String("target", "", "<host>:<port> of target volume")
skipNonMoveable := vsEvacuateCommand.Bool("skipNonMoveable", false, "skip volumes that can not be moved")
applyChange := vsEvacuateCommand.Bool("force", false, "actually apply the changes")
applyChange := vsEvacuateCommand.Bool("apply", false, "actually apply the changes")
// TODO: remove this alias
applyChangeAlias := vsEvacuateCommand.Bool("force", false, "actually apply the changes (alias for -apply)")
retryCount := vsEvacuateCommand.Int("retry", 0, "how many times to retry")
if err = vsEvacuateCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyChange, "-force")
infoAboutSimulationMode(writer, *applyChange, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil && *applyChange {
return
}
if *applyChangeAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyChange = *applyChangeAlias
}
if *volumeServer == "" && *c.volumeRack == "" {
return fmt.Errorf("need to specify volume server by -node=<host>:<port> or source rack")
}

10
weed/shell/command_volume_tier_move.go

@ -66,19 +66,25 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
source := tierCommand.String("fromDiskType", "", "the source disk type")
target := tierCommand.String("toDiskType", "", "the target disk type")
parallelLimit := tierCommand.Int("parallelLimit", 0, "limit the number of parallel copying jobs")
applyChange := tierCommand.Bool("force", false, "actually apply the changes")
applyChange := tierCommand.Bool("apply", false, "actually apply the changes")
// TODO: remove this alias
applyChangeAlias := tierCommand.Bool("force", false, "actually apply the changes (alias for -apply)")
ioBytePerSecond := tierCommand.Int64("ioBytePerSecond", 0, "limit the speed of move")
replicationString := tierCommand.String("toReplication", "", "the new target replication setting")
if err = tierCommand.Parse(args); err != nil {
return nil
}
infoAboutSimulationMode(writer, *applyChange, "-force")
infoAboutSimulationMode(writer, *applyChange, "-apply")
if err = commandEnv.confirmIsLocked(args); err != nil {
return
}
if *applyChangeAlias != false {
fmt.Fprintf(writer, "WARNING: -force is deprecated, please use -apply instead")
*applyChange = *applyChangeAlias
}
fromDiskType := types.ToDiskType(*source)
toDiskType := types.ToDiskType(*target)

Loading…
Cancel
Save