From f906511deda1d0fbceb3a8eaddc7d9e3f0a08734 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 26 Oct 2016 09:09:01 +0000 Subject: [PATCH] Add initial metadata in details panel and clarification comments --- common/weave/client.go | 7 ++++--- probe/overlay/weave.go | 13 +++++++++++++ render/weave.go | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common/weave/client.go b/common/weave/client.go index 4ec39ca78..8f0ed8d82 100644 --- a/common/weave/client.go +++ b/common/weave/client.go @@ -25,9 +25,10 @@ type Client interface { // Status describes whats happen in the Weave Net router. type Status struct { - Router Router - DNS DNS - IPAM IPAM + Version string + Router Router + DNS DNS + IPAM IPAM } // Router describes the status of the Weave Router diff --git a/probe/overlay/weave.go b/probe/overlay/weave.go index d4b173d68..eb0608e32 100644 --- a/probe/overlay/weave.go +++ b/probe/overlay/weave.go @@ -27,6 +27,9 @@ const ( // WeaveMACAddress is the key for the mac address of the container on the // weave network, to be found in container node metadata WeaveMACAddress = "weave_mac_address" + + // WeaveVersion is the key for the weave version running on the peer + WeaveVersion = "weave_version" ) // Weave represents a single Weave router, presumably on the same host @@ -163,14 +166,24 @@ func (w *Weave) Report() (report.Report, error) { WeaveMACAddress: {ID: WeaveMACAddress, Label: "Weave MAC", From: report.FromLatest, Priority: 17}, WeaveDNSHostname: {ID: WeaveDNSHostname, Label: "Weave DNS Name", From: report.FromLatest, Priority: 18}, }) + r.Overlay = r.Overlay.WithMetadataTemplates(report.MetadataTemplates{ + WeavePeerName: {ID: WeavePeerName, Label: "Peer Name", From: report.FromLatest, Truncate: 17, Priority: 1}, + WeaveVersion: {ID: WeaveVersion, Label: "Version", From: report.FromLatest, Priority: 2}, + }) + + // We report nodes for all peers (not just the current node) to highlight peers not monitored by Scope + // (i.e. without a running probe) + // Note: this will cause redundant information (n^2) if all peers have a running probe for _, peer := range w.statusCache.Router.Peers { node := report.MakeNodeWith(report.MakeOverlayNodeID(report.WeaveOverlayPeerPrefix, peer.Name), map[string]string{ WeavePeerName: peer.Name, WeavePeerNickName: peer.NickName, }) + // Peer corresponding to current host if peer.Name == w.statusCache.Router.Name { node = node.WithLatest(report.HostNodeID, mtime.Now(), w.hostID) + node = node.WithLatest(WeaveVersion, mtime.Now(), w.statusCache.Version) node = node.WithParents(report.EmptySets.Add(report.Host, report.MakeStringSet(w.hostID))) } for _, conn := range peer.Connections { diff --git a/render/weave.go b/render/weave.go index 9855c766e..216a0cf1c 100644 --- a/render/weave.go +++ b/render/weave.go @@ -23,6 +23,9 @@ func MapWeaveIdentity(m report.Node, _ report.Networks) report.Nodes { nickname, _ = m.Latest.Lookup(overlay.WeavePeerNickName) ) + // Nodes without a host id indicate they are not monitored by Scope + // (their info doesn't come from a probe monitoring that peer directly) + // , display them as pseudo nodes. if _, ok := node.Latest.Lookup(report.HostNodeID); !ok { id := MakePseudoNodeID(UnmanagedID, nickname) node = NewDerivedPseudoNode(id, m)