google-cloud-ruby: [BREAKING PRODUCTION] Error when attempting to add a retry policy to a pubsub subscription

Environment details

  • OS: Mac and Linux
  • Ruby version: 2.7.1
  • Gem name and version: google-cloud-pubsub v2.3.0

Steps to reproduce

Attempting to set a retry policy on a subscription that already exists is now breaking. It used to work, but now errors out causing for our production application not to boot:

subscription.retry_policy = Google::Cloud::PubSub::RetryPolicy.new(
  minimum_backoff: CloudPubsub.config.auto_retry.minimum_backoff,
  maximum_backoff: CloudPubsub.config.auto_retry.maximum_backoff
)

And here is our pre-existing subscription:

<Google::Cloud::PubSub::V1::Subscription: name: "projects/adhawk-franchises-development/subscriptions/development.retailer.ctm_answer_call", topic: "", push_config: nil, ack_deadline_seconds: 0, retain_acked_messages: false, message_retention_duration: nil, labels: {}, enable_message_ordering: false, expiration_policy: nil, filter: "", dead_letter_policy: nil, retry_policy: <Google::Cloud::PubSub::V1::RetryPolicy: minimum_backoff: <Google::Protobuf::Duration: seconds: 30, nanos: 0>, maximum_backoff: <Google::Protobuf::Duration: seconds: 600, nanos: 0>>, detached: false>

Full backtrace

Google::Cloud::InvalidArgumentError: 3:Invalid resource name given (name=). Refer to https://cloud.google.com/pubsub/docs/admin#resource_names for more information.. debug_error_string:{"created":"@1607295488.846134000","description":"Error received from peer ipv4:142.250.73.202:443","file":"src/core/lib/surface/call.cc","file_line":1063,"grpc_message":"Invalid resource name given (name=). Refer to https://cloud.google.com/pubsub/docs/admin#resource_names for more information.","grpc_status":3}
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/google-cloud-pubsub-v1-0.1.2/lib/google/cloud/pubsub/v1/subscriber/client.rb:578:in `rescue in update_subscription'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/google-cloud-pubsub-v1-0.1.2/lib/google/cloud/pubsub/v1/subscriber/client.rb:544:in `update_subscription'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/google-cloud-pubsub-2.3.0/lib/google/cloud/pubsub/service.rb:194:in `update_subscription'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/google-cloud-pubsub-2.3.0/lib/google/cloud/pubsub/subscription.rb:594:in `retry_policy='
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/lib/hanami/events/cloud_pubsub/listener.rb:140:in `apply_retry_options'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/lib/hanami/events/cloud_pubsub/listener.rb:43:in `register'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/lib/hanami/events/adapter/cloud_pubsub.rb:91:in `register_listener'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/lib/hanami/events/adapter/cloud_pubsub.rb:67:in `subscribe'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/bundler/gems/events-59a36d22b75e/lib/hanami/events/base.rb:36:in `subscribe'
  /Users/ianks/Code/tatami/lib/subscribers/base.rb:29:in `setup_event_handler'
  /Users/ianks/Code/tatami/lib/subscribers/base.rb:23:in `subscribe_to'
  /Users/ianks/Code/tatami/apps/retailer/subscribers/call_tracking_metrics/answer_call.rb:10:in `<class:AnswerCall>'
  /Users/ianks/Code/tatami/apps/retailer/subscribers/call_tracking_metrics/answer_call.rb:9:in `<module:CallTrackingMetrics>'
  /Users/ianks/Code/tatami/apps/retailer/subscribers/call_tracking_metrics/answer_call.rb:8:in `<module:Subscribers>'
  /Users/ianks/Code/tatami/apps/retailer/subscribers/call_tracking_metrics/answer_call.rb:7:in `<module:Retailer>'
  /Users/ianks/Code/tatami/apps/retailer/subscribers/call_tracking_metrics/answer_call.rb:6:in `<main>'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-utils-1.3.6/lib/hanami/utils.rb:54:in `block in require!'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-utils-1.3.6/lib/hanami/utils.rb:92:in `each'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-utils-1.3.6/lib/hanami/utils.rb:92:in `for_each_file_in'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-utils-1.3.6/lib/hanami/utils.rb:54:in `require!'
  /Users/ianks/Code/tatami/config/environment.rb:116:in `block (3 levels) in <top (required)>'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/lib/hanami/events/cloud_pubsub/cli.rb:49:in `load_subscriptions'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/lib/hanami/events/cloud_pubsub/cli.rb:39:in `call'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-cli-0.3.1/lib/hanami/cli.rb:57:in `call'
  /Users/ianks/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/hanami-events-cloud_pubsub-3.0.3/exe/cloudpubsub:8:in `<top (required)>'
  /Users/ianks/.asdf/installs/ruby/2.7.1/bin/cloudpubsub:23:in `load'
  /Users/ianks/.asdf/installs/ruby/2.7.1/bin/cloudpubsub:23:in `<top (required)>'

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@quartzmo sorry for missing this post. Yes I believe adding it to the documentation would have been the right decision.

However, the fix is now live so the mitigation technique is no longer necessary.

@ianks could you confirm you are no longer impacted?

@quartzmo I was able to recreate this in the test suite using the same project, and the subscriptions / topics from our dev project:

    it "allows updating the retry policy of a found subscription (issue #8237)" do
      top = pubsub.find_topic("projects/adhawk-franchises-development/topics/development.ctm.answer_call")
      subscription = top.find_subscription "development.retailer.ctm_answer_call"
      subscription.retry_policy = Google::Cloud::PubSub::RetryPolicy.new
      _(subscription.retry_policy.minimum_backoff).must_equal 10 # Default value
      _(subscription.retry_policy.maximum_backoff).must_equal 600 # Default value

      subscription.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: retry_minimum_backoff
      _(subscription.retry_policy.minimum_backoff).must_equal retry_minimum_backoff
      _(subscription.retry_policy.maximum_backoff).must_equal 600 # Default value


      subscription.retry_policy = Google::Cloud::PubSub::RetryPolicy.new maximum_backoff: retry_maximum_backoff
      _(subscription.retry_policy.minimum_backoff).must_equal 10 # Default value
      _(subscription.retry_policy.maximum_backoff).must_equal retry_maximum_backoff
    end
Finished in 10.391834s, 0.0962 runs/s, 0.0962 assertions/s.

  1) Error:
Google::Cloud::PubSub::pubsub::Subscription on Topic#test_0002_allows updating the retry policy of a found subscription (issue #8237):
Google::Cloud::InvalidArgumentError: 3:Invalid resource name given (name=). Refer to https://cloud.google.com/pubsub/docs/admin#resource_names for more information.. debug_error_string:{"created":"@1607395008.698892000","description":"Error received from peer ipv4:142.250.73.202:443","file":"src/core/lib/surface/call.cc","file_line":1063,"grpc_message":"Invalid resource name given (name=). Refer to https://cloud.google.com/pubsub/docs/admin#resource_names for more information.","grpc_status":3}
    /Users/ianks/Code/google-cloud-ruby/google-cloud-pubsub-v1/lib/google/cloud/pubsub/v1/subscriber/client.rb:578:in `rescue in update_subscription'
    /Users/ianks/Code/google-cloud-ruby/google-cloud-pubsub-v1/lib/google/cloud/pubsub/v1/subscriber/client.rb:544:in `update_subscription'
    /Users/ianks/Code/google-cloud-ruby/google-cloud-pubsub/lib/google/cloud/pubsub/service.rb:194:in `update_subscription'
    /Users/ianks/Code/google-cloud-ruby/google-cloud-pubsub/lib/google/cloud/pubsub/subscription.rb:594:in `retry_policy='
    /Users/ianks/Code/google-cloud-ruby/google-cloud-pubsub/acceptance/pubsub/pubsub_test.rb:151:in `block (3 levels) in <top (required)>'