Skip to content
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

feat: add object retention feature #2277

Merged
merged 16 commits into from
Nov 30, 2023
Merged

feat: add object retention feature #2277

merged 16 commits into from
Nov 30, 2023

Conversation

JesseLovelace
Copy link
Contributor

Adds the object retention feature and tests

@JesseLovelace JesseLovelace requested a review from a team as a code owner October 24, 2023 22:17
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. labels Oct 24, 2023
@gcf-owl-bot gcf-owl-bot bot requested a review from a team as a code owner October 24, 2023 22:20

public static Builder newBuilder() {
return new Builder();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't remember, do we usually do toBuilder() for the nested model classes or only the top level ones?

Comment on lines +427 to +432
// Create a bucket with object retention enabled
storage.create(
BucketInfo.newBuilder(bucketName).build(), BucketTargetOption.enableObjectRetention(true));

try {
Bucket remoteBucket = storage.get(bucketName);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If interested, you could use the TemporaryBucket helper to create and automatically cleanup the bucket. Example of this

try (TemporaryBucket tempB =
TemporaryBucket.newBuilder().setBucketInfo(bucketInfo).setStorage(storage).build()) {

@@ -238,6 +246,11 @@ private StorageObject blobInfoEncode(BlobInfo from) {
from.getRetentionExpirationTimeOffsetDateTime(),
dateTimeCodec::encode,
to::setRetentionExpirationTime);
if (from.getRetention() == null) {
to.setRetention(Data.nullOf(StorageObject.Retention.class));
Copy link
Member

Choose a reason for hiding this comment

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

What was the conclusion on detecting if a user set retention to null vs. it not being modified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't work, due to the modified fields not being passed along to the final patch call. I talked to ben and we agreed to just do it this way, there's precedent for it in the logging encoding

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for clarifying, is this value mutable once set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only certain cases work (i.e. going from Unlocked to Locked, reducing the retainUntilTime on an unlocked policy, and setting to null), and you have to pass in overrideUnlockedRetention for any of those cases to work, but yes

@BenWhitehead BenWhitehead added the owlbot:ignore instruct owl-bot to ignore a PR label Oct 25, 2023
@BenWhitehead BenWhitehead dismissed their stale review October 25, 2023 21:23

No longer blocking, but tests can't pass yet so not approving

@JesseLovelace
Copy link
Contributor Author

The current failure is just because the test project isn't allowlisted yet, it should be soon

@JesseLovelace JesseLovelace added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 6, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 6, 2023
@JesseLovelace JesseLovelace added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2023
@yoshi-kokoro yoshi-kokoro removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Nov 13, 2023
@JesseLovelace JesseLovelace merged commit 3deb29b into main Nov 30, 2023
20 checks passed
@JesseLovelace JesseLovelace deleted the objlock branch November 30, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. owlbot:ignore instruct owl-bot to ignore a PR size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants