aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2022-09-11 02:15:42 +0500
committerGitHub <noreply@github.com>2022-09-10 14:15:42 -0700
commitb64674018a618ea6a46137fd50fd687e8f72957f (patch)
tree2caa27a25c72a8cb1cca7826369f9147b6b66d5f
parent3cb914f7e12ad0aba82f52399282c3ffd377013e (diff)
downloadseaweedfs-b64674018a618ea6a46137fd50fd687e8f72957f.tar.xz
seaweedfs-b64674018a618ea6a46137fd50fd687e8f72957f.zip
[sync] override amz storage class, None to delete (#3639)
* override amz storage class, None to delete https://github.com/seaweedfs/seaweedfs/issues/3636 * use empty string to delete * without nil check
-rw-r--r--weed/command/filer_remote_sync.go2
-rw-r--r--weed/command/filer_remote_sync_dir.go6
-rw-r--r--weed/command/filer_sync_jobs.go2
3 files changed, 9 insertions, 1 deletions
diff --git a/weed/command/filer_remote_sync.go b/weed/command/filer_remote_sync.go
index 84d2f0e91..f1b5ef01d 100644
--- a/weed/command/filer_remote_sync.go
+++ b/weed/command/filer_remote_sync.go
@@ -14,6 +14,7 @@ import (
type RemoteSyncOptions struct {
filerAddress *string
+ storageClass *string
grpcDialOption grpc.DialOption
readChunkFromFiler *bool
timeAgo *time.Duration
@@ -45,6 +46,7 @@ func init() {
cmdFilerRemoteSynchronize.Run = runFilerRemoteSynchronize // break init cycle
remoteSyncOptions.filerAddress = cmdFilerRemoteSynchronize.Flag.String("filer", "localhost:8888", "filer of the SeaweedFS cluster")
remoteSyncOptions.dir = cmdFilerRemoteSynchronize.Flag.String("dir", "", "a mounted directory on filer")
+ remoteSyncOptions.storageClass = cmdFilerRemoteSynchronize.Flag.String("storageClass", "None", "override amz storage class, empty to delete")
remoteSyncOptions.readChunkFromFiler = cmdFilerRemoteSynchronize.Flag.Bool("filerProxy", false, "read file chunks from filer instead of volume servers")
remoteSyncOptions.timeAgo = cmdFilerRemoteSynchronize.Flag.Duration("timeAgo", 0, "start time before now, skipping previous metadata changes. \"300ms\", \"1.5h\" or \"2h45m\". Valid time units are \"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\"")
remoteSyncOptions.clientId = util.RandomInt32()
diff --git a/weed/command/filer_remote_sync_dir.go b/weed/command/filer_remote_sync_dir.go
index 6f061bda8..288b89a5a 100644
--- a/weed/command/filer_remote_sync_dir.go
+++ b/weed/command/filer_remote_sync_dir.go
@@ -37,6 +37,12 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
var lastLogTsNs = time.Now().UnixNano()
processEventFnWithOffset := pb.AddOffsetFunc(func(resp *filer_pb.SubscribeMetadataResponse) error {
+ storageClass := *option.storageClass
+ if storageClass == "" {
+ delete(resp.EventNotification.NewEntry.Extended, s3_constants.AmzStorageClass)
+ } else if storageClass != "None" {
+ resp.EventNotification.NewEntry.Extended[s3_constants.AmzStorageClass] = []byte(storageClass)
+ }
processor.AddSyncJob(resp)
return nil
}, 3*time.Second, func(counter int64, lastTsNs int64) error {
diff --git a/weed/command/filer_sync_jobs.go b/weed/command/filer_sync_jobs.go
index 50428a3ad..9d2ba75d5 100644
--- a/weed/command/filer_sync_jobs.go
+++ b/weed/command/filer_sync_jobs.go
@@ -54,7 +54,7 @@ func (t *MetadataProcessor) AddSyncJob(resp *filer_pb.SubscribeMetadataResponse)
// if is the oldest job, write down the watermark
isOldest := true
- for t, _ := range t.activeJobs {
+ for t := range t.activeJobs {
if resp.TsNs > t {
isOldest = false
break