Skip to content

Commit

Permalink
fix etcd lease
Browse files Browse the repository at this point in the history
I made a comment in WuYi's PR that this is not necessary, so WuYi
removed it. Turns out it's necessary after confirming with coreOS
developer.
  • Loading branch information
helinwang committed Jun 23, 2017
1 parent 94bfe2b commit e558ed0
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 e558ed0

Please sign in to comment.