From 7d24615d8e98a43cdc59bc79075d8813ba0415f7 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Wed, 13 Aug 2014 14:19:16 -0400 Subject: [PATCH] Etcd can close the watch channel for services Need to loop and reopen if it's closed. --- pkg/proxy/config/etcd.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/proxy/config/etcd.go b/pkg/proxy/config/etcd.go index dad0eecad86..15c66320851 100644 --- a/pkg/proxy/config/etcd.go +++ b/pkg/proxy/config/etcd.go @@ -40,6 +40,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/tools" + "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/coreos/go-etcd/etcd" "github.com/golang/glog" ) @@ -93,7 +94,7 @@ func (s ConfigSourceEtcd) Run() { // Ok, so we got something back from etcd. Let's set up a watch for new services, and // their endpoints - go s.WatchForChanges() + go util.Forever(s.WatchForChanges, 1*time.Second) for { services, endpoints, err = s.GetServices() @@ -186,7 +187,10 @@ func (s ConfigSourceEtcd) WatchForChanges() { watchChannel := make(chan *etcd.Response) go s.client.Watch("/registry/services/", 0, true, watchChannel, nil) for { - watchResponse := <-watchChannel + watchResponse, ok := <-watchChannel + if !ok { + break + } s.ProcessChange(watchResponse) } }