Skip to content

compute: Default CallOptions not used for some method calls #14221

@horgh

Description

@horgh

Client

compute

Environment

Ubuntu 24.04 on GCE
go version go1.26.1 linux/amd64

Code and Dependencies

package main

func main() {
  instanceGroupManagersClient.CallOptions.ListManagedInstances = append(
    instanceGroupManagersClient.CallOptions.ListManagedInstances,
    gax.WithRetry(mmgcloud.HTTPRetryer),
  )
}

HTTPRetryer looks like:

func HTTPRetryer() gax.Retryer {
  return gax.OnErrorFunc(
    gax.Backoff{}, // Use defaults
    func(err error) bool {
      // Check for Google API HTTP error codes
      if gerr, ok := errors.AsType[*googleapi.Error](err); ok {
        if gerr.Code == http.StatusServiceUnavailable ||
          gerr.Code == http.StatusGatewayTimeout {
          return true
        }
...
go.mod
module github.maxmind.com/maxmind/mm_website

go 1.26.0

require (
    cloud.google.com/go/compute v1.57.0
)

Expected behavior

CallOptions are respected by ListManagedInstances() when encountering 503:

listing managed instances: geo-scan-southamerica-east1: googleapi: Error 503: Authentication backend unavailable.

Actual behavior

They are not, retries do not happen despite configuring default CallOptions for the method.

Additional context

I think this is similar to #5906. The options for some methods like ListManagedInstances() only come from the parameters:

Whereas in other spots we merge the default opts:

opts = append((*c.CallOptions).Resize[0:len((*c.CallOptions).Resize):len((*c.CallOptions).Resize)], opts...)

I expected the CallOptions would be merged in all cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: computeIssues related to the Compute Engine API.triage meI really want to be triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions