EC volume supports expiration and displays expiration message when executing volume.list (#5895)

* ec volume expire

* volume.list show DestroyTime

* comments

* code optimization

---------

Co-authored-by: xuwenfeng <xuwenfeng1@zto.com>
This commit is contained in:
augustazz
2024-08-16 15:20:00 +08:00
committed by GitHub
parent 8f1f1730e9
commit 0b00706454
14 changed files with 1189 additions and 1082 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"path"
"strings"
"time"
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/operation"
@@ -71,11 +72,22 @@ func (vs *VolumeServer) VolumeEcShardsGenerate(ctx context.Context, req *volume_
}
// write .vif files
var destroyTime uint64
if v.Ttl != nil {
ttlMills := v.Ttl.ToSeconds()
if ttlMills > 0 {
destroyTime = uint64(time.Now().Unix()) + v.Ttl.ToSeconds() //calculated destroy time from the ec volume was created
}
}
volumeInfo := &volume_server_pb.VolumeInfo{Version: uint32(v.Version())}
if destroyTime == 0 {
glog.Warningf("gen ec volume,cal ec volume destory time fail,set time to 0,ttl:%v", v.Ttl)
} else {
volumeInfo.DestroyTime = destroyTime
}
datSize, _, _ := v.FileStat()
if err := volume_info.SaveVolumeInfo(baseFileName+".vif", &volume_server_pb.VolumeInfo{
Version: uint32(v.Version()),
DatFileSize: int64(datSize),
}); err != nil {
volumeInfo.DatFileSize = int64(datSize)
if err := volume_info.SaveVolumeInfo(baseFileName+".vif", volumeInfo); err != nil {
return nil, fmt.Errorf("SaveVolumeInfo %s: %v", baseFileName, err)
}
@@ -154,7 +166,6 @@ func (vs *VolumeServer) VolumeEcShardsCopy(ctx context.Context, req *volume_serv
if _, err := vs.doCopyFile(client, true, req.Collection, req.VolumeId, math.MaxUint32, math.MaxInt64, indexBaseFileName, ".ecx", false, false, nil); err != nil {
return err
}
return nil
}
if req.CopyEcjFile {