Skip to content

Commit

Permalink
credentials: remove the context timeout to fix token request failure …
Browse files Browse the repository at this point in the history
…with non-GCE ADC (#7845)

* Remove the context timeout to fix token request failure with non-GCE ADC

* address comment

* fix vet
  • Loading branch information
rockspore authored Nov 19, 2024
1 parent 3244606 commit db700b7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions credentials/google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package google
import (
"context"
"fmt"
"time"

"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/alts"
Expand All @@ -31,8 +30,6 @@ import (
"google.golang.org/grpc/internal"
)

const tokenRequestTimeout = 30 * time.Second

var logger = grpclog.Component("credentials")

// DefaultCredentialsOptions constructs options to build DefaultCredentials.
Expand All @@ -50,10 +47,11 @@ type DefaultCredentialsOptions struct {
// This API is experimental.
func NewDefaultCredentialsWithOptions(opts DefaultCredentialsOptions) credentials.Bundle {
if opts.PerRPCCreds == nil {
ctx, cancel := context.WithTimeout(context.Background(), tokenRequestTimeout)
defer cancel()
var err error
opts.PerRPCCreds, err = newADC(ctx)
// If the ADC ends up being Compute Engine Credentials, this context
// won't be used. Otherwise, the context dictates all the subsequent
// token requests via HTTP. So we cannot have any deadline or timeout.
opts.PerRPCCreds, err = newADC(context.TODO())
if err != nil {
logger.Warningf("NewDefaultCredentialsWithOptions: failed to create application oauth: %v", err)
}
Expand Down

0 comments on commit db700b7

Please sign in to comment.