Skip to content

Commit

Permalink
Add helpful error log if a service account is missing (GoogleCloudPla…
Browse files Browse the repository at this point in the history
…tform#304)

* Add friendly error log if a service account is mising

* move error message to retry util

* Fix error message lint error
  • Loading branch information
ryanwe authored Apr 2, 2021
1 parent 24bf8d9 commit cfeb07b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions retryutil/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ package retryutil

import (
"context"
"errors"
"fmt"
"math"
"math/rand"
"time"

"cloud.google.com/go/compute/metadata"
"github.com/GoogleCloudPlatform/osconfig/clog"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -83,6 +85,10 @@ func RetryAPICall(ctx context.Context, maxRetryTime time.Duration, name string,
case codes.ResourceExhausted:
extra = 10
default:
var ndr *metadata.NotDefinedError
if errors.As(err, &ndr) {
return fmt.Errorf("no service account set for instance")
}
return err
}
} else {
Expand Down

0 comments on commit cfeb07b

Please sign in to comment.