fix: deletes newly created volumes (#4551)

https://github.com/seaweedfs/seaweedfs/issues/4531

Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co>
This commit is contained in:
Konstantin Lebedev 2023-06-06 21:08:27 +05:00 committed by GitHub
parent 9bdbf9c880
commit 5caff2c0f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -57,7 +57,7 @@ func (c *commandVolumeDeleteEmpty) Do(args []string, commandEnv *CommandEnv, wri
eachDataNode(topologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) { eachDataNode(topologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) {
for _, diskInfo := range dn.DiskInfos { for _, diskInfo := range dn.DiskInfos {
for _, v := range diskInfo.VolumeInfos { for _, v := range diskInfo.VolumeInfos {
if v.Size <= 8 && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds { if v.Size <= 8 && v.ModifiedAtSecond > 0 && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds {
if *applyBalancing { if *applyBalancing {
log.Printf("deleting empty volume %d from %s", v.Id, dn.Id) log.Printf("deleting empty volume %d from %s", v.Id, dn.Id)
if deleteErr := deleteVolume(commandEnv.option.GrpcDialOption, needle.VolumeId(v.Id), pb.NewServerAddressFromDataNode(dn)); deleteErr != nil { if deleteErr := deleteVolume(commandEnv.option.GrpcDialOption, needle.VolumeId(v.Id), pb.NewServerAddressFromDataNode(dn)); deleteErr != nil {

View file

@ -6,6 +6,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb" "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"math/rand" "math/rand"
"sync" "sync"
"time"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -240,6 +241,7 @@ func (vg *VolumeGrowth) grow(grpcDialOption grpc.DialOption, topo *Topology, vid
Ttl: option.Ttl, Ttl: option.Ttl,
Version: needle.CurrentVersion, Version: needle.CurrentVersion,
DiskType: option.DiskType.String(), DiskType: option.DiskType.String(),
ModifiedAtSecond: time.Now().Unix(),
}) })
glog.V(0).Infof("Created Volume %d on %s", vid, server.NodeImpl.String()) glog.V(0).Infof("Created Volume %d on %s", vid, server.NodeImpl.String())
} else { } else {