VOL-806: Envoy polls etcd for changes in core assignments

* Replaced polling loop with an etcd watch channel.
* Fixed a coordinator log message that sometimes causes
  an exception.

Change-Id: I6e523b30724d2f1e953928b705fb847cb43dca4f
diff --git a/envoy/go/envoyd/envoyd.go b/envoy/go/envoyd/envoyd.go
index b1a4067..d4b8b05 100644
--- a/envoy/go/envoyd/envoyd.go
+++ b/envoy/go/envoyd/envoyd.go
@@ -526,35 +526,28 @@
 func (ec * EnvoyControl) monitorEtcdKey() {
 	var err error
 
-	// TODO: Check into the use of any data consistency options
-	//
 	// Get the initial values of the assignment key which contains individual
 	// voltha core IP addresses. This may be empty until voltha populates it
 	// so it must be checked
-	log.Printf("Monitoring etcd key")
-	val, index, err := ec.readEtcdKey(ec.assignmentKey)
-	lastIndex := index
-	log.Printf("Starting Envoy, initial index = %d", lastIndex)
-	ec.runEnvoy(val)
 
-	for {
-		for {
-			time.Sleep(60 * time.Second)
-			val, index, err = ec.readEtcdKey(ec.assignmentKey)
-			if err != nil {
-				log.Fatal("Unable to read assignment etcd key: %s\n", err.Error())
-			} else if index != lastIndex {
-			       break
-			} else {
-				log.Println(string(val))
-				log.Printf("Last index = %d", index)
-			}
-		}
-		// Fell through, the index has changed thus the key has changed
-		log.Printf("Starting Envoy")
+	log.Printf("Monitoring etcd key %s", ec.assignmentKey)
+	val, index, err := ec.readEtcdKey(ec.assignmentKey)
+	if err == nil {
+		lastIndex := index
+		log.Printf("Starting Envoy, initial index = %d", lastIndex)
 		ec.runEnvoy(val)
-		log.Printf("Last index = %d", index)
-		lastIndex = index
+	}
+
+	rch := ec.etcd.Watch(context.Background(), ec.assignmentKey)
+	for resp := range rch {
+	    for _, ev := range resp.Events {
+	    	val = ev.Kv.Value
+	    	log.Printf("%s %q : %q\n", ev.Type, ev.Kv.Key, ev.Kv.Value)
+	    	if ev.Type == etcdapi.EventTypePut {
+				log.Printf("Starting Envoy")
+				ec.runEnvoy(val)
+			}
+	    }
 	}
 }
 
diff --git a/voltha/coordinator_etcd.py b/voltha/coordinator_etcd.py
index 8ed25e0..3c13f67 100644
--- a/voltha/coordinator_etcd.py
+++ b/voltha/coordinator_etcd.py
@@ -580,7 +580,7 @@
                     log.exception(e)
                 yield self._backoff('unknown-error')
 
-        log.info('end-op', operation=operation, args=args, kw=kw, result=result)
+        log.info('end-op', operation=operation, args=args, kw=kw)
         returnValue(result)
 
     @inlineCallbacks