mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
client: no need to getToken when dial specific endpoint for maintenance
The existing client may connect to different endpoint from the specific endpoint to be maintained. Maintenance operations do not go through raft at all, so it might run into issue if the server hasn't finished applying the authentication request. Let's work with an example. Assuming the existing client connects to ep1, while the user wants to maintain ep2. If we getToken again, it sends an authentication request, which goes through raft. When the specific endpoint receives the maintenance request, it might haven't finished previous authentication request, but the new token is already carried in the context, so it will reject the maintenance request due to invalid token. We already have retry logic in `unaryClientInterceptor` and `streamClientInterceptor`. When the token expires, it can automatically refresh the token, so it should be safe to remove the `getToken` logic in `maintenance.dial` Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
parent
f782891246
commit
7f46da223d
@ -119,19 +119,7 @@ func NewMaintenance(c *Client) Maintenance {
|
||||
return nil, nil, fmt.Errorf("failed to dial endpoint %s with maintenance client: %v", endpoint, err)
|
||||
}
|
||||
|
||||
//get token with established connection
|
||||
dctx := c.ctx
|
||||
cancel := func() {}
|
||||
if c.cfg.DialTimeout > 0 {
|
||||
dctx, cancel = context.WithTimeout(c.ctx, c.cfg.DialTimeout)
|
||||
}
|
||||
err = c.getToken(dctx)
|
||||
cancel()
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return nil, nil, fmt.Errorf("failed to getToken from endpoint %s with maintenance client: %v", endpoint, err)
|
||||
}
|
||||
cancel = func() { conn.Close() }
|
||||
cancel := func() { conn.Close() }
|
||||
return RetryMaintenanceClient(c, conn), cancel, nil
|
||||
},
|
||||
remote: RetryMaintenanceClient(c, c.conn),
|
||||
|
Loading…
x
Reference in New Issue
Block a user