Skip to content

Conversation

@frankyn
Copy link
Contributor

@frankyn frankyn commented Jun 6, 2022

Add remaining fields for Bucket metadata (defaultObjectAcls, Owner, Logging, Cors, and IamConfiguration)
Fix OLM deleteRules encode/decode to only function when Rules are exactly what's expected otherwise return null.

@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 Jun 6, 2022
@frankyn frankyn marked this pull request as ready for review June 6, 2022 22:36
@frankyn frankyn requested a review from a team as a code owner June 6, 2022 22:36
}

private Bucket.Lifecycle buildLifecyclePolicy(BucketInfo from) {
// Handle duplicate rules introduced by deleteRules using a backing ImmutableSet
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Handling duplicates, what are your thoughts @BenWhitehead; I'm deduping proto Rule message types, but not sure if equals() will handle unknown fields as different. Looking into this next; but thought you may already know.

Copy link
Contributor Author

@frankyn frankyn Jun 10, 2022

Choose a reason for hiding this comment

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

Looks like this should be okay, tested an unknown field on Rule (thankfully action and condition are both messages as well): Let me know if I goofed.

// The following passes
  @Test
  public void assertNotEqualWithUnknownField() {
    com.google.storage.v2.Bucket.Lifecycle.Rule rule =
        com.google.storage.v2.Bucket.Lifecycle.Rule.getDefaultInstance();

    assertNotEquals(
        com.google.storage.v2.Bucket.Lifecycle.Rule.getDefaultInstance()
            .toBuilder()
            .setUnknownFields(
                UnknownFieldSet.newBuilder()
                    .addField(100, UnknownFieldSet.Field.newBuilder().addFixed32(10).build())
                    .build()).build(), com.google.storage.v2.Bucket.Lifecycle.Rule.getDefaultInstance());
  }

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, duplicates is an interesting case that we haven't thus far accounted for.

In fact the existing BucketInfo.fromPb[1] is duplicating and not deduplicating later.

I think we're going to want to start another PR after merging this one, where we actually go through and remove all internal usage of DeleteRule and instead translate the respective delete rule operations into the correct operations for lifecycle rules. Then, we can remove this duplication from both the apiary and grpc converters.

Regarding handling of unknown fields, we only have to account for them when decoding to BlobInfo. Once the BlobInfo is decoded, the unknown fields will effectively be abandoned.

[1] https://github.com/googleapis/java-storage/blob/main/google-cloud-storage/src/main/java/com/google/cloud/storage/BucketInfo.java#L2200-L2219

Copy link
Collaborator

Choose a reason for hiding this comment

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

We spoke offline, we're going to open a separate PR to remove the duplication in BucketInfo and instead shim the old DeleteRules over exclusively LifecycleRules

@BenWhitehead BenWhitehead merged commit c76b8db into feat/grpc-storage Jun 10, 2022
@BenWhitehead BenWhitehead deleted the bucket-metadata-grpc branch June 10, 2022 18:54
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. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants