Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

upgrade lib/pq #58

Open
wants to merge 82 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
ac48f2d
bump Pebble to 9509dcb7a53a
jbowens Sep 21, 2021
a804651
bump Pebble to 9656de4a3019
jbowens Sep 22, 2021
19a73ad
vendor: bump Pebble to 031921b4
sumeerbhola Sep 24, 2021
f5b8c01
bump modvendor to 0.5 fix its handling of version names with capitals
andreimatei Sep 25, 2021
e677f18
add OpenTelemetry tracing support and remove OpenTracing
andreimatei Sep 21, 2021
af0cc10
The opentracing dependency is now indirect.
andreimatei Sep 28, 2021
67125a3
bump Pebble to c73841491dd5
nicktrav Sep 30, 2021
3cb6936
add aws sdk v2
Oct 4, 2021
bd71529
upgrade go-deadlock
erikgrinaker Oct 8, 2021
99a4b54
bump Pebble to 59007c613a66
nicktrav Oct 11, 2021
21cb7f9
bump datadriven
RaduBerinde Oct 13, 2021
2c43cb6
make gopkg.in/yaml.v3 dependency explicit
ajwerner Oct 14, 2021
2606b49
bump panicparse to v2.2.0
nvanbenschoten Oct 19, 2021
eabe011
Update prometheus dependency
rimadeodhar Oct 19, 2021
ea98f7e
bump Pebble to 7fec828fc1af
bananabrick Oct 21, 2021
cd95d58
Bump gosigar
knz Oct 28, 2021
831e7b0
update parquet dependency
msbutler Nov 1, 2021
10d68bc
Upgrade slack-go module
rail Nov 10, 2021
363e184
add `github.com/google/skylark/syntax` package
rickystewart Nov 11, 2021
2d6f42b
use patched `stringer` tool instead of upstream
rickystewart Nov 12, 2021
0d455ff
update gopsutil to v3.21.10
stevendanna Nov 15, 2021
8156c6e
vendor: add github.com/kylelemons/godebug v1.1.0
Nov 10, 2021
526352f
upgrade to go 1.17
rickystewart Nov 16, 2021
1b9ad70
bump logtags
knz Nov 18, 2021
689ec18
update staticcheck 2021.1.1
stevendanna Nov 18, 2021
32b07eb
update errcheck to `master`
rickystewart Dec 1, 2021
d90cba2
Pubsub vendor changes
Dec 6, 2021
59bbb0e
Added dep for gcp pubsub
Dec 21, 2021
32482cd
Merging branch with master
Dec 21, 2021
a25739b
Added deps for error checking with pubsub topic
Dec 22, 2021
5aa6e67
bump gopsutil to v3
dt Jan 3, 2022
091e6c6
bump github.com/lufia/iostat
dt Jan 3, 2022
c4c9e05
bump Pebble to a71dc5a033cf
ajwerner Jan 4, 2022
633af31
Update goid to support arm64
nvanbenschoten Dec 31, 2021
9b521d0
bump xdg/scram
knz Jan 6, 2022
8366e93
Bump bufbuild/buf
knz Jan 6, 2022
0fc47b8
bump Pebble to c75a2e96a7e8
jbowens Jan 7, 2022
63f160d
bump cockroachdb/apd to pick up #104
nvanbenschoten Jan 6, 2022
d663e58
Bump pebble to 3d0ff924
itsbilal Jan 12, 2022
79fdb5d
bump apache/thrift and fraugster/parquet-go
knz Jan 15, 2022
9a365ef
replace gorhill/cronexpr with robfig/cron
dt Jan 15, 2022
4c70094
vendor: update to latest `stress`
rickystewart Jan 19, 2022
fce5a99
bump Pebble to ec6c21662e65
nicktrav Jan 21, 2022
8845178
Update to cockroach-go 2.2.6
rafiss Jan 24, 2022
a6d6f52
bump Pebble to a5c1766b568a
jbowens Jan 26, 2022
547dc6f
bump Pebble to b958d9a7760b
bananabrick Jan 28, 2022
ac23b57
revert pebble from b958d9a7760b to a5c1766b568a
ajwerner Jan 31, 2022
89cd242
added gcs kms dependencies
Jan 31, 2022
ea9f08e
bump cockroachdb/apd to v3.1.0
nvanbenschoten Jan 31, 2022
6c582ac
vendor bazel-remote library
rickystewart Feb 2, 2022
ed53f10
bump Pebble to 38b68e17aa97
nicktrav Feb 2, 2022
b983eae
bump Pebble to 19e11cfe195f
dt Feb 3, 2022
1474933
Add deps for dev tests
irfansharif Feb 8, 2022
bea3d04
Vendor google/shlex for dev
irfansharif Feb 11, 2022
9803a2b
Update vendor for 74570
rail Feb 14, 2022
9aa7fe4
Bump errors, sentry-go, datadriven
knz Feb 15, 2022
59c536a
bump Pebble to 821db50635d6
jbowens Feb 17, 2022
b19e671
vendor: upgrade to latest stress
rickystewart Feb 18, 2022
e5ebee2
bump Pebble to 40d39da505a5
jbowens Feb 28, 2022
0b1f61c
bump Pebble to 69a82fe41c31
nicktrav Mar 2, 2022
165025f
update parquet dep for EXPORT to v0.10.0
msbutler Mar 2, 2022
5d616a2
bump Pebble to e2b7bb844759
jbowens Mar 7, 2022
87c857e
bump Pebble to 93d472261892
jbowens Mar 10, 2022
2df7baf
vendor: upgrade to latest `stress`
rickystewart Mar 10, 2022
c4c02df
bump errors
knz Mar 11, 2022
a12d52b
add: github.com/google/go-github/v42
celiala Mar 11, 2022
067bd8c
bump Pebble to 6164579cf2cb
nicktrav Mar 22, 2022
b46e3ef
add google.golang.org/grpc/test/bufconn
jaylim-crl Mar 22, 2022
82c5c0a
add dummy lib pq
otan Apr 8, 2022
1bbc6bb
upgrade lib/pq
otan Apr 12, 2022
9d3123e
upgrade aws-sdk
otan Apr 19, 2022
54ccaee
bump google cloud sdk
adityamaru Apr 22, 2022
6cde0a9
Remove toxiproxy
tbg Apr 25, 2022
5169b35
bump Pebble to b33d6e173cae
nicktrav Apr 26, 2022
734427a
Update jackc/pgx for kerberos support
rafiss May 2, 2022
73c75fb
Bump panicparse to v2.2.2
tbg May 13, 2022
c404bd4
bump Pebble to e567fec84c6e
jbowens May 17, 2022
5b5c6cc
Update to pgconn v1.12.1
rafiss May 24, 2022
204a1b7
add google impersonate package
May 24, 2022
00535a0
bump Pebble to bb2c1501ac23
jbowens May 25, 2022
55a07c4
Update to gopgkrb5 v1.0.3
rafiss May 25, 2022
c11ee08
upgrades lib/pq to v1.10.6
catj-cockroach May 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
195 changes: 195 additions & 0 deletions cloud.google.com/go/CHANGES.md

Large diffs are not rendered by default.

63 changes: 4 additions & 59 deletions cloud.google.com/go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,63 +27,8 @@ make backwards-incompatible changes.

## Supported APIs

| Google API | Status | Package |
| ----------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| [Asset][cloud-asset] | stable | [`cloud.google.com/go/asset/apiv1`](https://pkg.go.dev/cloud.google.com/go/asset/v1beta) |
| [Automl][cloud-automl] | stable | [`cloud.google.com/go/automl/apiv1`](https://pkg.go.dev/cloud.google.com/go/automl/apiv1) |
| [BigQuery][cloud-bigquery] | stable | [`cloud.google.com/go/bigquery`](https://pkg.go.dev/cloud.google.com/go/bigquery) |
| [Bigtable][cloud-bigtable] | stable | [`cloud.google.com/go/bigtable`](https://pkg.go.dev/cloud.google.com/go/bigtable) |
| [Cloudbuild][cloud-build] | stable | [`cloud.google.com/go/cloudbuild/apiv1`](https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1) |
| [Cloudtasks][cloud-tasks] | stable | [`cloud.google.com/go/cloudtasks/apiv2`](https://pkg.go.dev/cloud.google.com/go/cloudtasks/apiv2) |
| [Compute Engine][cloud-compute] | alpha | [`cloud.google.com/go/compute/apiv1`](https://pkg.go.dev/cloud.google.com/go/compute/apiv1) |
| [Container][cloud-container] | stable | [`cloud.google.com/go/container/apiv1`](https://pkg.go.dev/cloud.google.com/go/container/apiv1) |
| [ContainerAnalysis][cloud-containeranalysis] | beta | [`cloud.google.com/go/containeranalysis/apiv1`](https://pkg.go.dev/cloud.google.com/go/containeranalysis/apiv1) |
| [Dataproc][cloud-dataproc] | stable | [`cloud.google.com/go/dataproc/apiv1`](https://pkg.go.dev/cloud.google.com/go/dataproc/apiv1) |
| [Datastore][cloud-datastore] | stable | [`cloud.google.com/go/datastore`](https://pkg.go.dev/cloud.google.com/go/datastore) |
| [Debugger][cloud-debugger] | stable | [`cloud.google.com/go/debugger/apiv2`](https://pkg.go.dev/cloud.google.com/go/debugger/apiv2) |
| [Dialogflow][cloud-dialogflow] | stable | [`cloud.google.com/go/dialogflow/apiv2`](https://pkg.go.dev/cloud.google.com/go/dialogflow/apiv2) |
| [Data Loss Prevention][cloud-dlp] | stable | [`cloud.google.com/go/dlp/apiv2`](https://pkg.go.dev/cloud.google.com/go/dlp/apiv2) |
| [ErrorReporting][cloud-errors] | alpha | [`cloud.google.com/go/errorreporting`](https://pkg.go.dev/cloud.google.com/go/errorreporting) |
| [Firestore][cloud-firestore] | stable | [`cloud.google.com/go/firestore`](https://pkg.go.dev/cloud.google.com/go/firestore) |
| [IAM][cloud-iam] | stable | [`cloud.google.com/go/iam`](https://pkg.go.dev/cloud.google.com/go/iam) |
| [IoT][cloud-iot] | stable | [`cloud.google.com/go/iot/apiv1`](https://pkg.go.dev/cloud.google.com/go/iot/apiv1) |
| [IRM][cloud-irm] | alpha | [`cloud.google.com/go/irm/apiv1alpha2`](https://pkg.go.dev/cloud.google.com/go/irm/apiv1alpha2) |
| [KMS][cloud-kms] | stable | [`cloud.google.com/go/kms/apiv1`](https://pkg.go.dev/cloud.google.com/go/kms/apiv1) |
| [Natural Language][cloud-natural-language] | stable | [`cloud.google.com/go/language/apiv1`](https://pkg.go.dev/cloud.google.com/go/language/apiv1) |
| [Logging][cloud-logging] | stable | [`cloud.google.com/go/logging`](https://pkg.go.dev/cloud.google.com/go/logging) |
| [Memorystore][cloud-memorystore] | alpha | [`cloud.google.com/go/redis/apiv1`](https://pkg.go.dev/cloud.google.com/go/redis/apiv1) |
| [Monitoring][cloud-monitoring] | stable | [`cloud.google.com/go/monitoring/apiv3`](https://pkg.go.dev/cloud.google.com/go/monitoring/apiv3) |
| [OS Login][cloud-oslogin] | stable | [`cloud.google.com/go/oslogin/apiv1`](https://pkg.go.dev/cloud.google.com/go/oslogin/apiv1) |
| [Pub/Sub][cloud-pubsub] | stable | [`cloud.google.com/go/pubsub`](https://pkg.go.dev/cloud.google.com/go/pubsub) |
| [Pub/Sub Lite][cloud-pubsublite] | stable | [`cloud.google.com/go/pubsublite`](https://pkg.go.dev/cloud.google.com/go/pubsublite) |
| [Phishing Protection][cloud-phishingprotection] | alpha | [`cloud.google.com/go/phishingprotection/apiv1beta1`](https://pkg.go.dev/cloud.google.com/go/phishingprotection/apiv1beta1) |
| [reCAPTCHA Enterprise][cloud-recaptcha] | alpha | [`cloud.google.com/go/recaptchaenterprise/apiv1beta1`](https://pkg.go.dev/cloud.google.com/go/recaptchaenterprise/apiv1beta1) |
| [Recommender][cloud-recommender] | beta | [`cloud.google.com/go/recommender/apiv1beta1`](https://pkg.go.dev/cloud.google.com/go/recommender/apiv1beta1) |
| [Scheduler][cloud-scheduler] | stable | [`cloud.google.com/go/scheduler/apiv1`](https://pkg.go.dev/cloud.google.com/go/scheduler/apiv1) |
| [Securitycenter][cloud-securitycenter] | stable | [`cloud.google.com/go/securitycenter/apiv1`](https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1) |
| [Spanner][cloud-spanner] | stable | [`cloud.google.com/go/spanner`](https://pkg.go.dev/cloud.google.com/go/spanner) |
| [Speech][cloud-speech] | stable | [`cloud.google.com/go/speech/apiv1`](https://pkg.go.dev/cloud.google.com/go/speech/apiv1) |
| [Storage][cloud-storage] | stable | [`cloud.google.com/go/storage`](https://pkg.go.dev/cloud.google.com/go/storage) |
| [Talent][cloud-talent] | alpha | [`cloud.google.com/go/talent/apiv4beta1`](https://pkg.go.dev/cloud.google.com/go/talent/apiv4beta1) |
| [Text To Speech][cloud-texttospeech] | stable | [`cloud.google.com/go/texttospeech/apiv1`](https://pkg.go.dev/cloud.google.com/go/texttospeech/apiv1) |
| [Trace][cloud-trace] | stable | [`cloud.google.com/go/trace/apiv2`](https://pkg.go.dev/cloud.google.com/go/trace/apiv2) |
| [Translate][cloud-translate] | stable | [`cloud.google.com/go/translate`](https://pkg.go.dev/cloud.google.com/go/translate) |
| [Video Intelligence][cloud-video] | beta | [`cloud.google.com/go/videointelligence/apiv1beta2`](https://pkg.go.dev/cloud.google.com/go/videointelligence/apiv1beta2) |
| [Vision][cloud-vision] | stable | [`cloud.google.com/go/vision/apiv1`](https://pkg.go.dev/cloud.google.com/go/vision/apiv1) |
| [Webrisk][cloud-webrisk] | alpha | [`cloud.google.com/go/webrisk/apiv1beta1`](https://pkg.go.dev/cloud.google.com/go/webrisk/apiv1beta1) |

> **Alpha status**: the API is still being actively developed. As a
> result, it might change in backward-incompatible ways and is not recommended
> for production use.
>
> **Beta status**: the API is largely complete, but still has outstanding
> features and bugs to be addressed. There may be minor backwards-incompatible
> changes where necessary.
>
> **Stable status**: the API is mature and ready for production use. We will
> continue addressing bugs and feature requests.

Documentation and examples are available at [pkg.go.dev/cloud.google.com/go](https://pkg.go.dev/cloud.google.com/go)
For an updated list of all of our released APIs please see our
[reference docs](https://cloud.google.com/go/docs/reference).

## [Go Versions Supported](#supported-versions)

Expand Down Expand Up @@ -125,12 +70,12 @@ client, err := storage.NewClient(ctx, option.WithTokenSource(tokenSource))
## Contributing

Contributions are welcome. Please, see the
[CONTRIBUTING](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CONTRIBUTING.md)
[CONTRIBUTING](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/main/CONTRIBUTING.md)
document for details.

Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.
See [Contributor Code of Conduct](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/master/CONTRIBUTING.md#contributor-code-of-conduct)
See [Contributor Code of Conduct](https://github.com/GoogleCloudPlatform/google-cloud-go/blob/main/CONTRIBUTING.md#contributor-code-of-conduct)
for more information.

[cloud-asset]: https://cloud.google.com/security-command-center/docs/how-to-asset-inventory
Expand Down
12 changes: 6 additions & 6 deletions cloud.google.com/go/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ here is how to manually cut a release of `cloud.google.com/go`.
[continuous Kokoro build](http://go/google-cloud-go-continuous). If there are
any failures in the most recent build, address them before proceeding with
the release.
1. Navigate to `google-cloud-go/` and switch to master.
1. Navigate to `google-cloud-go/` and switch to main.
1. `git pull`
1. Run `git tag -l | grep -v beta | grep -v alpha` to see all existing releases.
The current latest tag `$CV` is the largest tag. It should look something
like `vX.Y.Z` (note: ignore all `LIB/vX.Y.Z` tags - these are tags for a
specific library, not the module root). We'll call the current version `$CV`
and the new version `$NV`.
1. On master, run `git log $CV...` to list all the changes since the last
1. On main, run `git log $CV...` to list all the changes since the last
release. NOTE: You must manually visually parse out changes to submodules [1]
(the `git log` is going to show you things in submodules, which are not going
to be part of your release).
Expand All @@ -98,7 +98,7 @@ here is how to manually cut a release of `cloud.google.com/go`.
and create a PR titled `chore: release $NV`.
1. Wait for the PR to be reviewed and merged. Once it's merged, and without
merging any other PRs in the meantime:
a. Switch to master.
a. Switch to main.
b. `git pull`
c. Tag the repo with the next version: `git tag $NV`.
d. Push the tag to origin:
Expand All @@ -118,21 +118,21 @@ here is how to manually cut a release of a submodule.
any failures in the most recent build, address them before proceeding with
the release. (This applies even if the failures are in a different submodule
from the one being released.)
1. Navigate to `google-cloud-go/` and switch to master.
1. Navigate to `google-cloud-go/` and switch to main.
1. `git pull`
1. Run `git tag -l | grep datastore | grep -v beta | grep -v alpha` to see all
existing releases. The current latest tag `$CV` is the largest tag. It
should look something like `datastore/vX.Y.Z`. We'll call the current version
`$CV` and the new version `$NV`.
1. On master, run `git log $CV.. -- datastore/` to list all the changes to the
1. On main, run `git log $CV.. -- datastore/` to list all the changes to the
submodule directory since the last release.
1. Edit `datastore/CHANGES.md` to include a summary of the changes.
1. In `internal/version` run `go generate`.
1. Commit the changes, ignoring the generated `.go-r` file. Push to your fork,
and create a PR titled `chore(datastore): release $NV`.
1. Wait for the PR to be reviewed and merged. Once it's merged, and without
merging any other PRs in the meantime:
a. Switch to master.
a. Switch to main.
b. `git pull`
c. Tag the repo with the next version: `git tag $NV`.
d. Push the tag to origin:
Expand Down
48 changes: 35 additions & 13 deletions cloud.google.com/go/compute/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ var (
instID = &cachedValue{k: "instance/id", trim: true}
)

var defaultClient = &Client{hc: &http.Client{
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: 2 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
},
}}
var defaultClient = &Client{hc: newDefaultHTTPClient()}

func newDefaultHTTPClient() *http.Client {
return &http.Client{
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: 2 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
},
}
}

// NotDefinedError is returned when requested metadata is not defined.
//
Expand Down Expand Up @@ -130,7 +134,7 @@ func testOnGCE() bool {
go func() {
req, _ := http.NewRequest("GET", "http://"+metadataIP, nil)
req.Header.Set("User-Agent", userAgent)
res, err := defaultClient.hc.Do(req.WithContext(ctx))
res, err := newDefaultHTTPClient().Do(req.WithContext(ctx))
if err != nil {
resc <- false
return
Expand All @@ -140,7 +144,8 @@ func testOnGCE() bool {
}()

go func() {
addrs, err := net.DefaultResolver.LookupHost(ctx, "metadata.google.internal")
resolver := &net.Resolver{}
addrs, err := resolver.LookupHost(ctx, "metadata.google.internal")
if err != nil || len(addrs) == 0 {
resc <- false
return
Expand Down Expand Up @@ -282,6 +287,7 @@ func NewClient(c *http.Client) *Client {
// getETag returns a value from the metadata service as well as the associated ETag.
// This func is otherwise equivalent to Get.
func (c *Client) getETag(suffix string) (value, etag string, err error) {
ctx := context.TODO()
// Using a fixed IP makes it very difficult to spoof the metadata service in
// a container, which is an important use-case for local testing of cloud
// deployments. To enable spoofing of the metadata service, the environment
Expand All @@ -304,9 +310,25 @@ func (c *Client) getETag(suffix string) (value, etag string, err error) {
}
req.Header.Set("Metadata-Flavor", "Google")
req.Header.Set("User-Agent", userAgent)
res, err := c.hc.Do(req)
if err != nil {
return "", "", err
var res *http.Response
var reqErr error
retryer := newRetryer()
for {
res, reqErr = c.hc.Do(req)
var code int
if res != nil {
code = res.StatusCode
}
if delay, shouldRetry := retryer.Retry(code, reqErr); shouldRetry {
if err := sleep(ctx, delay); err != nil {
return "", "", err
}
continue
}
break
}
if reqErr != nil {
return "", "", reqErr
}
defer res.Body.Close()
if res.StatusCode == http.StatusNotFound {
Expand Down
114 changes: 114 additions & 0 deletions cloud.google.com/go/compute/metadata/retry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package metadata

import (
"context"
"io"
"math/rand"
"net/http"
"time"
)

const (
maxRetryAttempts = 5
)

var (
syscallRetryable = func(err error) bool { return false }
)

// defaultBackoff is basically equivalent to gax.Backoff without the need for
// the dependency.
type defaultBackoff struct {
max time.Duration
mul float64
cur time.Duration
}

func (b *defaultBackoff) Pause() time.Duration {
d := time.Duration(1 + rand.Int63n(int64(b.cur)))
b.cur = time.Duration(float64(b.cur) * b.mul)
if b.cur > b.max {
b.cur = b.max
}
return d
}

// sleep is the equivalent of gax.Sleep without the need for the dependency.
func sleep(ctx context.Context, d time.Duration) error {
t := time.NewTimer(d)
select {
case <-ctx.Done():
t.Stop()
return ctx.Err()
case <-t.C:
return nil
}
}

func newRetryer() *metadataRetryer {
return &metadataRetryer{bo: &defaultBackoff{
cur: 100 * time.Millisecond,
max: 30 * time.Second,
mul: 2,
}}
}

type backoff interface {
Pause() time.Duration
}

type metadataRetryer struct {
bo backoff
attempts int
}

func (r *metadataRetryer) Retry(status int, err error) (time.Duration, bool) {
if status == http.StatusOK {
return 0, false
}
retryOk := shouldRetry(status, err)
if !retryOk {
return 0, false
}
if r.attempts == maxRetryAttempts {
return 0, false
}
r.attempts++
return r.bo.Pause(), true
}

func shouldRetry(status int, err error) bool {
if 500 <= status && status <= 599 {
return true
}
if err == io.ErrUnexpectedEOF {
return true
}
// Transient network errors should be retried.
if syscallRetryable(err) {
return true
}
if err, ok := err.(interface{ Temporary() bool }); ok {
if err.Temporary() {
return true
}
}
if err, ok := err.(interface{ Unwrap() error }); ok {
return shouldRetry(status, err.Unwrap())
}
return false
}
26 changes: 26 additions & 0 deletions cloud.google.com/go/compute/metadata/retry_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build linux
// +build linux

package metadata

import "syscall"

func init() {
// Initialize syscallRetryable to return true on transient socket-level
// errors. These errors are specific to Linux.
syscallRetryable = func(err error) bool { return err == syscall.ECONNRESET || err == syscall.ECONNREFUSED }
}
Loading