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

[Storage] Bucket lock samples and bug fixes. #3709

Merged
merged 4 commits into from
Sep 22, 2018

Conversation

frankyn
Copy link
Member

@frankyn frankyn commented Sep 20, 2018

Bug fixes from sample review

  • Clean up comments for Boolean types in the Storage client library to explain possible states.
  • Fix Integration tests that kept failing due to objects with retention by releasing holds during cleanup.
  • Fix bug in client library not allowing to clear retentionPolicy correctly.
  • Be consistent with how Booleans are handled between Bucket and Blob classes.
  • Reformat BlobInfo and BucketInfo classes.

Samples

  • Update storage snippets bucket clean up to follow integration tests.
  • Define a retention policy
  • Remove a retention policy if not locked
  • Lock a retention policy
  • Set temporary hold
  • Release temporary hold
  • Set event-based hold
  • Release event-based hold
  • Set default event-based hold
  • Release default event-based hold
  • View default event-based hold
  • View bucket retention policy metadata
  • View metadata for object
  • Run formatter.

@frankyn frankyn requested review from pongad and kurtisvg September 20, 2018 20:30
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 20, 2018
for (Blob blob : bucket.list(BlobListOption.fields(Storage.BlobField.EVENT_BASED_HOLD,
Storage.BlobField.TEMPORARY_HOLD)).iterateAll()) {
if(blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
BlobInfo.Builder blobBuilder = BlobInfo.newBuilder(bucket.getName(), blob.getName());

This comment was marked as spam.

This comment was marked as spam.

System.out.println("Last Metadata Update: " + new Date(blob.getUpdateTime()));
System.out.println(
"temporaryHold: "
+ (blob.getTemporaryHold() != null && blob.getTemporaryHold()

This comment was marked as spam.

This comment was marked as spam.

if (blob.getMetadata() != null) {
System.out.println("User metadata:");
for (Map.Entry<String, String> userMetadata : blob.getMetadata().entrySet()) {
System.out.println(userMetadata.getKey() + " " + userMetadata.getValue());

This comment was marked as spam.

This comment was marked as spam.

Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.RETENTION_POLICY));
if (bucket.retentionPolicyIsLocked() != null && bucket.retentionPolicyIsLocked()) {
System.out.println("Unable to remove retention period as retention policy is locked.");
return bucket;

This comment was marked as spam.

This comment was marked as spam.

return bucket;
}

Bucket updated_bucket = bucket.toBuilder().setRetentionPeriod(null).build().update();

This comment was marked as spam.

This comment was marked as spam.

Bucket bucket = storage.get(bucketName, BucketGetOption.fields(BucketField.RETENTION_POLICY));

System.out.println("Retention Policy for " + bucketName);

This comment was marked as spam.

This comment was marked as spam.


Bucket bucket =
storage.get(bucketName, Storage.BucketGetOption.fields(BucketField.METAGENERATION));
Bucket updated_bucket =

This comment was marked as spam.

This comment was marked as spam.

Bucket bucket =
storage.get(bucketName, BucketGetOption.fields(BucketField.DEFAULT_EVENT_BASED_HOLD));

if (bucket.getDefaultEventBasedHold() == true) {

This comment was marked as spam.

This comment was marked as spam.

@frankyn
Copy link
Member Author

frankyn commented Sep 20, 2018

Comments addressed. @kurtisvg PTAL

Copy link
Contributor

@kurtisvg kurtisvg left a comment

Choose a reason for hiding this comment

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

LGTM

@pongad pongad removed their request for review September 21, 2018 05:42
@frankyn
Copy link
Member Author

frankyn commented Sep 22, 2018

Merging for now and following up in a separate PR to resolve devex issues.

@frankyn frankyn merged commit c55c3b7 into gcs-bucket-lock-ready Sep 22, 2018
@frankyn frankyn deleted the gcs-bucket-lock-samples branch September 22, 2018 17:26
@frankyn frankyn mentioned this pull request Sep 25, 2018
frankyn added a commit that referenced this pull request Sep 28, 2018
* [Storage] Replay GCS Bucket Lock (#3645)

* Add support for defaultEventBasedHold

* Add support for Blob eventBasedHold

* Add support for blob temporary holds

* Remove Beta launch annotations for CMEK

* Add support for lockRetentionPolicy and RetentionPolicy

* Update FakeStorageRPC

* codacy-bot review fix (final only)

* Update getRetentionPolicyIsLocked() -> retentionPolicyIsLocked() and misc.

* Address comments

* Address comments

* Address comments.

* Small nits

* Fix additional comments

* [Storage] Bucket lock samples and bug fixes. (#3709)

* Fix issue in tests, write bucket lock samples, and resolve issue in client library

* Update documentation around Boolean returns to clarify different return caes.

* Fix broken unit test

* Address feedback

* Fix typo in comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants