Browse code

Fix README flag and expose orphan network peers

- Readme example was using wrong flag
- Network peers were not exposed properly

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

Flavio Crisciani authored on 2018/03/24 02:19:02
Showing 3 changed files
... ...
@@ -252,11 +252,11 @@ Remember to use the full network ID, you can easily find that with `docker netwo
252 252
 **Service discovery and load balancer:**
253 253
 
254 254
 ```bash
255
-$ diagnostiClient -c sd -v -net n8a8ie6tb3wr2e260vxj8ncy4 -a
255
+$ diagnostiClient -t sd -v -net n8a8ie6tb3wr2e260vxj8ncy4 -a
256 256
 ```
257 257
 
258 258
 **Overlay network:**
259 259
 
260 260
 ```bash
261
-$ diagnostiClient -port 2001 -c overlay -v -net n8a8ie6tb3wr2e260vxj8ncy4 -a
261
+$ diagnostiClient -port 2001 -t overlay -v -net n8a8ie6tb3wr2e260vxj8ncy4 -a
262 262
 ```
... ...
@@ -313,7 +313,7 @@ func (nDB *NetworkDB) Peers(nid string) []PeerInfo {
313 313
 		} else {
314 314
 			// Added for testing purposes, this condition should never happen else mean that the network list
315 315
 			// is out of sync with the node list
316
-			peers = append(peers, PeerInfo{})
316
+			peers = append(peers, PeerInfo{Name: nodeName, IP: "unknown"})
317 317
 		}
318 318
 	}
319 319
 	return peers
... ...
@@ -84,7 +84,11 @@ func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) {
84 84
 		peers := nDB.Peers(r.Form["nid"][0])
85 85
 		rsp := &diagnostic.TableObj{Length: len(peers)}
86 86
 		for i, peerInfo := range peers {
87
-			rsp.Elements = append(rsp.Elements, &diagnostic.PeerEntryObj{Index: i, Name: peerInfo.Name, IP: peerInfo.IP})
87
+			if peerInfo.IP == "unknown" {
88
+				rsp.Elements = append(rsp.Elements, &diagnostic.PeerEntryObj{Index: i, Name: "orphan-" + peerInfo.Name, IP: peerInfo.IP})
89
+			} else {
90
+				rsp.Elements = append(rsp.Elements, &diagnostic.PeerEntryObj{Index: i, Name: peerInfo.Name, IP: peerInfo.IP})
91
+			}
88 92
 		}
89 93
 		log.WithField("response", fmt.Sprintf("%+v", rsp)).Info("network peers done")
90 94
 		diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json)