Skip to content

Commit

Permalink
Merge pull request #6788 from fanminshi/lease_http_eof_fix
Browse files Browse the repository at this point in the history
etcd-tester: add retry logic on retriving lease info
  • Loading branch information
fanminshi authored Nov 3, 2016
2 parents b28b38f + 649fe7f commit b7ab5c6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tools/functional-tester/etcd-tester/lease_stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,18 @@ func (ls *leaseStresser) getLeaseByID(ctx context.Context, leaseID int64) (*pb.L
}

func (ls *leaseStresser) hasLeaseExpired(ctx context.Context, leaseID int64) (bool, error) {
resp, err := ls.getLeaseByID(ctx, leaseID)
plog.Debugf("hasLeaseExpired %v resp %v error (%v)", leaseID, resp, err)
if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
return true, nil
// keep retrying until lease's state is known or ctx is being canceled
for ctx.Err() == nil {
resp, err := ls.getLeaseByID(ctx, leaseID)
if err == nil {
return false, nil
}
if rpctypes.Error(err) == rpctypes.ErrLeaseNotFound {
return true, nil
}
plog.Warningf("hasLeaseExpired %v resp %v error (%v)", leaseID, resp, err)
}
return false, err
return false, ctx.Err()
}

// The keys attached to the lease has the format of "<leaseID>_<idx>" where idx is the ordering key creation
Expand Down

0 comments on commit b7ab5c6

Please sign in to comment.