Skip to content

Commit

Permalink
Merge pull request etcd-io#15071 from wafuwafu13/refactor-gettoken
Browse files Browse the repository at this point in the history
clientv3: refactor getToken automatically
  • Loading branch information
spzala authored Jan 15, 2023
2 parents d31a0ee + 8b15146 commit 7daec29
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions client/v3/retry_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,12 @@ func (c *Client) streamClientInterceptor(optFuncs ...retryOption) grpc.StreamCli
intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs)
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
ctx = withVersion(ctx)
// getToken automatically
// TODO(cfc4n): keep this code block, remove codes about getToken in client.go after pr #12165 merged.
if c.authTokenBundle != nil {
// equal to c.Username != "" && c.Password != ""
err := c.getToken(ctx)
if err != nil && rpctypes.Error(err) != rpctypes.ErrAuthNotEnabled {
c.GetLogger().Error("clientv3/retry_interceptor: getToken failed", zap.Error(err))
return nil, err
}
// getToken automatically. Otherwise, auth token may be invalid after watch reconnection because the token has expired
// (see https://github.com/etcd-io/etcd/issues/11954 for more).
err := c.getToken(ctx)
if err != nil {
c.GetLogger().Error("clientv3/retry_interceptor: getToken failed", zap.Error(err))
return nil, err
}
grpcOpts, retryOpts := filterCallOptions(opts)
callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts)
Expand Down

0 comments on commit 7daec29

Please sign in to comment.