Skip to content

Conversation

@ChenSammi
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a 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 bucketObjectID field to OmLifecycleConfiguration to 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;
Copy link

Copilot AI Nov 6, 2025

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.

Suggested change
private long bucketObjectID = -1L;
private final long bucketObjectID;

Copilot uses AI. Check for mistakes.
@ivandika3 ivandika3 added the s3-lifecycle HDDS-8342 label Nov 7, 2025
Copy link
Contributor

@ivandika3 ivandika3 left a 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.

@ChenSammi
Copy link
Contributor Author

ChenSammi commented Nov 7, 2025

@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.

@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.

@ivandika3
Copy link
Contributor

@ChenSammi Thanks for the explanation. Makes sense.

@ivandika3
Copy link
Contributor

Error:  Tests run: 24, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 58.96 s <<< FAILURE! -- in org.apache.hadoop.ozone.om.service.TestKeyLifecycleService$Failing
Error:  org.apache.hadoop.ozone.om.service.TestKeyLifecycleService$Failing.testKeyDeletedOrRenamed(BucketLayout, boolean)[1] -- Time elapsed: 10.40 s <<< ERROR!

Seems some tests are timeout.

Copy link
Contributor

@ivandika3 ivandika3 left a 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) {
Copy link
Contributor

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.

Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor Author

@ChenSammi ChenSammi Nov 14, 2025

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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@ChenSammi ChenSammi merged commit 3b5cb65 into apache:HDDS-8342 Nov 17, 2025
83 of 84 checks passed
@ChenSammi
Copy link
Contributor Author

Thanks @ivandika3 and @xichen01 for the review.

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

Labels

s3-lifecycle HDDS-8342

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants