mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #7415 from gyuho/etcd-tester-lease-check-with-ttl
etcd-tester: check expired lease with -1 TTL
This commit is contained in:
commit
2831b9dcfd
@ -133,7 +133,8 @@ func (lc *leaseChecker) checkShortLivedLease(ctx context.Context, leaseID int64)
|
||||
var resp *pb.LeaseTimeToLiveResponse
|
||||
for i := 0; i < retries; i++ {
|
||||
resp, err = lc.getLeaseByID(ctx, leaseID)
|
||||
if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
|
||||
// lease not found, for ~v3.1 compatibilities, check ErrLeaseNotFound
|
||||
if (err == nil && resp.TTL == -1) || (err != nil && rpctypes.Error(err) == rpctypes.ErrLeaseNotFound) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
@ -195,11 +196,13 @@ func (lc *leaseChecker) hasLeaseExpired(ctx context.Context, leaseID int64) (boo
|
||||
// keep retrying until lease's state is known or ctx is being canceled
|
||||
for ctx.Err() == nil {
|
||||
resp, err := lc.getLeaseByID(ctx, leaseID)
|
||||
if err == nil {
|
||||
return false, nil
|
||||
}
|
||||
if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
|
||||
return true, nil
|
||||
if err != nil {
|
||||
// for ~v3.1 compatibilities
|
||||
if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
|
||||
return true, nil
|
||||
}
|
||||
} else {
|
||||
return resp.TTL == -1, nil
|
||||
}
|
||||
plog.Warningf("hasLeaseExpired %v resp %v error %v (endpoint %q)", leaseID, resp, err, lc.endpoint)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user