aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_delete_empty.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-08-03 21:20:05 -0700
committerChris Lu <chris.lu@gmail.com>2021-08-03 21:20:05 -0700
commit42969c9c6247117f99ece43194912cd098acceb0 (patch)
tree804a7b7a666b2714082acdae396d04e0707f70c7 /weed/shell/command_volume_delete_empty.go
parent81b255df8b7352e7a420e7dc4a56cf58bcb9075f (diff)
parent8cf0c515bfb45c5d8e6c71f96c43f91cae30ea9d (diff)
downloadseaweedfs-42969c9c6247117f99ece43194912cd098acceb0.tar.xz
seaweedfs-42969c9c6247117f99ece43194912cd098acceb0.zip
Merge branch 'master' into add_remote_storage
Diffstat (limited to 'weed/shell/command_volume_delete_empty.go')
-rw-r--r--weed/shell/command_volume_delete_empty.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/weed/shell/command_volume_delete_empty.go b/weed/shell/command_volume_delete_empty.go
index 07c6d5b2c..079915f66 100644
--- a/weed/shell/command_volume_delete_empty.go
+++ b/weed/shell/command_volume_delete_empty.go
@@ -3,11 +3,10 @@ package shell
import (
"flag"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
+ "github.com/chrislusf/seaweedfs/weed/storage/needle"
"io"
"log"
"time"
-
- "github.com/chrislusf/seaweedfs/weed/storage/needle"
)
func init() {
@@ -24,7 +23,7 @@ func (c *commandVolumeDeleteEmpty) Name() string {
func (c *commandVolumeDeleteEmpty) Help() string {
return `delete empty volumes from all volume servers
- volume.deleteEmpty -quietFor=24h
+ volume.deleteEmpty -quietFor=24h -force
This command deletes all empty volumes from one volume server.
@@ -39,6 +38,7 @@ 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")
if err = volDeleteCommand.Parse(args); err != nil {
return nil
}
@@ -55,10 +55,15 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri
eachDataNode(topologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) {
for _, diskInfo := range dn.DiskInfos {
for _, v := range diskInfo.VolumeInfos {
- if v.Size <= 8 && v.ModifiedAtSecond + quietSeconds < nowUnixSeconds {
- log.Printf("deleting empty volume %d from %s", v.Id, dn.Id)
- if deleteErr := deleteVolume(commandEnv.option.GrpcDialOption, needle.VolumeId(v.Id), dn.Id); deleteErr != nil {
- err = deleteErr
+ if v.Size <= 8 && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds {
+ if *applyBalancing {
+ log.Printf("deleting empty volume %d from %s", v.Id, dn.Id)
+ if deleteErr := deleteVolume(commandEnv.option.GrpcDialOption, needle.VolumeId(v.Id), dn.Id); deleteErr != nil {
+ err = deleteErr
+ }
+ continue
+ } else {
+ log.Printf("empty volume %d from %s", v.Id, dn.Id)
}
}
}