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(generator): generate a SetIamPolicy() overload with an OCC loop #7276

Merged
merged 2 commits into from
Sep 7, 2021

Conversation

devbww
Copy link
Contributor

@devbww devbww commented Sep 7, 2021

For generated clients with standard GetIamPolicy() and SetIamPolicy()
operations, also generate a SetIamPolicy() overload that implements an
optimistic concurrency control loop, where the Policy.etag field is
used to prevent simultaneous updates of a policy from overwriting each
other.

Fixes #7168.


This change is Reviewable

For generated clients with standard `GetIamPolicy()` and `SetIamPolicy()`
operations, also generate a `SetIamPolicy()` overload that implements an
optimistic concurrency control loop, where the `Policy.etag` field is
used to prevent simultaneous updates of a policy from overwriting each
other.

Fixes googleapis#7168.
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 7, 2021
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 7, 2021
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: dd74da0d5833a86116471233484b6395ba7a1a32

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

@codecov
Copy link

codecov bot commented Sep 7, 2021

Codecov Report

Merging #7276 (4d3950b) into main (2c8f98c) will increase coverage by 0.00%.
The diff coverage is 93.23%.

Impacted file tree graph

@@           Coverage Diff            @@
##             main    #7276    +/-   ##
========================================
  Coverage   94.34%   94.34%            
========================================
  Files        1317     1317            
  Lines      114594   114799   +205     
========================================
+ Hits       108109   108304   +195     
- Misses       6485     6495    +10     
Impacted Files Coverage Δ
...tegration_tests/golden/golden_thing_admin_client.h 100.00% <ø> (ø)
generator/internal/client_generator.h 100.00% <ø> (ø)
...loud/iam/integration_tests/iam_integration_test.cc 74.33% <62.50%> (-0.37%) ⬇️
google/cloud/iam/iam_client.cc 89.68% <68.75%> (-3.05%) ⬇️
...sts/golden/tests/golden_thing_admin_client_test.cc 98.08% <97.54%> (-0.15%) ⬇️
...egration_tests/golden/golden_thing_admin_client.cc 100.00% <100.00%> (ø)
generator/internal/client_generator.cc 100.00% <100.00%> (ø)
...bigtable/examples/bigtable_hello_instance_admin.cc 81.31% <0.00%> (-2.20%) ⬇️
google/cloud/pubsub/samples/samples.cc 91.75% <0.00%> (+0.07%) ⬆️
.../cloud/storage/benchmarks/throughput_experiment.cc 74.87% <0.00%> (+0.50%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c8f98c...4d3950b. Read the comment docs.

@devbww devbww marked this pull request as ready for review September 7, 2021 05:55
@devbww devbww requested a review from a team as a code owner September 7, 2021 05:55
Copy link
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

One alternative for the comment formatting, your call.

" * Updates the IAM policy for @p resource using an"
" optimistic concurrency control loop.\n"
" *\n"
" * The loop fetches the current policy for @p resource, and"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the lack of \n in these comments make the output into a very long line. Seems like you decided to rely on clang-format? As an alternative, consider using a raw string to make the formatting more obvious?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, although in the long run I suspect we may well be better off relying on clang-format to do all the formatting rather than only part of it.

@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: 4d3950b937814e6f7899e9100c6f544687186e0b

ℹ️ NOTE: Kokoro logs are linked from "Details" below.

Copy link
Member

@scotthart scotthart left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 12 files reviewed, 1 unresolved discussion (waiting on @devbww)


generator/internal/client_generator.cc, line 76 at r2 (raw file):

                       "google/cloud/polling_policy.h",
                       "google/cloud/status_or.h", "google/cloud/version.h"});
  if (get_iam_policy_extension_ && set_iam_policy_extension_) {

There's no guarantee (that I'm aware of) that either or both GetIamPolicy and SetIamPolicy rpcs have method_signature options. It's just proved true so far in the handful of services we've encountered. It might be better to use the proto request/response typed rpcs directly.

Copy link
Contributor Author

@devbww devbww left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 12 files reviewed, 1 unresolved discussion (waiting on @scotthart)


generator/internal/client_generator.cc, line 76 at r2 (raw file):

Previously, scotthart (Scott Hart) wrote…

There's no guarantee (that I'm aware of) that either or both GetIamPolicy and SetIamPolicy rpcs have method_signature options. It's just proved true so far in the handful of services we've encountered. It might be better to use the proto request/response typed rpcs directly.

The logic was that if they don't have the "resource" and "resource,policy" signature extensions respectively, then we don't want to generate a "resource,updater" extension either. That is, if the service only uses the proto request/response types, then that is all you get.

Copy link
Member

@scotthart scotthart left a comment

Choose a reason for hiding this comment

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

Reviewed 10 of 12 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @devbww)

@devbww devbww merged commit e678cf3 into googleapis:main Sep 7, 2021
@devbww devbww deleted the refactor-iamupdater branch September 7, 2021 18:31
@@ -26,6 +26,7 @@ google_cloud_cpp_common_hdrs = [
"iam_binding.h",
"iam_bindings.h",
"iam_policy.h",
"iam_updater.h",
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 like the wrong place for these headers, since they seem to depend on gRPC and this list is for the "common" deps, which shouldn't have a dep on grpc. I suspect the other iam-related headers that already existed here may be in the wrong place too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iam_updater.h moved in #7287.

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.

Implement generic IAM update loop to common
6 participants