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

fix(pubsub): do not overwrite ConnectionOptions #7406

Merged
merged 2 commits into from
Oct 5, 2021

Conversation

dbolduc
Copy link
Member

@dbolduc dbolduc commented Oct 5, 2021

When PublisherOptions is constructed, we default all options, including ones covered by ConnectionOptions, for example, GrpcCredentialOption.

opts_ = pubsub_internal::DefaultPublisherOptions(std::move(opts));

return DefaultCommonOptions(std::move(opts));

This means that when we merge options here ....

std::shared_ptr<PublisherConnection> MakePublisherConnection(
Topic topic, PublisherOptions options, ConnectionOptions connection_options,
std::unique_ptr<pubsub::RetryPolicy const> retry_policy,
std::unique_ptr<pubsub::BackoffPolicy const> backoff_policy) {
auto opts = internal::MergeOptions(
pubsub_internal::MakeOptions(std::move(options)),
internal::MakeOptions(std::move(connection_options)));

.... we try to merge user-set options contained in ConnectionOptions but ignore them because those options all have default values from PublisherOptions.

(I am saying we, but this is solely @dbolduc's fault)

This is a disaster if users try to authenticate with custom credentials passed to ConnectionOptions. Also, the same is true for the Subscriber version of things.

To fix the problem, I could have just switched the order of the merge so that the PublisherOptions are merged into the ConnectionOptions. But I decided it would be better (and easier to test) that PublisherOptions only defaults options from the PublisherOptionList.


This change is Reviewable

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Oct 5, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 5, 2021
@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: eeb1272288e785a7e99d1f85b738d1f49ca0cc4d

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

@dbolduc dbolduc marked this pull request as ready for review October 5, 2021 20:24
@dbolduc dbolduc requested a review from a team as a code owner October 5, 2021 20:24
google/cloud/pubsub/internal/defaults_test.cc Show resolved Hide resolved
google/cloud/pubsub/internal/defaults.cc Outdated Show resolved Hide resolved
google/cloud/pubsub/internal/defaults.cc Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #7406 (d1653e0) into main (39d87d4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7406   +/-   ##
=======================================
  Coverage   93.65%   93.65%           
=======================================
  Files        1351     1351           
  Lines      117334   117381   +47     
=======================================
+ Hits       109886   109935   +49     
+ Misses       7448     7446    -2     
Impacted Files Coverage Δ
google/cloud/pubsub/internal/defaults.cc 100.00% <100.00%> (ø)
google/cloud/pubsub/internal/defaults_test.cc 100.00% <100.00%> (ø)
google/cloud/pubsub/publisher_options.cc 100.00% <100.00%> (ø)
google/cloud/pubsub/publisher_options_test.cc 100.00% <100.00%> (ø)
google/cloud/pubsub/subscriber_options.cc 100.00% <100.00%> (ø)
google/cloud/pubsub/subscriber_options_test.cc 100.00% <100.00%> (ø)
...ud/spanner/integration_tests/client_stress_test.cc 85.52% <0.00%> (-0.66%) ⬇️
...cloud/pubsub/internal/subscription_session_test.cc 98.00% <0.00%> (+0.24%) ⬆️
google/cloud/grpc_error_delegate.cc 100.00% <0.00%> (+4.16%) ⬆️

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 39d87d4...d1653e0. Read the comment docs.

@google-cloud-cpp-bot
Copy link
Collaborator

Google Cloud Build Logs
For commit: d1653e095d189b58bdd6639c6bbbe63ee2a9022d

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

@dbolduc dbolduc merged commit 9d7be2a into googleapis:main Oct 5, 2021
@dbolduc dbolduc deleted the pubsub-fix-default-options branch January 15, 2022 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. 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