Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

feat: add object retention feature - #2277

Merged
JesseLovelace merged 16 commits into
mainfrom
objlock
Nov 30, 2023
Merged

JesseLovelace merged 16 commits into
mainfrom
objlock

Conversation

@JesseLovelace

Copy link
Copy Markdown
Contributor

Adds the object retention feature and tests

@JesseLovelace
JesseLovelace requested review from a team and BenWhitehead 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 October 24, 2023 22:20

public static Builder newBuilder() {
return new Builder();
}

Copy link
Copy Markdown
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
Copy Markdown
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()) {

dateTimeCodec::encode,
to::setRetentionExpirationTime);
if (from.getRetention() == null) {
to.setRetention(Data.nullOf(StorageObject.Retention.class));

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.

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

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

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
Copy Markdown
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
Copy Markdown
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
@JesseLovelace
JesseLovelace deleted the objlock branch November 30, 2023 20:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

4 participants