From 4df4ba70caf2de3b68158d9e6cb9a6f4ea203e0f Mon Sep 17 00:00:00 2001 From: Santhosh Manohar Date: Sun, 4 Oct 2015 07:42:59 -0700 Subject: [PATCH] Fix the daemon panic on consul server restart Signed-off-by: Santhosh Manohar --- libnetwork/datastore/datastore.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libnetwork/datastore/datastore.go b/libnetwork/datastore/datastore.go index e36da4221e..70be5c9cc1 100644 --- a/libnetwork/datastore/datastore.go +++ b/libnetwork/datastore/datastore.go @@ -265,6 +265,13 @@ func (ds *datastore) Watch(kvObject KVObject, stopCh <-chan struct{}) (<-chan KV close(sCh) return case kvPair := <-kvpCh: + // If the backend KV store gets reset libkv's go routine + // for the watch can exit resulting in a nil value in + // channel. + if kvPair == nil { + close(sCh) + return + } dstO := ctor.New() if err := dstO.SetValue(kvPair.Value); err != nil {