From 7f803506ad40a87379c2da141c6ed46d0062b769 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sat, 11 Oct 2014 12:01:35 +0100
Subject: [PATCH] update watch index on error 401

Make progress anyway when the history is gone.
---
 node/node.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/node/node.go b/node/node.go
index 5dbc2545..25222543 100644
--- a/node/node.go
+++ b/node/node.go
@@ -201,6 +201,15 @@ func (w *ConfigSyncer) Start() {
 			} else if err != nil {
 				// Log the error and start over.
 				log.Printf("Watch(): %s", err)
+
+				// If the error is code 401 ("index
+				// out of date"), start from the
+				// current index. TODO: consider
+				// calling loadFullConfig, or we might
+				// potentially lose some updates?
+				if etcdErr, ok := err.(*etcd.EtcdError); ok && etcdErr.ErrorCode == 401 {
+					w.setIndex(etcdErr.Index)
+				}
 			}
 		}
 	}()
-- 
GitLab