diff --git a/pkg/etcd/client.go b/pkg/etcd/client.go index 45d0361acb8..bfbd5bdc893 100644 --- a/pkg/etcd/client.go +++ b/pkg/etcd/client.go @@ -158,8 +158,10 @@ func (c *Client) Txn(ctx context.Context, cmps []clientv3.Cmp, opsThen, opsElse // Grant delegates request to clientv3.Lease.Grant func (c *Client) Grant(ctx context.Context, ttl int64) (resp *clientv3.LeaseGrantResponse, err error) { err = retryRPC(EtcdGrant, c.metrics[EtcdGrant], func() error { + grantCtx, cancel := context.WithTimeout(ctx, etcdClientTimeoutWithoutRetry) + defer cancel() var inErr error - resp, inErr = c.cli.Grant(ctx, ttl) + resp, inErr = c.cli.Grant(grantCtx, ttl) return inErr }) return @@ -190,8 +192,10 @@ func isRetryableError(rpcName string) retry.IsRetryable { // Revoke delegates request to clientv3.Lease.Revoke func (c *Client) Revoke(ctx context.Context, id clientv3.LeaseID) (resp *clientv3.LeaseRevokeResponse, err error) { err = retryRPC(EtcdRevoke, c.metrics[EtcdRevoke], func() error { + revokeCtx, cancel := context.WithTimeout(ctx, etcdClientTimeoutWithoutRetry) + defer cancel() var inErr error - resp, inErr = c.cli.Revoke(ctx, id) + resp, inErr = c.cli.Revoke(revokeCtx, id) return inErr }) return @@ -200,8 +204,10 @@ func (c *Client) Revoke(ctx context.Context, id clientv3.LeaseID) (resp *clientv // TimeToLive delegates request to clientv3.Lease.TimeToLive func (c *Client) TimeToLive(ctx context.Context, lease clientv3.LeaseID, opts ...clientv3.LeaseOption) (resp *clientv3.LeaseTimeToLiveResponse, err error) { err = retryRPC(EtcdRevoke, c.metrics[EtcdRevoke], func() error { + timeToLiveCtx, cancel := context.WithTimeout(ctx, etcdClientTimeoutWithoutRetry) + defer cancel() var inErr error - resp, inErr = c.cli.TimeToLive(ctx, lease, opts...) + resp, inErr = c.cli.TimeToLive(timeToLiveCtx, lease, opts...) return inErr }) return