-
Notifications
You must be signed in to change notification settings - Fork 594
HDDS-12784. Add bucket object ID to lifecycle configuration proto definition #9255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds bucket object ID tracking to lifecycle configurations to prevent stale lifecycle policies from being applied after bucket recreation. The main goal is to ensure that lifecycle configurations are invalidated when a bucket is deleted and recreated with the same name but a different object ID.
Key changes:
- Added
bucketObjectIDfield toOmLifecycleConfigurationto track the bucket instance - Modified lifecycle configuration validation to check bucket object ID matching
- Updated bucket deletion to clean up associated lifecycle configurations
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| OmClientProtocol.proto | Added bucketObjectID field to LifecycleConfiguration message |
| OmLifecycleConfiguration.java | Added bucketObjectID field with getter/setter, removed @Immutable annotation, updated serialization/deserialization |
| OMLifecycleConfigurationSetRequest.java | Sets bucketObjectID when creating/updating lifecycle configuration |
| OMLifecycleConfigurationSetResponse.java | Added getter method to expose OmLifecycleConfiguration for testing |
| KeyLifecycleService.java | Added validation to check bucket object ID matches before applying lifecycle policies |
| OMBucketDeleteResponse.java | Added lifecycle configuration table to cleanup tables list |
| S3LifecycleConfiguration.java | Added comment explaining why OzoneBucket doesn't have objectID info |
| TestOMLifecycleConfigurationSetRequest.java | Added test assertion to verify bucketObjectID is set correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public static final int LC_MAX_RULES = 1000; | ||
| private final String volume; | ||
| private final String bucket; | ||
| private long bucketObjectID = -1L; |
Copilot
AI
Nov 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field bucketObjectID should be marked as final and initialized through the constructor. The current implementation with a setter method violates immutability principles and makes the class susceptible to being modified after construction, which can lead to thread-safety issues. If mutability is required, consider documenting why the @Immutable annotation was removed and the implications for thread safety.
| private long bucketObjectID = -1L; | |
| private final long bucketObjectID; |
ivandika3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChenSammi Thanks for the improvement. Left come comments.
Since the OMBucketDeleteRequest will also delete the lifecycle configuration, technically the bucket object ID mismatch should not happen. However, it's good to double check.
...manager/src/main/java/org/apache/hadoop/ozone/om/response/bucket/OMBucketDeleteResponse.java
Show resolved
Hide resolved
...in/java/org/apache/hadoop/ozone/om/request/lifecycle/OMLifecycleConfigurationSetRequest.java
Outdated
Show resolved
Hide resolved
...zone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/KeyLifecycleService.java
Show resolved
Hide resolved
...-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmLifecycleConfiguration.java
Outdated
Show resolved
Hide resolved
@ivandika3 , this is mainly for upgrade-downgrade-upgrade consideration. After discuss with Xi, we plan to not introduce new OM layout feature. In case of upgrade-downgrade-upgrade, to prevent a bucket with LifecycleConfiguration created during upgrade, but not finalized, then system is downgraded, this LifecycleConfiguration will be left in the DB table, then later the cluster is upgraded again. If the bucket is deleted before that, and a new bucket with same name is created, then this new bucket should not be linked to the LifecycleConfiguration in the DB table. To detect this, we need object ID to compare weather it's the same bucket or a differnt bucket. |
|
@ChenSammi Thanks for the explanation. Makes sense. |
Seems some tests are timeout. |
ivandika3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. LGTM +1.
| .setObjectID(getObjectID()) | ||
| .setUpdateID(getUpdateID()); | ||
|
|
||
| if (bucketObjectID != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can set bucketObjectID to -1 or some other special value, so that the bucketObjectID of the version containing the Lifecycle feature will definitely have one valid bucket ObjectID (it is not -1), ultimately achieving the same effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conflicts with my review #9255 (comment) , IMO it's better to explicitly set to null.
| } | ||
| } | ||
|
|
||
| // OzoneBucket doesn't have objectID info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be fine; OM itself knows the bucket's ObjectID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is the reason that OmLifecycleConfiguration object created by this function doesn't have bucket's objectID set because it doesn't know the ID from OzoneBucket. I put this comment here to help reminder in case I forget later.
| omLifecycleConfiguration.valid(); | ||
| auditMap = omLifecycleConfiguration.toAuditMap(); | ||
|
|
||
| omLifecycleConfiguration.setUpdateID(transactionLogIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the OmLifecycleConfiguration is not a @Immutable, since it can be modified, maybe we should remove the @immutable on the OmLifecycleConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the @immutable in next path, where I plan to add an option to enable/disable move to trash support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OmLifecycleConfiguration inherits mutability from its parent class WithObjectID. Still, we should strive to eliminate mutability, not introduce further. Please prefer creating modified copy via the builder.
|
Thanks @ivandika3 and @xichen01 for the review. |
What changes were proposed in this pull request?
save bucket object ID in LifeCycleConfiguration, capable to detect same bucket name, actually different bucket case.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-12784
How was this patch tested?
new unit test