From 6c2a3abf22295001e11869d233ed22d6a197468d Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Tue, 19 Nov 2013 13:49:19 +0000
Subject: [PATCH] fix some comments where the code has been updated

---
 masterelection/masterelection.go | 15 +++++++++------
 node/node.go                     |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/masterelection/masterelection.go b/masterelection/masterelection.go
index eb89748c..a37a9f7d 100644
--- a/masterelection/masterelection.go
+++ b/masterelection/masterelection.go
@@ -106,7 +106,7 @@ func (m *MasterElection) runMaster(index uint64) {
 		case t := <-tick.C:
 			// To verify that we actually are still the
 			// master (not just we believe we are), try
-			// yet another compare-and-swap to check that
+			// a compare-and-swap operation to check that
 			// the stored master address is still our own,
 			// and no-one stole our lock. If not, the TTL
 			// will be updated (and the lock renewed).
@@ -136,7 +136,9 @@ func (m *MasterElection) runSlave(index uint64) {
 		// Start a watch on the lock, waiting for its removal.
 		response, err := m.client.Watch(m.Path, index+1, nil, m.stop)
 		if err != nil {
-			log.Printf("slave Watch() error: %+v", err)
+			if err != etcd.ErrWatchStoppedByUser {
+				log.Printf("slave Watch() error: %+v", err)
+			}
 			return
 		}
 
@@ -162,15 +164,16 @@ func (m *MasterElection) Run() {
 		// Since a failed Create does not return the
 		// RAFT index, let's optimistically query the lock
 		// before starting just to set a baseline for the
-		// index.
+		// following Watch().
 		if iresponse, err := m.client.Get(m.Path, false); err == nil {
 			log.Printf("lock already exists: %+v", iresponse)
 			watchIndex = iresponse.ModifiedIndex
 		}
 
-		// Try to acquire the lock. If we are currently the
-		// master, the previous value should be our own
-		// address, otherwise it should be unset.
+		// Try to acquire the lock. This call will only succeed
+		// if the lockfile does not exist (either because it
+		// expired, or the previous master exited gracefully and
+		// deleted it).
 		response, err := m.client.Create(m.Path, m.Addr, m.TTL)
 
 		if err == nil {
diff --git a/node/node.go b/node/node.go
index 390c8cf5..5413dc42 100644
--- a/node/node.go
+++ b/node/node.go
@@ -175,6 +175,7 @@ func (w *ConfigSyncer) Run() {
 			if err == etcd.ErrWatchStoppedByUser {
 				return
 			} else if err != nil {
+				// Log the error, but keep watching.
 				log.Printf("Watch(): %s", err)
 			}
 		}
-- 
GitLab