Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

enforce bucket quota

chrislue47f63d15987
diff --git a/weed/shell/command_s3_bucket_quota_check.go b/weed/shell/command_s3_bucket_quota_check.go
index fc8291148a..3620b92edc 100644
--- a/weed/shell/command_s3_bucket_quota_check.go
+++ b/weed/shell/command_s3_bucket_quota_check.go
@@ -11,28 +11,28 @@ import (
)
func init() {
- Commands = append(Commands, &commandS3BucketQuotaCheck{})
+ Commands = append(Commands, &commandS3BucketQuotaEnforce{})
}
-type commandS3BucketQuotaCheck struct {
+type commandS3BucketQuotaEnforce struct {
}
-func (c *commandS3BucketQuotaCheck) Name() string {
- return "s3.bucket.quota.check"
+func (c *commandS3BucketQuotaEnforce) Name() string {
+ return "s3.bucket.quota.enforce"
}
-func (c *commandS3BucketQuotaCheck) Help() string {
+func (c *commandS3BucketQuotaEnforce) Help() string {
return `check quota for all buckets, make the bucket read only if over the limit
Example:
- s3.bucket.quota.check -force
+ s3.bucket.quota.enforce -apply
`
}
-func (c *commandS3BucketQuotaCheck) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
+func (c *commandS3BucketQuotaEnforce) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
bucketCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- enforceQuotaLimit := bucketCommand.Bool("force", false, "actually change the buckets readonly attribute")
+ applyQuotaLimit := bucketCommand.Bool("apply", false, "actually change the buckets readonly attribute")
if err = bucketCommand.Parse(args); err != nil {
return nil
}
@@ -79,11 +79,14 @@ func (c *commandS3BucketQuotaCheck) Do(args []string, commandEnv *CommandEnv, wr
}
// apply the configuration changes
- if hasConfChanges && *enforceQuotaLimit {
+ if hasConfChanges && *applyQuotaLimit {
var buf2 bytes.Buffer
fc.ToText(&buf2)
+ fmt.Fprintf(writer, string(buf2.Bytes()))
+ fmt.Fprintln(writer)
+
if err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
return filer.SaveInsideFiler(client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, buf2.Bytes())
}); err != nil && err != filer_pb.ErrNotFound {
@@ -95,16 +98,11 @@ func (c *commandS3BucketQuotaCheck) Do(args []string, commandEnv *CommandEnv, wr
}
-func (c *commandS3BucketQuotaCheck) processEachBucket(fc *filer.FilerConf, filerBucketsPath string, entry *filer_pb.Entry, writer io.Writer, collectionSize uint64) (hasConfChanges bool) {
+func (c *commandS3BucketQuotaEnforce) processEachBucket(fc *filer.FilerConf, filerBucketsPath string, entry *filer_pb.Entry, writer io.Writer, collectionSize uint64) (hasConfChanges bool) {
locPrefix := filerBucketsPath + "/" + entry.Name + "/"
locConf := fc.MatchStorageRule(locPrefix)
- if locConf == nil {
- locConf = &filer_pb.FilerConf_PathConf{
- LocationPrefix: locPrefix,
- Collection: entry.Name,
- }
- }
+ locConf.LocationPrefix = locPrefix
if entry.Quota > 0 {
if locConf.ReadOnly {