Skip to content

Commit 3039c63

Browse files
authored
Merge pull request #8867 from gyuho/clientv3-backport-to-release-3.2
clientv3: backport new balancer to release-3.2, upgrade gRPC to v1.7.3
2 parents 8dc20ea + 91335d0 commit 3039c63

File tree

222 files changed

+19976
-5098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+19976
-5098
lines changed

Documentation/learning/auth_design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ For avoiding such a situation, the API layer performs *version number validation
6060

6161
After authenticating with `Authenticate()`, a client can create a gRPC connection as it would without auth. In addition to the existing initialization process, the client must associate the token with the newly created connection. `grpc.WithPerRPCCredentials()` provides the functionality for this purpose.
6262

63-
Every authenticated request from the client has a token. The token can be obtained with `grpc.metadata.FromContext()` in the server side. The server can obtain who is issuing the request and when the user was authorized. The information will be filled by the API layer in the header (`etcdserverpb.RequestHeader.Username` and `etcdserverpb.RequestHeader.AuthRevision`) of a raft log entry (`etcdserverpb.InternalRaftRequest`).
63+
Every authenticated request from the client has a token. The token can be obtained with `grpc.metadata.FromIncomingContext()` in the server side. The server can obtain who is issuing the request and when the user was authorized. The information will be filled by the API layer in the header (`etcdserverpb.RequestHeader.Username` and `etcdserverpb.RequestHeader.AuthRevision`) of a raft log entry (`etcdserverpb.InternalRaftRequest`).
6464

6565
### Checking permission in the state machine
6666

auth/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ func (as *authStore) AuthInfoFromTLS(ctx context.Context) *AuthInfo {
992992
}
993993

994994
func (as *authStore) AuthInfoFromCtx(ctx context.Context) (*AuthInfo, error) {
995-
md, ok := metadata.FromContext(ctx)
995+
md, ok := metadata.FromIncomingContext(ctx)
996996
if !ok {
997997
return nil, nil
998998
}

auth/store_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ func TestAuthInfoFromCtx(t *testing.T) {
453453
t.Errorf("expected (nil, nil), got (%v, %v)", ai, err)
454454
}
455455

456-
ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"tokens": "dummy"}))
456+
// as if it came from RPC
457+
ctx = metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{"tokens": "dummy"}))
457458
ai, err = as.AuthInfoFromCtx(ctx)
458459
if err != nil && ai != nil {
459460
t.Errorf("expected (nil, nil), got (%v, %v)", ai, err)
@@ -465,19 +466,19 @@ func TestAuthInfoFromCtx(t *testing.T) {
465466
t.Error(err)
466467
}
467468

468-
ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": "Invalid Token"}))
469+
ctx = metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{"token": "Invalid Token"}))
469470
_, err = as.AuthInfoFromCtx(ctx)
470471
if err != ErrInvalidAuthToken {
471472
t.Errorf("expected %v, got %v", ErrInvalidAuthToken, err)
472473
}
473474

474-
ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": "Invalid.Token"}))
475+
ctx = metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{"token": "Invalid.Token"}))
475476
_, err = as.AuthInfoFromCtx(ctx)
476477
if err != ErrInvalidAuthToken {
477478
t.Errorf("expected %v, got %v", ErrInvalidAuthToken, err)
478479
}
479480

480-
ctx = metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": resp.Token}))
481+
ctx = metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{"token": resp.Token}))
481482
ai, err = as.AuthInfoFromCtx(ctx)
482483
if err != nil {
483484
t.Error(err)
@@ -521,7 +522,7 @@ func TestAuthInfoFromCtxRace(t *testing.T) {
521522
donec := make(chan struct{})
522523
go func() {
523524
defer close(donec)
524-
ctx := metadata.NewContext(context.Background(), metadata.New(map[string]string{"token": "test"}))
525+
ctx := metadata.NewIncomingContext(context.Background(), metadata.New(map[string]string{"token": "test"}))
525526
as.AuthInfoFromCtx(ctx)
526527
}()
527528
as.UserAdd(&pb.AuthUserAddRequest{Name: "test"})

bill-of-materials.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,21 @@
345345
}
346346
]
347347
},
348+
{
349+
"project": "google.golang.org/genproto/googleapis",
350+
"licenses": [
351+
{
352+
"type": "Apache License 2.0",
353+
"confidence": 1
354+
}
355+
]
356+
},
348357
{
349358
"project": "google.golang.org/grpc",
350359
"licenses": [
351360
{
352-
"type": "BSD 3-clause \"New\" or \"Revised\" License",
353-
"confidence": 0.979253112033195
361+
"type": "Apache License 2.0",
362+
"confidence": 1
354363
}
355364
]
356365
},

clientv3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# etcd/clientv3
22

3-
[![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/coreos/etcd/clientv3)
3+
[![Godoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/coreos/etcd/clientv3)
44

55
`etcd/clientv3` is the official Go etcd client for v3.
66

clientv3/auth.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/coreos/etcd/auth/authpb"
2222
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
23+
2324
"golang.org/x/net/context"
2425
"google.golang.org/grpc"
2526
)
@@ -104,16 +105,16 @@ type auth struct {
104105
}
105106

106107
func NewAuth(c *Client) Auth {
107-
return &auth{remote: pb.NewAuthClient(c.ActiveConnection())}
108+
return &auth{remote: RetryAuthClient(c)}
108109
}
109110

110111
func (auth *auth) AuthEnable(ctx context.Context) (*AuthEnableResponse, error) {
111-
resp, err := auth.remote.AuthEnable(ctx, &pb.AuthEnableRequest{}, grpc.FailFast(false))
112+
resp, err := auth.remote.AuthEnable(ctx, &pb.AuthEnableRequest{})
112113
return (*AuthEnableResponse)(resp), toErr(ctx, err)
113114
}
114115

115116
func (auth *auth) AuthDisable(ctx context.Context) (*AuthDisableResponse, error) {
116-
resp, err := auth.remote.AuthDisable(ctx, &pb.AuthDisableRequest{}, grpc.FailFast(false))
117+
resp, err := auth.remote.AuthDisable(ctx, &pb.AuthDisableRequest{})
117118
return (*AuthDisableResponse)(resp), toErr(ctx, err)
118119
}
119120

@@ -138,12 +139,12 @@ func (auth *auth) UserGrantRole(ctx context.Context, user string, role string) (
138139
}
139140

140141
func (auth *auth) UserGet(ctx context.Context, name string) (*AuthUserGetResponse, error) {
141-
resp, err := auth.remote.UserGet(ctx, &pb.AuthUserGetRequest{Name: name}, grpc.FailFast(false))
142+
resp, err := auth.remote.UserGet(ctx, &pb.AuthUserGetRequest{Name: name})
142143
return (*AuthUserGetResponse)(resp), toErr(ctx, err)
143144
}
144145

145146
func (auth *auth) UserList(ctx context.Context) (*AuthUserListResponse, error) {
146-
resp, err := auth.remote.UserList(ctx, &pb.AuthUserListRequest{}, grpc.FailFast(false))
147+
resp, err := auth.remote.UserList(ctx, &pb.AuthUserListRequest{})
147148
return (*AuthUserListResponse)(resp), toErr(ctx, err)
148149
}
149150

@@ -168,12 +169,12 @@ func (auth *auth) RoleGrantPermission(ctx context.Context, name string, key, ran
168169
}
169170

170171
func (auth *auth) RoleGet(ctx context.Context, role string) (*AuthRoleGetResponse, error) {
171-
resp, err := auth.remote.RoleGet(ctx, &pb.AuthRoleGetRequest{Role: role}, grpc.FailFast(false))
172+
resp, err := auth.remote.RoleGet(ctx, &pb.AuthRoleGetRequest{Role: role})
172173
return (*AuthRoleGetResponse)(resp), toErr(ctx, err)
173174
}
174175

175176
func (auth *auth) RoleList(ctx context.Context) (*AuthRoleListResponse, error) {
176-
resp, err := auth.remote.RoleList(ctx, &pb.AuthRoleListRequest{}, grpc.FailFast(false))
177+
resp, err := auth.remote.RoleList(ctx, &pb.AuthRoleListRequest{})
177178
return (*AuthRoleListResponse)(resp), toErr(ctx, err)
178179
}
179180

@@ -201,7 +202,7 @@ type authenticator struct {
201202
}
202203

203204
func (auth *authenticator) authenticate(ctx context.Context, name string, password string) (*AuthenticateResponse, error) {
204-
resp, err := auth.remote.Authenticate(ctx, &pb.AuthenticateRequest{Name: name, Password: password}, grpc.FailFast(false))
205+
resp, err := auth.remote.Authenticate(ctx, &pb.AuthenticateRequest{Name: name, Password: password})
205206
return (*AuthenticateResponse)(resp), toErr(ctx, err)
206207
}
207208

0 commit comments

Comments
 (0)