Skip to content

Commit

Permalink
Merge pull request #2573 from helinwang/keep_alive
Browse files Browse the repository at this point in the history
fix etcd lease
  • Loading branch information
helinwang committed Jun 23, 2017
2 parents a21c881 + e558ed0 commit f277726
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion go/pserver/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,18 @@ func (s *Service) registerPserverEtcd(ctx context.Context) (*clientv3.TxnRespons
// find the first id and write info
c.Put(psKey, s.externalIP, clientv3.WithLease(resp.ID))
log.Debugf("set pserver node %s with value %s", psKey, s.externalIP)
_, kaerr := s.etcdClient.KeepAlive(context.TODO(), resp.ID)
ch, kaerr := s.etcdClient.KeepAlive(context.TODO(), resp.ID)
if kaerr != nil {
log.Errorf("keepalive etcd node error: %v", kaerr)
return kaerr
}

// Eat the keep alive message so etcd
// will not expire the lease.
go func(ch <-chan *clientv3.LeaseKeepAliveResponse) {
ka := <-ch
log.Debugf("keepalive: %d\n", ka.TTL)
}(ch)
log.Debug("register finished")
registered = true
break
Expand Down

0 comments on commit f277726

Please sign in to comment.