diff --git a/api/etcdserverpb/raft_internal.pb.go b/api/etcdserverpb/raft_internal.pb.go index d59e65813f4..c7ef10644ee 100644 --- a/api/etcdserverpb/raft_internal.pb.go +++ b/api/etcdserverpb/raft_internal.pb.go @@ -85,6 +85,7 @@ type InternalRaftRequest struct { LeaseRevoke *LeaseRevokeRequest `protobuf:"bytes,9,opt,name=lease_revoke,json=leaseRevoke,proto3" json:"lease_revoke,omitempty"` Alarm *AlarmRequest `protobuf:"bytes,10,opt,name=alarm,proto3" json:"alarm,omitempty"` LeaseCheckpoint *LeaseCheckpointRequest `protobuf:"bytes,11,opt,name=lease_checkpoint,json=leaseCheckpoint,proto3" json:"lease_checkpoint,omitempty"` + LeaseRenew *LeaseKeepAliveRequest `protobuf:"bytes,12,opt,name=lease_renew,json=leaseRenew,proto3" json:"lease_renew,omitempty"` AuthEnable *AuthEnableRequest `protobuf:"bytes,1000,opt,name=auth_enable,json=authEnable,proto3" json:"auth_enable,omitempty"` AuthDisable *AuthDisableRequest `protobuf:"bytes,1011,opt,name=auth_disable,json=authDisable,proto3" json:"auth_disable,omitempty"` AuthStatus *AuthStatusRequest `protobuf:"bytes,1013,opt,name=auth_status,json=authStatus,proto3" json:"auth_status,omitempty"` @@ -238,73 +239,75 @@ func init() { func init() { proto.RegisterFile("raft_internal.proto", fileDescriptor_b4c9a9be0cfca103) } var fileDescriptor_b4c9a9be0cfca103 = []byte{ - // 1054 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x56, 0x5d, 0x6f, 0x1b, 0x45, - 0x14, 0xad, 0xd3, 0x34, 0x89, 0xc7, 0x49, 0x9a, 0x4e, 0x52, 0x3a, 0x38, 0x92, 0x71, 0x03, 0x2d, - 0x01, 0x8a, 0x53, 0x1c, 0x78, 0xe1, 0x05, 0x5c, 0x3b, 0x4a, 0x83, 0x4a, 0x15, 0x6d, 0x0b, 0xaa, - 0x84, 0xd0, 0x32, 0xde, 0xbd, 0xb1, 0xb7, 0x59, 0xef, 0x2e, 0x33, 0x63, 0x37, 0x7d, 0xe5, 0x91, - 0x67, 0x40, 0xfc, 0x0c, 0x3e, 0xff, 0x43, 0x85, 0xf8, 0x28, 0xf0, 0x07, 0x20, 0xbc, 0xf0, 0x0e, - 0xbc, 0xa3, 0xf9, 0xd8, 0x5d, 0xaf, 0x3d, 0xce, 0xdb, 0xfa, 0xde, 0x73, 0xcf, 0x39, 0x33, 0x73, - 0xef, 0x78, 0xd0, 0x3a, 0xa3, 0x47, 0xc2, 0x0d, 0x22, 0x01, 0x2c, 0xa2, 0x61, 0x23, 0x61, 0xb1, - 0x88, 0xf1, 0x32, 0x08, 0xcf, 0xe7, 0xc0, 0x46, 0xc0, 0x92, 0x6e, 0x75, 0xa3, 0x17, 0xf7, 0x62, - 0x95, 0xd8, 0x91, 0x5f, 0x1a, 0x53, 0x5d, 0xcb, 0x31, 0x26, 0x52, 0x66, 0x89, 0x67, 0x3e, 0xeb, - 0x32, 0xb9, 0x43, 0x93, 0x60, 0x67, 0x04, 0x8c, 0x07, 0x71, 0x94, 0x74, 0xd3, 0x2f, 0x83, 0xb8, - 0x9e, 0x21, 0x06, 0x30, 0xe8, 0x02, 0xe3, 0xfd, 0x20, 0x49, 0xba, 0x63, 0x3f, 0x34, 0x6e, 0x8b, - 0xa1, 0x15, 0x07, 0x3e, 0x1e, 0x02, 0x17, 0xb7, 0x81, 0xfa, 0xc0, 0xf0, 0x2a, 0x9a, 0x3b, 0xe8, - 0x90, 0x52, 0xbd, 0xb4, 0x3d, 0xef, 0xcc, 0x1d, 0x74, 0x70, 0x15, 0x2d, 0x0d, 0xb9, 0x34, 0x3f, - 0x00, 0x32, 0x57, 0x2f, 0x6d, 0x97, 0x9d, 0xec, 0x37, 0xbe, 0x81, 0x56, 0xe8, 0x50, 0xf4, 0x5d, - 0x06, 0xa3, 0x40, 0x6a, 0x93, 0xf3, 0xb2, 0xec, 0xd6, 0xe2, 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x87, 0xad, 0xc7, 0x68, 0xf3, 0x8c, 0xeb, 0x1b, 0x63, 0x34, 0xaf, 0xde, 0x72, 0x25, - 0xf5, 0x96, 0x53, 0xdf, 0xf2, 0x8d, 0x97, 0xdd, 0x6a, 0xe6, 0x8d, 0x97, 0xfe, 0xc6, 0x57, 0xd1, - 0x32, 0x0f, 0x06, 0x49, 0x08, 0xae, 0x88, 0x8f, 0x41, 0x3f, 0xf1, 0xca, 0x4e, 0x45, 0xc7, 0xee, - 0xcb, 0x50, 0xe6, 0xe5, 0xd6, 0xc6, 0x93, 0x3f, 0x6b, 0xe7, 0x9e, 0x9c, 0xd6, 0x4a, 0x4f, 0x4f, - 0x6b, 0xa5, 0x3f, 0x4e, 0x6b, 0xa5, 0x2f, 0xff, 0xaa, 0x9d, 0xeb, 0x2e, 0xa8, 0x97, 0xe6, 0xee, - 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x30, 0x36, 0x53, 0xc6, 0x0b, 0x0b, 0x00, 0x00, + // 1083 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x56, 0x4d, 0x73, 0x1b, 0x45, + 0x10, 0x8d, 0x6c, 0xc7, 0xb6, 0x46, 0xb6, 0xe3, 0x8c, 0x1d, 0x32, 0xd8, 0x55, 0x46, 0x31, 0x24, + 0x18, 0x08, 0x72, 0x90, 0x81, 0x03, 0x17, 0x50, 0x24, 0x97, 0x63, 0x48, 0x52, 0xae, 0x4d, 0xa0, + 0x52, 0x45, 0x51, 0xcb, 0x68, 0xb7, 0x2d, 0x6d, 0xbc, 0xda, 0x5d, 0x66, 0x46, 0xb2, 0x73, 0xe5, + 0xc8, 0x19, 0x28, 0xf8, 0x17, 0x7c, 0xfe, 0x87, 0x1c, 0xf8, 0x08, 0xf0, 0x07, 0xc0, 0x5c, 0xb8, + 0x03, 0xf7, 0xd4, 0x7c, 0xec, 0xae, 0x56, 0x1a,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a3, 0x9e, 0x86, 0x25, 0xf5, 0x34, 0x54, + 0xdf, 0xf2, 0xc9, 0x98, 0xdd, 0x6a, 0xe6, 0xc9, 0x98, 0xfe, 0xc6, 0x57, 0xd0, 0x02, 0x0f, 0x7a, + 0x49, 0x08, 0xae, 0x88, 0x8f, 0x40, 0xbf, 0x18, 0xcb, 0x4e, 0x45, 0xc7, 0xee, 0xcb, 0x50, 0xe6, + 0xe5, 0xe6, 0xea, 0xe3, 0xbf, 0x36, 0xce, 0x3d, 0x3e, 0xdd, 0x28, 0x3d, 0x39, 0xdd, 0x28, 0xfd, + 0x79, 0xba, 0x51, 0xfa, 0xea, 0xef, 0x8d, 0x73, 0xed, 0x59, 0xf5, 0x70, 0xdd, 0x79, 0x1a, 0x00, + 0x00, 0xff, 0xff, 0x51, 0x34, 0x24, 0xd0, 0x5a, 0x0b, 0x00, 0x00, } func (m *RequestHeader) Marshal() (dAtA []byte, err error) { @@ -669,6 +672,18 @@ func (m *InternalRaftRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0xa2 } + if m.LeaseRenew != nil { + { + size, err := m.LeaseRenew.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRaftInternal(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } if m.LeaseCheckpoint != nil { { size, err := m.LeaseCheckpoint.MarshalToSizedBuffer(dAtA[:i]) @@ -954,6 +969,10 @@ func (m *InternalRaftRequest) Size() (n int) { l = m.LeaseCheckpoint.Size() n += 1 + l + sovRaftInternal(uint64(l)) } + if m.LeaseRenew != nil { + l = m.LeaseRenew.Size() + n += 1 + l + sovRaftInternal(uint64(l)) + } if m.Header != nil { l = m.Header.Size() n += 2 + l + sovRaftInternal(uint64(l)) @@ -1615,6 +1634,42 @@ func (m *InternalRaftRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LeaseRenew", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRaftInternal + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRaftInternal + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRaftInternal + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.LeaseRenew == nil { + m.LeaseRenew = &LeaseKeepAliveRequest{} + } + if err := m.LeaseRenew.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 100: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) diff --git a/api/etcdserverpb/raft_internal.proto b/api/etcdserverpb/raft_internal.proto index f1036b9f619..f457c90ab2a 100644 --- a/api/etcdserverpb/raft_internal.proto +++ b/api/etcdserverpb/raft_internal.proto @@ -44,6 +44,7 @@ message InternalRaftRequest { AlarmRequest alarm = 10; LeaseCheckpointRequest lease_checkpoint = 11 [(versionpb.etcd_version_field) = "3.4"]; + LeaseKeepAliveRequest lease_renew = 12 [(versionpb.etcd_version_field) = "3.6"]; AuthEnableRequest auth_enable = 1000; AuthDisableRequest auth_disable = 1011; diff --git a/scripts/etcd_version_annotations.txt b/scripts/etcd_version_annotations.txt index 3e5d23f94d8..4da014f8c0d 100644 --- a/scripts/etcd_version_annotations.txt +++ b/scripts/etcd_version_annotations.txt @@ -204,6 +204,7 @@ etcdserverpb.InternalRaftRequest.downgrade_info_set: "3.5" etcdserverpb.InternalRaftRequest.header: "" etcdserverpb.InternalRaftRequest.lease_checkpoint: "3.4" etcdserverpb.InternalRaftRequest.lease_grant: "" +etcdserverpb.InternalRaftRequest.lease_renew: "3.6" etcdserverpb.InternalRaftRequest.lease_revoke: "" etcdserverpb.InternalRaftRequest.put: "" etcdserverpb.InternalRaftRequest.range: "" diff --git a/server/etcdserver/api/v3rpc/lease.go b/server/etcdserver/api/v3rpc/lease.go index e123dd2a37c..8b8bccd88f5 100644 --- a/server/etcdserver/api/v3rpc/lease.go +++ b/server/etcdserver/api/v3rpc/lease.go @@ -123,26 +123,18 @@ func (ls *LeaseServer) leaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) erro return err } - // Create header before we sent out the renew request. - // This can make sure that the revision is strictly smaller or equal to - // when the keepalive happened at the local server (when the local server is the leader) - // or remote leader. - // Without this, a lease might be revoked at rev 3 but client can see the keepalive succeeded - // at rev 4. - resp := &pb.LeaseKeepAliveResponse{ID: req.ID, Header: &pb.ResponseHeader{}} - ls.hdr.fill(resp.Header) - - ttl, err := ls.le.LeaseRenew(stream.Context(), lease.LeaseID(req.ID)) + resp, err := ls.le.LeaseRenew(stream.Context(), req) if err == lease.ErrLeaseNotFound { err = nil - ttl = 0 + resp = &pb.LeaseKeepAliveResponse{ID: req.ID, Header: &pb.ResponseHeader{}} + ls.hdr.fill(resp.Header) + resp.TTL = 0 } if err != nil { return togRPCError(err) } - resp.TTL = ttl err = stream.Send(resp) if err != nil { if isClientCtxErr(stream.Context().Err(), err) { diff --git a/server/etcdserver/apply/apply.go b/server/etcdserver/apply/apply.go index 058870b1dc2..242d9d3334a 100644 --- a/server/etcdserver/apply/apply.go +++ b/server/etcdserver/apply/apply.go @@ -79,6 +79,7 @@ type applierV3 interface { LeaseGrant(lc *pb.LeaseGrantRequest) (*pb.LeaseGrantResponse, error) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) + LeaseRenew(lc *pb.LeaseKeepAliveRequest) (*pb.LeaseKeepAliveResponse, error) LeaseCheckpoint(lc *pb.LeaseCheckpointRequest) (*pb.LeaseCheckpointResponse, error) @@ -207,6 +208,11 @@ func (a *applierV3backend) LeaseRevoke(lc *pb.LeaseRevokeRequest) (*pb.LeaseRevo return &pb.LeaseRevokeResponse{Header: a.newHeader()}, err } +func (a *applierV3backend) LeaseRenew(lc *pb.LeaseKeepAliveRequest) (*pb.LeaseKeepAliveResponse, error) { + ttl, err := a.lessor.Renew(lease.LeaseID(lc.ID)) + return &pb.LeaseKeepAliveResponse{Header: a.newHeader(), ID: lc.ID, TTL: ttl}, err +} + func (a *applierV3backend) LeaseCheckpoint(lc *pb.LeaseCheckpointRequest) (*pb.LeaseCheckpointResponse, error) { for _, c := range lc.Checkpoints { err := a.lessor.Checkpoint(lease.LeaseID(c.ID), c.Remaining_TTL) diff --git a/server/etcdserver/apply/corrupt.go b/server/etcdserver/apply/corrupt.go index 040f294aeba..f81836701ea 100644 --- a/server/etcdserver/apply/corrupt.go +++ b/server/etcdserver/apply/corrupt.go @@ -56,3 +56,7 @@ func (a *applierV3Corrupt) LeaseGrant(_ *pb.LeaseGrantRequest) (*pb.LeaseGrantRe func (a *applierV3Corrupt) LeaseRevoke(_ *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) { return nil, errors.ErrCorrupt } + +func (a *applierV3Corrupt) LeaseRenew(lc *pb.LeaseKeepAliveRequest) (*pb.LeaseKeepAliveResponse, error) { + return nil, errors.ErrCorrupt +} diff --git a/server/etcdserver/apply/uber_applier.go b/server/etcdserver/apply/uber_applier.go index 201defa385b..7074fd67e60 100644 --- a/server/etcdserver/apply/uber_applier.go +++ b/server/etcdserver/apply/uber_applier.go @@ -172,6 +172,9 @@ func (a *uberApplier) dispatch(ctx context.Context, r *pb.InternalRaftRequest, s case r.LeaseRevoke != nil: op = "LeaseRevoke" ar.Resp, ar.Err = a.applyV3.LeaseRevoke(r.LeaseRevoke) + case r.LeaseRenew != nil: + op = "LeaseRenew" + ar.Resp, ar.Err = a.applyV3.LeaseRenew(r.LeaseRenew) case r.LeaseCheckpoint != nil: op = "LeaseCheckpoint" ar.Resp, ar.Err = a.applyV3.LeaseCheckpoint(r.LeaseCheckpoint) diff --git a/server/etcdserver/v3_server.go b/server/etcdserver/v3_server.go index 4f1cd6b13ee..d4be7db0c54 100644 --- a/server/etcdserver/v3_server.go +++ b/server/etcdserver/v3_server.go @@ -68,9 +68,8 @@ type Lessor interface { // LeaseRevoke sends LeaseRevoke request to raft and toApply it after committed. LeaseRevoke(ctx context.Context, r *pb.LeaseRevokeRequest) (*pb.LeaseRevokeResponse, error) - // LeaseRenew renews the lease with given ID. The renewed TTL is returned. Or an error - // is returned. - LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, error) + // LeaseRenew renews the lease. + LeaseRenew(ctx context.Context, r *pb.LeaseKeepAliveRequest) (*pb.LeaseKeepAliveResponse, error) // LeaseTimeToLive retrieves lease information. LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) @@ -276,13 +275,73 @@ func (s *EtcdServer) LeaseRevoke(ctx context.Context, r *pb.LeaseRevokeRequest) return resp.(*pb.LeaseRevokeResponse), nil } -func (s *EtcdServer) LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, error) { +func (s *EtcdServer) LeaseRenewV2(ctx context.Context, id lease.LeaseID) (int64, error) { if s.isLeader() { if err := s.waitAppliedIndex(); err != nil { return 0, err } - ttl, err := s.lessor.Renew(id) + ttl, err := s.lessor.RenewV2(id) + if err == nil { // already requested to primary lessor(leader) + return ttl, nil + } + if err != lease.ErrNotPrimary { + return -1, err + } + } + + cctx, cancel := context.WithTimeout(ctx, s.Cfg.ReqTimeout()) + defer cancel() + + // renewals don't go through raft; forward to leader manually + for cctx.Err() == nil { + leader, lerr := s.waitLeader(cctx) + if lerr != nil { + return -1, lerr + } + for _, url := range leader.PeerURLs { + lurl := url + leasehttp.LeasePrefix + ttl, err := leasehttp.RenewHTTP(cctx, id, lurl, s.peerRt) + if err == nil || err == lease.ErrLeaseNotFound { + return ttl, err + } + } + // Throttle in case of e.g. connection problems. + time.Sleep(50 * time.Millisecond) + } + + if cctx.Err() == context.DeadlineExceeded { + return -1, errors.ErrTimeout + } + return -1, errors.ErrCanceled +} + +func (s *EtcdServer) LeaseRenew(ctx context.Context, r *pb.LeaseKeepAliveRequest) (*pb.LeaseKeepAliveResponse, error) { + // TODO(ahrtr): remove the legacy `leaseRenewV2` in 3.7. + cv := s.cluster.Version() + if version.LessThan(*cv, version.V3_6) { + resp := &pb.LeaseKeepAliveResponse{ID: r.ID, Header: s.newHeader()} + + var err error + resp.TTL, err = s.leaseRenewV2(ctx, lease.LeaseID(r.ID)) + + return resp, err + } + + resp, err := s.raftRequestOnce(ctx, pb.InternalRaftRequest{LeaseRenew: r}) + if err != nil { + return nil, err + } + return resp.(*pb.LeaseKeepAliveResponse), err +} + +func (s *EtcdServer) leaseRenewV2(ctx context.Context, id lease.LeaseID) (int64, error) { + if s.isLeader() { + if err := s.waitAppliedIndex(); err != nil { + return 0, err + } + + ttl, err := s.lessor.RenewV2(id) if err == nil { // already requested to primary lessor(leader) return ttl, nil } diff --git a/server/lease/leasehttp/http.go b/server/lease/leasehttp/http.go index 30caf22e783..6b4488c8485 100644 --- a/server/lease/leasehttp/http.go +++ b/server/lease/leasehttp/http.go @@ -73,7 +73,7 @@ func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { http.Error(w, ErrLeaseHTTPTimeout.Error(), http.StatusRequestTimeout) return } - ttl, rerr := h.l.Renew(lease.LeaseID(lreq.ID)) + ttl, rerr := h.l.RenewV2(lease.LeaseID(lreq.ID)) if rerr != nil { if rerr == lease.ErrLeaseNotFound { http.Error(w, rerr.Error(), http.StatusNotFound) diff --git a/server/lease/lessor.go b/server/lease/lessor.go index 860de54f45f..85e69eb7940 100644 --- a/server/lease/lessor.go +++ b/server/lease/lessor.go @@ -119,8 +119,13 @@ type Lessor interface { // Demote demotes the lessor from being the primary lessor. Demote() - // Renew renews a lease with given ID. It returns the renewed TTL. If the ID does not exist, - // an error will be returned. + // RenewV2 renews a lease with given ID. It returns the renewed TTL. + // If the ID does not exist, an error will be returned. + // TODO(ahrtr): remove this legacy method in 3.7. + RenewV2(id LeaseID) (int64, error) + + // Renew renews a lease with given ID. It returns the renewed TTL. + // If the given lease does not exist, an error will be returned. Renew(id LeaseID) (int64, error) // Lookup gives the lease at a given lease id, if any @@ -364,7 +369,10 @@ func (le *lessor) Revoke(id LeaseID) error { func (le *lessor) Checkpoint(id LeaseID, remainingTTL int64) error { le.mu.Lock() defer le.mu.Unlock() + return le.checkpoint(id, remainingTTL) +} +func (le *lessor) checkpoint(id LeaseID, remainingTTL int64) error { if l, ok := le.leaseMap[id]; ok { // when checkpointing, we only update the remainingTTL, Promote is responsible for applying this to lease expiry l.remainingTTL = remainingTTL @@ -388,9 +396,10 @@ func greaterOrEqual(first, second semver.Version) bool { return !version.LessThan(first, second) } -// Renew renews an existing lease. If the given lease does not exist or +// RenewV2 renews an existing lease. If the given lease does not exist or // has expired, an error will be returned. -func (le *lessor) Renew(id LeaseID) (int64, error) { +// TODO(ahrtr): remove the legacy method in 3.7 +func (le *lessor) RenewV2(id LeaseID) (int64, error) { le.mu.RLock() if !le.isPrimary() { // forward renew request to primary instead of returning error. @@ -442,6 +451,31 @@ func (le *lessor) Renew(id LeaseID) (int64, error) { return l.ttl, nil } +func (le *lessor) Renew(id LeaseID) (int64, error) { + le.mu.Lock() + defer le.mu.Unlock() + + l := le.leaseMap[id] + if l == nil { + return -1, ErrLeaseNotFound + } + + if !le.isPrimary() { + if l.remainingTTL > 0 { + le.checkpoint(id, 0) + } + return l.ttl, nil + } + + le.checkpoint(id, 0) + l.refresh(0) + item := &LeaseWithTime{id: l.ID, time: l.expiry} + le.leaseExpiredNotifier.RegisterOrUpdate(item) + + leaseRenewed.Inc() + return l.ttl, nil +} + func (le *lessor) Lookup(id LeaseID) *Lease { le.mu.RLock() defer le.mu.RUnlock() @@ -842,6 +876,8 @@ func (fl *FakeLessor) Promote(extend time.Duration) {} func (fl *FakeLessor) Demote() {} +func (fl *FakeLessor) RenewV2(id LeaseID) (int64, error) { return 10, nil } + func (fl *FakeLessor) Renew(id LeaseID) (int64, error) { return 10, nil } func (fl *FakeLessor) Lookup(id LeaseID) *Lease { return nil } diff --git a/server/lease/lessor_test.go b/server/lease/lessor_test.go index ae9ad52e820..0a0c1e0a40c 100644 --- a/server/lease/lessor_test.go +++ b/server/lease/lessor_test.go @@ -426,7 +426,9 @@ func TestLessorRecover(t *testing.T) { } } -func TestLessorExpire(t *testing.T) { +// TestLessorExpireV2 tests the legacy `RenewV2`. +// TODO(ahrtr): remove this test case when the legacy `RenewV2` is removed. +func TestLessorExpireV2(t *testing.T) { lg := zap.NewNop() dir, be := NewTestBackend(t) defer os.RemoveAll(dir) @@ -455,7 +457,7 @@ func TestLessorExpire(t *testing.T) { donec := make(chan struct{}, 1) go func() { // expired lease cannot be renewed - if _, err := le.Renew(l.ID); err != ErrLeaseNotFound { + if _, err := le.RenewV2(l.ID); err != ErrLeaseNotFound { t.Errorf("unexpected renew") } donec <- struct{}{} @@ -479,7 +481,50 @@ func TestLessorExpire(t *testing.T) { } } -func TestLessorExpireAndDemote(t *testing.T) { +func TestLessorExpire(t *testing.T) { + lg := zap.NewNop() + dir, be := NewTestBackend(t) + defer os.RemoveAll(dir) + defer be.Close() + + testMinTTL := int64(1) + + le := newLessor(lg, be, clusterLatest(), LessorConfig{MinLeaseTTL: testMinTTL}) + defer le.Stop() + + le.Promote(1 * time.Second) + l, err := le.Grant(1, testMinTTL) + if err != nil { + t.Fatalf("failed to create lease: %v", err) + } + + select { + case el := <-le.ExpiredLeasesC(): + if el[0].ID != l.ID { + t.Fatalf("expired id = %x, want %x", el[0].ID, l.ID) + } + case <-time.After(10 * time.Second): + t.Fatalf("failed to receive expired lease") + } + + if _, err := le.Renew(l.ID); err != nil { + t.Errorf("unexpected renew") + } + + // expired lease can be revoked + if err := le.Revoke(l.ID); err != nil { + t.Fatalf("failed to revoke expired lease: %v", err) + } + + // revoked lease can't be renewed + if _, err := le.Renew(l.ID); err != ErrLeaseNotFound { + t.Errorf("unexpected renew") + } +} + +// TestLessorExpireAndDemoteV2 tests the legacy `RenewV2`. +// TODO(ahrtr): remove this test case when the legacy `RenewV2` is removed. +func TestLessorExpireAndDemoteV2(t *testing.T) { lg := zap.NewNop() dir, be := NewTestBackend(t) defer os.RemoveAll(dir) @@ -508,7 +553,7 @@ func TestLessorExpireAndDemote(t *testing.T) { donec := make(chan struct{}, 1) go func() { // expired lease cannot be renewed - if _, err := le.Renew(l.ID); err != ErrNotPrimary { + if _, err := le.RenewV2(l.ID); err != ErrNotPrimary { t.Errorf("unexpected renew: %v", err) } donec <- struct{}{} @@ -520,7 +565,7 @@ func TestLessorExpireAndDemote(t *testing.T) { case <-time.After(50 * time.Millisecond): } - // demote will cause the renew request to fail with ErrNotPrimary + // demote will cause the renewV2 request to fail with ErrNotPrimary le.Demote() select { @@ -530,6 +575,44 @@ func TestLessorExpireAndDemote(t *testing.T) { } } +func TestLessorExpireAndDemote(t *testing.T) { + lg := zap.NewNop() + dir, be := NewTestBackend(t) + defer os.RemoveAll(dir) + defer be.Close() + + testMinTTL := int64(1) + + le := newLessor(lg, be, clusterLatest(), LessorConfig{MinLeaseTTL: testMinTTL}) + defer le.Stop() + + le.Promote(1 * time.Second) + l, err := le.Grant(1, testMinTTL) + if err != nil { + t.Fatalf("failed to create lease: %v", err) + } + + select { + case el := <-le.ExpiredLeasesC(): + if el[0].ID != l.ID { + t.Fatalf("expired id = %x, want %x", el[0].ID, l.ID) + } + case <-time.After(10 * time.Second): + t.Fatalf("failed to receive expired lease") + } + + if _, err := le.Renew(l.ID); err != nil { + t.Errorf("unexpected renew: %v", err) + } + + le.Demote() + + // renew should work after demote. + if _, err := le.Renew(l.ID); err != nil { + t.Errorf("unexpected renew: %v", err) + } +} + func TestLessorMaxTTL(t *testing.T) { lg := zap.NewNop() dir, be := NewTestBackend(t) diff --git a/tests/integration/v3_lease_test.go b/tests/integration/v3_lease_test.go index 8518b17879e..17121f53937 100644 --- a/tests/integration/v3_lease_test.go +++ b/tests/integration/v3_lease_test.go @@ -747,7 +747,7 @@ func TestV3LeaseFailover(t *testing.T) { // send keep alive to old leader until the old leader starts // to drop lease request. - var expectedExp time.Time + expectedExp := time.Now().Add(time.Duration(lresp.TTL) * time.Second) for { if err = lac.Send(lreq); err != nil { break