Skip to content

Commit df6b6f9

Browse files
authored
fix: increase rateLimit burst size to 2 (GoogleCloudPlatform#1048)
1 parent 730c082 commit df6b6f9

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/hanwen/go-fuse/v2 v2.1.0
1111
github.com/lib/pq v1.10.4
1212
go.uber.org/zap v1.19.1
13+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
1314
golang.org/x/net v0.0.0-20211020060615-d418f374d309
1415
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
1516
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

go.sum

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,9 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk
221221
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
222222
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
223223
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
224-
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
225224
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
225+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
226+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
226227
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
227228
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
228229
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -365,6 +366,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
365366
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
366367
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
367368
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
369+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
368370
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
369371
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
370372
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

proxy/proxy/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (c *Client) cachedCfg(ctx context.Context, instance string) (string, *tls.C
417417
e = c.cfgCache[instance]
418418
limiter := c.limiters[instance]
419419
if limiter == nil {
420-
limiter = rate.NewLimiter(rate.Every(throttle), 1)
420+
limiter = rate.NewLimiter(rate.Every(throttle), 2)
421421
c.limiters[instance] = limiter
422422
}
423423
if needsRefresh(e, refreshCfgBuffer) {

proxy/proxy/client_test.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -559,25 +559,13 @@ func TestClientHandshakeCanceled(t *testing.T) {
559559
validateError(t, err)
560560
})
561561
})
562+
}
562563

563-
// Fail fast when dial attempts trigger a race condition
564-
t.Run("dialing in quick succession", func(t *testing.T) {
565-
withTestHarness(t, func(port int) {
566-
c := newClient(port)
567-
568-
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
569-
defer cancel()
564+
func TestConnectingWithInvalidConfig(t *testing.T) {
565+
c := &Client{}
570566

571-
var ok bool
572-
for i := 0; i < 100; i++ {
573-
_, err := c.DialContext(ctx, instance)
574-
if err == ErrUnexpectedFailure {
575-
ok = true
576-
}
577-
}
578-
if !ok {
579-
t.Fatal("wanted ErrUnexpectedFailure, got none")
580-
}
581-
})
582-
})
567+
_, err := c.tryConnect(context.Background(), "", "myinstance", &tls.Config{})
568+
if err != ErrUnexpectedFailure {
569+
t.Fatalf("wanted ErrUnexpectedFailure, got = %v", err)
570+
}
583571
}

0 commit comments

Comments
 (0)