google-api-ruby-client icon indicating copy to clipboard operation
google-api-ruby-client copied to clipboard

Document backoff semantics for create_profile

Open bitglue opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe.

I'm trying to implement an agent for Cloud Profiler, but I'm not sure how it should behave. According to the documentation, the server can request the client to back off through some GRPC metadata:

https://github.com/googleapis/google-api-ruby-client/blob/889330f35e45221df1f0ec6f974e28480b7471f0/generated/google/apis/cloudprofiler_v2/service.rb#L50-L58

However, I can't find anything that specifies how this maps to the JSON API.

Sometimes, I've received an HTTP 409 response with an error like "generic::aborted: action throttled, backoff for 44m0s". Maybe this is what the documentation is talking about? I'm not sure. Parsing the duration out of a string doesn't seem ideal. It's difficult to explore, because it's difficult to solicit this response.

Oddly, the documentation says this should happen in about 1 minute, but when I've had it happen, it's taken more like 230 seconds. This is longer than the default 60 second timeout on this method.

Furthermore, I don't always get the 409 response even with a longer timeout. I've tried increasing the timeout to as much as 1 hour, and usually I'll get <Google::Apis::TransmissionError: execution expired> at the end of that hour, instead of the HTTP 409.

I definitely want to respect the prescribed client behavior here, because the alternative is getting rate limited and that's no good.

Not sure if there's already logic in this library that's handling the retries or what.

Describe the solution you'd like

Document what the backoff response looks like over the JSON HTTP and the interface exposed by google-api-ruby-client.

Describe alternatives you've considered

I'd use an agent implemented by Google, but that doesn't seem to be going anywhere: https://github.com/googleapis/google-cloud-ruby/issues/2116

I'd also use the GRPC API directly if it was easy, but it seems like https://github.com/googleapis/google-cloud-ruby would be the place that would happen, and there doesn't seem to be any support even for the raw API in there.

Additional context

bitglue avatar Nov 12 '20 23:11 bitglue

I'm not sure if this helps, but here is where retry with backoff is implemented for the generated gRPC clients in google-cloud-ruby:

https://github.com/googleapis/gapic-generator-ruby/blob/master/gapic-common/lib/gapic/call_options/retry_policy.rb

quartzmo avatar Nov 12 '20 23:11 quartzmo

Greetings, we're closing this. Looks like the issue got resolved. Please let us know if the issue needs to be reopened.

fhinkel avatar Dec 08 '20 14:12 fhinkel