Skip to content
Snippets Groups Projects
Commit 6c2a3abf authored by ale's avatar ale
Browse files

fix some comments where the code has been updated

parent 7ee361e9
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -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)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment