From fb81fb44fa86af51e0d65f30bd9be9f51d4b6d64 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Fri, 3 Mar 2017 10:44:48 -0800 Subject: [PATCH] etcd-tester: check expired lease with -1 TTL Following the change at https://github.com/coreos/etcd/commit/2ca1823a96105409febb89479d53c6c5e0f83dc2 Signed-off-by: Gyu-Ho Lee --- tools/functional-tester/etcd-tester/checks.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/functional-tester/etcd-tester/checks.go b/tools/functional-tester/etcd-tester/checks.go index ac82aca235a..7cff67c57cc 100644 --- a/tools/functional-tester/etcd-tester/checks.go +++ b/tools/functional-tester/etcd-tester/checks.go @@ -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) }