handle watch errors everywhere

This commit is contained in:
Daniel Smith
2014-09-22 17:37:12 -07:00
parent 8fd1fb4337
commit f211e46f20
6 changed files with 47 additions and 14 deletions

View File

@@ -60,18 +60,18 @@ func NewSourceEtcd(key string, client tools.EtcdClient, updates chan<- interface
}
func (s *SourceEtcd) run() {
watching, err := s.helper.Watch(s.key, 0)
if err != nil {
glog.Errorf("Failed to initialize etcd watch: %v", err)
return
}
watching := s.helper.Watch(s.key, 0)
for {
select {
case event, ok := <-watching.ResultChan():
if !ok {
return
}
if event.Type == watch.Error {
glog.Errorf("Watch error: %v", event.Object)
watching.Stop()
return
}
pods, err := eventToPods(event)
if err != nil {
glog.Errorf("Failed to parse result from etcd watch: %v", err)