diff --git a/weed/command/filer.go b/weed/command/filer.go index 1e4b065cd..053c5a147 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -122,7 +122,6 @@ func init() { filerS3Options.auditLogConfig = cmdFiler.Flag.String("s3.auditLogConfig", "", "path to the audit log config file") filerS3Options.allowEmptyFolder = cmdFiler.Flag.Bool("s3.allowEmptyFolder", true, "allow empty folders") filerS3Options.allowDeleteBucketNotEmpty = cmdFiler.Flag.Bool("s3.allowDeleteBucketNotEmpty", true, "allow recursive deleting all entries along with bucket") - filerS3Options.allowDeleteObjectsByTTL = cmdFiler.Flag.Bool("s3.allowDeleteObjectsByTTL", false, "allow deleting all expired entries") filerS3Options.localSocket = cmdFiler.Flag.String("s3.localSocket", "", "default to /tmp/seaweedfs-s3-.sock") filerS3Options.tlsCACertificate = cmdFiler.Flag.String("s3.cacert.file", "", "path to the TLS CA certificate file") filerS3Options.tlsVerifyClientCert = cmdFiler.Flag.Bool("s3.tlsVerifyClientCert", false, "whether to verify the client's certificate") diff --git a/weed/command/s3.go b/weed/command/s3.go index 4de1c4fba..fa575b3db 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -51,7 +51,6 @@ type S3Options struct { metricsHttpIp *string allowEmptyFolder *bool allowDeleteBucketNotEmpty *bool - allowDeleteObjectsByTTL *bool auditLogConfig *string localFilerSocket *string dataCenter *string @@ -81,7 +80,6 @@ func init() { s3StandaloneOptions.metricsHttpIp = cmdS3.Flag.String("metricsIp", "", "metrics listen ip. If empty, default to same as -ip.bind option.") s3StandaloneOptions.allowEmptyFolder = cmdS3.Flag.Bool("allowEmptyFolder", true, "allow empty folders") s3StandaloneOptions.allowDeleteBucketNotEmpty = cmdS3.Flag.Bool("allowDeleteBucketNotEmpty", true, "allow recursive deleting all entries along with bucket") - s3StandaloneOptions.allowDeleteObjectsByTTL = cmdS3.Flag.Bool("allowDeleteObjectsByTTL", false, "allow deleting all expired entries") s3StandaloneOptions.localFilerSocket = cmdS3.Flag.String("localFilerSocket", "", "local filer socket path") s3StandaloneOptions.localSocket = cmdS3.Flag.String("localSocket", "", "default to /tmp/seaweedfs-s3-.sock") s3StandaloneOptions.idleTimeout = cmdS3.Flag.Int("idleTimeout", 10, "connection idle seconds") @@ -263,7 +261,6 @@ func (s3opt *S3Options) startS3Server() bool { GrpcDialOption: grpcDialOption, AllowEmptyFolder: *s3opt.allowEmptyFolder, AllowDeleteBucketNotEmpty: *s3opt.allowDeleteBucketNotEmpty, - AllowDeleteObjectsByTTL: *s3opt.allowDeleteObjectsByTTL, LocalFilerSocket: localFilerSocket, DataCenter: *s3opt.dataCenter, FilerGroup: filerGroup, diff --git a/weed/command/server.go b/weed/command/server.go index 10d412315..8c99d04fd 100644 --- a/weed/command/server.go +++ b/weed/command/server.go @@ -165,7 +165,6 @@ func init() { s3Options.auditLogConfig = cmdServer.Flag.String("s3.auditLogConfig", "", "path to the audit log config file") s3Options.allowEmptyFolder = cmdServer.Flag.Bool("s3.allowEmptyFolder", true, "allow empty folders") s3Options.allowDeleteBucketNotEmpty = cmdServer.Flag.Bool("s3.allowDeleteBucketNotEmpty", true, "allow recursive deleting all entries along with bucket") - s3Options.allowDeleteObjectsByTTL = cmdServer.Flag.Bool("s3.allowDeleteObjectsByTTL", false, "allow deleting all expired entries") s3Options.localSocket = cmdServer.Flag.String("s3.localSocket", "", "default to /tmp/seaweedfs-s3-.sock") s3Options.bindIp = cmdServer.Flag.String("s3.ip.bind", "", "ip address to bind to. If empty, default to same as -ip.bind option.") s3Options.idleTimeout = cmdServer.Flag.Int("s3.idleTimeout", 10, "connection idle seconds") diff --git a/weed/s3api/filer_multipart.go b/weed/s3api/filer_multipart.go index c9247f2c5..5850766cc 100644 --- a/weed/s3api/filer_multipart.go +++ b/weed/s3api/filer_multipart.go @@ -55,8 +55,9 @@ func (s3a *S3ApiServer) createMultipartUpload(r *http.Request, input *s3.CreateM if entry.Extended == nil { entry.Extended = make(map[string][]byte) } - entry.Extended["key"] = []byte(*input.Key) - + entry.Extended[s3_constants.ExtMultipartObjectKey] = []byte(*input.Key) + // Set TTL-based S3 expiry (modification time) + entry.Extended[s3_constants.SeaweedFSExpiresS3] = []byte("true") // Set object owner for multipart upload amzAccountId := r.Header.Get(s3_constants.AmzAccountId) if amzAccountId != "" { @@ -334,7 +335,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl } for k, v := range pentry.Extended { - if k != "key" { + if k != s3_constants.ExtMultipartObjectKey { versionEntry.Extended[k] = v } } @@ -396,7 +397,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl } for k, v := range pentry.Extended { - if k != "key" { + if k != s3_constants.ExtMultipartObjectKey { entry.Extended[k] = v } } @@ -449,7 +450,7 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl } for k, v := range pentry.Extended { - if k != "key" { + if k != s3_constants.ExtMultipartObjectKey { entry.Extended[k] = v } } @@ -472,7 +473,8 @@ func (s3a *S3ApiServer) completeMultipartUpload(r *http.Request, input *s3.Compl entry.Attributes.Mime = mime } entry.Attributes.FileSize = uint64(offset) - if s3a.option.AllowDeleteObjectsByTTL && entityWithTtl { + // Set TTL-based S3 expiry (modification time) + if entityWithTtl { entry.Extended[s3_constants.SeaweedFSExpiresS3] = []byte("true") } }) @@ -594,7 +596,7 @@ func (s3a *S3ApiServer) listMultipartUploads(input *s3.ListMultipartUploadsInput uploadsCount := int64(0) for _, entry := range entries { if entry.Extended != nil { - key := string(entry.Extended["key"]) + key := string(entry.Extended[s3_constants.ExtMultipartObjectKey]) if *input.KeyMarker != "" && *input.KeyMarker != key { continue } diff --git a/weed/s3api/s3_constants/extend_key.go b/weed/s3api/s3_constants/extend_key.go index f0f223a45..d57798341 100644 --- a/weed/s3api/s3_constants/extend_key.go +++ b/weed/s3api/s3_constants/extend_key.go @@ -11,6 +11,7 @@ const ( ExtETagKey = "Seaweed-X-Amz-ETag" ExtLatestVersionIdKey = "Seaweed-X-Amz-Latest-Version-Id" ExtLatestVersionFileNameKey = "Seaweed-X-Amz-Latest-Version-File-Name" + ExtMultipartObjectKey = "key" // Bucket Policy ExtBucketPolicyKey = "Seaweed-X-Amz-Bucket-Policy" diff --git a/weed/s3api/s3api_object_handlers_put.go b/weed/s3api/s3api_object_handlers_put.go index 1609ca510..0d07c548e 100644 --- a/weed/s3api/s3api_object_handlers_put.go +++ b/weed/s3api/s3api_object_handlers_put.go @@ -333,9 +333,8 @@ func (s3a *S3ApiServer) putToFiler(r *http.Request, uploadUrl string, dataReader proxyReq.Header.Set(s3_constants.SeaweedFSSSES3Key, base64.StdEncoding.EncodeToString(sseS3Metadata)) glog.V(3).Infof("putToFiler: storing SSE-S3 metadata for object %s with keyID %s", uploadUrl, sseS3Key.KeyID) } - if s3a.option.AllowDeleteObjectsByTTL { - proxyReq.Header.Set(s3_constants.SeaweedFSExpiresS3, "true") - } + // Set TTL-based S3 expiry (modification time) + proxyReq.Header.Set(s3_constants.SeaweedFSExpiresS3, "true") // ensure that the Authorization header is overriding any previous // Authorization header which might be already present in proxyReq s3a.maybeAddFilerJwtAuthorization(proxyReq, true) diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index baf28b237..e21886c57 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -41,7 +41,6 @@ type S3ApiServerOption struct { GrpcDialOption grpc.DialOption AllowEmptyFolder bool AllowDeleteBucketNotEmpty bool - AllowDeleteObjectsByTTL bool LocalFilerSocket string DataCenter string FilerGroup string