Skip to content

feat(shell): add Object Lock management commands - #8141

Merged
chrislusf merged 3 commits into
seaweedfs:masterfrom
kvaps:feat/s3-bucket-lock-command
Jan 27, 2026
Merged

chrislusf merged 3 commits into
seaweedfs:masterfrom
kvaps:feat/s3-bucket-lock-command

Conversation

@kvaps

@kvaps kvaps commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add new s3.bucket.lock command to view and enable Object Lock on existing buckets
  • Add -withLock flag to s3.bucket.create for creating buckets with Object Lock enabled

Details

s3.bucket.lock command

Allows administrators to enable Object Lock on existing buckets without recreating them:

s3.bucket.lock -name <bucket>          # view status
s3.bucket.lock -name <bucket> -enable  # enable Object Lock
  • Automatically enables versioning if not already enabled (required for Object Lock)
  • Object Lock cannot be disabled once enabled (per AWS S3 specification)

s3.bucket.create -withLock flag

Creates a new bucket with Object Lock enabled:

s3.bucket.create -name mybucket -withLock

Test plan

  • Test s3.bucket.lock -name <bucket> shows correct status
  • Test s3.bucket.lock -name <bucket> -enable enables Object Lock
  • Test s3.bucket.create -name <bucket> -withLock creates bucket with Object Lock
  • Verify retention can be set after enabling Object Lock

Summary by CodeRabbit

  • New Features
    • Added a -withLock option when creating S3 buckets to enable Object Lock (automatically enables Versioning).
    • Added a new command to view S3 bucket Versioning and Object Lock status.
    • Added the ability to enable Object Lock on existing buckets (with an irreversible confirmation and status feedback).

✏️ Tip: You can customize this high-level summary in your review settings.

kvaps and others added 2 commits January 27, 2026 18:27
Add new weed shell command to view and enable S3 Object Lock on existing
buckets. This allows administrators to enable Object Lock without
recreating buckets, which is useful when buckets already contain data.

The command:
- Shows current Object Lock and Versioning status
- Enables Object Lock with -enable flag (irreversible, per AWS S3 spec)
- Automatically enables Versioning if not already enabled (required for Object Lock)

Usage:
  s3.bucket.lock -name <bucket>          # view status
  s3.bucket.lock -name <bucket> -enable  # enable Object Lock

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
Add support for creating buckets with Object Lock enabled directly from
weed shell. The flag automatically enables versioning as required by
Object Lock.

Usage:
  s3.bucket.create -name mybucket -withLock

Co-Authored-By: Claude <[email protected]>
Signed-off-by: Andrei Kvapil <[email protected]>
@coderabbitai

coderabbitai Bot commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds optional -withLock flag to s3.bucket.create command to enable Object Lock on newly created buckets, and introduces a new s3.bucket.lock shell command for viewing and enabling Object Lock with Versioning on existing buckets.

Changes

Cohort / File(s) Summary
S3 Bucket Creation with Object Lock
weed/shell/command_s3_bucket_create.go
Adds -withLock boolean flag to enable Object Lock during bucket creation; initializes Extended metadata map, sets Versioning and Object Lock attributes, and prints confirmation messages when flag is used.
S3 Bucket Object Lock Management
weed/shell/command_s3_bucket_lock.go
New command for viewing and enabling Object Lock on buckets; validates bucket name, retrieves filer configuration, reads current Extended attributes for Versioning and Object Lock status, and optionally updates bucket metadata with -enable flag (auto-enables Versioning if needed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • seaweedfs/seaweedfs#7854: Modifies S3 bucket Object Lock and Versioning handling by reading/writing the same extended attributes and managing bucket-related metadata operations.
  • seaweedfs/seaweedfs#7734: Adds shared utilities for Object Lock checking and delete-time protections, enhancing S3 bucket Object Lock feature handling.

Poem

🐰 Locks and latches for buckets so grand,
No Object shall leave once sealed by command,
With -withLock and -enable so fine,
Your data's now locked in a vault-proof design,
Safe as a warren, immutable and sound! 🔐

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(shell): add Object Lock management commands' clearly and concisely summarizes the main addition of new S3 Object Lock management functionality to the shell.
Description check ✅ Passed The description covers all major aspects: problem statement (managing Object Lock), solution details (two new features with command syntax), and includes a test plan. While some checkbox items lack explicit fulfillment details, the core required information is present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kvaps, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant enhancements to S3 bucket management by adding comprehensive support for Object Lock. It provides users with flexible options to enable Object Lock, either when creating new buckets or on existing ones, thereby ensuring data immutability and compliance with WORM storage principles. The changes aim to simplify the process of securing data against unauthorized modifications.

Highlights

  • New s3.bucket.lock command: A new command s3.bucket.lock has been introduced. This command allows users to view the current Object Lock status of an existing S3 bucket and to enable Object Lock on it. If versioning is not already enabled on the bucket, this command will automatically enable it, as versioning is a prerequisite for Object Lock.
  • Object Lock enablement during bucket creation: The s3.bucket.create command now includes a new flag, -withLock. When this flag is used, a new S3 bucket will be created with Object Lock enabled from the outset. Similar to enabling Object Lock on existing buckets, this also automatically enables versioning for the newly created bucket.
  • Irreversible Object Lock: Both the new s3.bucket.lock -enable functionality and the s3.bucket.create -withLock flag adhere to the S3 specification that Object Lock, once enabled on a bucket, cannot be disabled. This ensures the Write Once Read Many (WORM) protection is permanent.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@kvaps
kvaps marked this pull request as ready for review January 27, 2026 17:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new shell commands for managing S3 Object Lock. A -withLock flag is added to s3.bucket.create to enable Object Lock on new buckets, and a new s3.bucket.lock command is added to view and enable Object Lock on existing buckets. The implementation is solid and covers the described functionality.

My review found one high-severity issue in the new s3.bucket.lock command where flag parsing errors are silently ignored. Fixing this will improve the command's robustness and user experience. Overall, this is a great addition.

Comment thread weed/shell/command_s3_bucket_lock.go Resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@chrislusf
chrislusf merged commit b1d63d0 into seaweedfs:master Jan 27, 2026
40 of 41 checks passed
@chrislusf

Copy link
Copy Markdown
Collaborator

thanks! Maybe adds similar commands to enable/pause bucket versioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants