Commit Graph

71 Commits

Author SHA1 Message Date
Peter Bourgon
0dafad763f Calculate rates in detailed nodes 2015-08-03 16:04:06 +02:00
Peter Bourgon
e1f7752a34 Split PacketCount to Egress and Ingress
Also, 1 packet may be counted in N topologies, so you can't rely on the
sum of all packet counts across topologies having any relation to the
sampling data.
2015-08-03 14:58:41 +02:00
Peter Bourgon
0361b11b87 Fix bugs in how we report bandwidth 2015-08-03 12:25:56 +02:00
Peter Bourgon
0aadf6447b Revert to correct edge construction
Another implicit invariant in the data model is that edges are always of the
form (local -> remote). That is, the source of an edge must always be a node
that originates from within Scope's domain of visibility. This was evident by
the presence of ingress and egress fields in edge/aggregate metadata.

When building the sniffer, I accidentally and incorrectly violated this
invariant, by constructing distinct edges for (local -> remote) and (remote ->
local), and collapsing ingress and egress byte counts to a single scalar. I
experienced a variety of subtle undefined behavior as a result. See #339.

This change reverts to the old, correct methodology. Consequently the sniffer
needs to be able to find out which side of the sniffed packet is local v.
remote, and to do that it needs access to local networks. I moved the
discovery from the probe/host package into probe/main.go.

As part of that work I discovered that package report also maintains its own,
independent "cache" of local networks. Except it contains only the (optional)
Docker bridge network, if it's been populated by the probe, and it's only used
by the report.Make{Endpoint,Address}NodeID constructors to scope local
addresses. Normally, scoping happens during rendering, and only for pseudo
nodes -- see current LeafMap Render localNetworks. This is pretty convoluted
and should be either be made consistent or heavily commented.
2015-08-03 10:55:59 +02:00
Peter Bourgon
c7a06d2a43 Don't flat-embed sampling in the report
In the JSON representation, we want the Sampling data to be distinct.
2015-08-03 10:55:59 +02:00
Peter Bourgon
b9afa67ad6 gopacket-based traffic sniffing 2015-08-03 10:55:59 +02:00
Peter Bourgon
b3868c58d7 Fix a subtle bug in render mapping
During rendering, RenderableNodes are created by Map funcs, which take only
NodeMetadata. Previously, it was simply assumed that the relevant keys for a
given Map func would be present in the metadata. If that implicit invariant
failed, the returned RenderableNode would be invalid, with e.g. an ID of
"hostid::". That, in turn, would trigger undefined behavior later on in the
rendering workflow.

This bug was detected by creating a partial node metadata for a non-local
endpoint node. That node was detected during the first phase of rendering, and
given an invalid renderable node ID of "myhostname::", which prevented it from
attaching to TheInternet pseudonode. It eventually got removed from the  set
of valid nodes, which meant nodes that were adjacent to it suddenly became
orphans, and got filtered out by the FilterUnconnected step of the rendering
pipeline.

With this change, every map func checks for the presence of mandatory fields,
i.e. the fields that compose the resulting renderable node's ID.

Also,

- Add unit tests for LeafMapFuncs
- Topology Validate checks NodeMetadatas must not have nil Metadata
2015-08-03 10:43:07 +02:00
Peter Bourgon
3dd59c8b9b Fixes to NodeMetadata
NewNodeMetadata -> MakeNodeMetadata. It doesn't return a pointer, so
Make is more idiomatic.

Invoke MakeNodeMetadata when necessary. The zero value for a
NodeMetadata is no longer valid.

Split MakeNodeMetadata to two constructors. MakeNodeMetadata when you
don't have anything to prepopulate; MakeNodeMetadataWith when you do.

Also, a fix to the tests in app. We unmarshal a RenderableNode struct,
which has a JSON-ignored NodeMetadata field. The zero value is invalid,
so we need to fix that before performing comparisons.
2015-07-30 17:20:44 +02:00
Tom Wilkie
f85195308c report.Metadata -> map[string]string 2015-07-16 12:06:05 +00:00
Tom Wilkie
c2065836e2 Make NodeMetadata a struct, move existing map[string]string to NodeMetadata.Metadata 2015-07-15 10:06:36 +00:00
Bryan Boreham
1fa853befe Neater implementation of de-duplication in MakeIDList() 2015-07-08 13:38:39 +01:00
Bryan Boreham
35f9dc622e More efficient slice-insert - less copying, less garbage 2015-07-07 22:36:22 +01:00
Bryan Boreham
baf0d94af9 Implement a Merge function on IDLists which is more efficient than repeated Add 2015-07-07 22:36:22 +01:00
Bryan Boreham
76d658b193 Make MakeIDList() enforce invariant 2015-07-07 22:16:50 +01:00
Paul Bellamy
95f941ff2d const-izing NodeMetadata fields 2015-07-02 14:51:12 +01:00
Paul Bellamy
cd71f82d4d aggregate connection details table
List Local and Remote endpoints for each TCP connection on the node.
2015-07-02 14:21:16 +01:00
Peter Bourgon
90a0286909 Refactor tests to have appropriate packages
By default, tests should be in package pkg_test. If they need to test
package internals, they can be in package pkg, but then should carry a
suffix of foo_internal_test.go.

This changeset enforces that idiom across the codebase, and adds a check
to the linter to make sure it remains.

Also, some fixes to comments.
2015-06-29 18:06:44 +02:00
Tom Wilkie
416f56c3cc Only have a single report fixture
- Move render.Rpt to test.Report
- Remove report/report_fixture_test.go; it was unused
- Remove report fixture in app/ and make tests use test.Report
- Move expected outputs into render/expected, so they can be reused
2015-06-24 09:51:29 +00:00
Tom Wilkie
152774a812 Extract out rendered node id generation into a small set of functions. 2015-06-23 07:42:17 +00:00
Tom Wilkie
82a7f93e17 Treat addresses on the docker bridge as local. 2015-06-22 11:24:47 +00:00
Tom Wilkie
49dae07cca Make render module produce The Internet pseudo node. 2015-06-19 11:09:52 +00:00
Tom Wilkie
f32d2b5a5e Remove report squash logic. 2015-06-18 17:20:20 +00:00
Tom Wilkie
25ca0c0eb7 Add ContainerImage topology and use it to build the Container By Image graph.
This makes container image details show the containers (and processes) correctly.

Also:
- introduces a 'test' package, moved Diff function there.
- adds some tests for this new rendered view.
2015-06-18 09:16:20 +00:00
Tom Wilkie
f971ac12bf Move AggregateMetadata into render package. 2015-06-17 19:26:13 +00:00
Tom Wilkie
18c544701a Review feedback 2015-06-17 17:23:33 +00:00
Tom Wilkie
16e2ccd2be Produce the container topology by way of the process topology. 2015-06-17 17:23:20 +00:00
Tom Wilkie
7f9eee3b08 Merge pull request #242 from tomwilkie/228-more-moves
Move RenderableNode and DetailedNode into render/
2015-06-16 18:36:31 +02:00
Tom Wilkie
2a4a33f30a Move RenderableNode and DetailedNode into render/ 2015-06-16 15:37:08 +00:00
Peter Bourgon
990d527664 Merge pull request #219 from weaveworks/weave-tagger
WeaveTagger and the Overlay topology
2015-06-16 16:56:12 +02:00
Peter Bourgon
e3c5b7f36d Add WeaveTagger
- report: add Overlay topology
- probe/tag: introduce WeaveTagger
2015-06-16 16:29:50 +02:00
Tom Wilkie
4726b48f4e Move topology diff to render package. 2015-06-16 14:25:34 +00:00
Tom Wilkie
ae9ea5c97f Move mapping functions and main render function in render package. 2015-06-16 14:23:56 +00:00
Peter Bourgon
65d79d2908 Merge pull request #236 from weaveworks/clarify-validation
Improve error messages during report validation
2015-06-16 16:19:02 +02:00
Peter Bourgon
49ec565a04 Improve error messages during report validation 2015-06-16 10:42:40 +02:00
Tom Wilkie
d71f10773f Remove MappedNode type; mappers return RenderableNodes 2015-06-15 16:25:36 +00:00
Peter Bourgon
c65aecd9e1 Fix node scoping rules
We only want to scope (i.e. prefix with hostID) those addresses that are
deemed loopback, to disambiguate them. Otherwise, we want to leave
addresses in unscoped form, so they can be matched, and links between
communicating nodes properly made.

So, we make the isLoopback check in MakeAddressID, and omit hostID if
the address isn't loopback. So far so good.

But this breaks topology rendering, as we were relying on extracting
hostID from adjacency node IDs, to populate origin hosts in the rendered
node output. So we need another way to get origin host from an arbitrary
node.

A survey revealed no reliable way to get that information from IDs in
their new form. However, we have access to node metadata, so this
changeset introduces the OriginHostTagger, which tags each node with its
origin host, via the foreign-key semantics we'll use going forward.
2015-06-15 14:36:48 +02:00
Peter Bourgon
032e78d99d Dedupe tables in detail pane 2015-06-15 11:20:30 +02:00
Tom Wilkie
53456179e4 All merging of RenderableNodes, such that we can merge multiple topologies. 2015-06-11 17:11:10 +00:00
Tom Wilkie
ae84861e00 Now we have merged topologies, we don't need to put so much data on the endpoint topology, or render so much info. 2015-06-11 16:57:24 +00:00
Tom Wilkie
c5d10867c6 Add Validate method to Report & Topology. 2015-06-11 13:27:49 +00:00
Tom Wilkie
ff11022862 Add Containers topology populated by the Docker tagger. 2015-06-10 16:01:15 +00:00
Peter Bourgon
d435e36834 Add and populate Process topology
Also, add comm value (name) to process node metadata.
2015-06-10 17:27:07 +02:00
Peter Bourgon
342d887667 Merge pull request #202 from weaveworks/report-tests
Add TestOriginTable
2015-06-10 11:38:59 +02:00
Peter Bourgon
c8b995ee34 Add TestOriginTable
Leaves some process topology bits commented out, for the future.
2015-06-10 11:32:03 +02:00
Tom Wilkie
616759200f Merge pull request #197 from tomwilkie/196-foo
Don't make adjacency edges into 'the internet' if they refer to valid nodes
2015-06-10 10:31:22 +01:00
Tom Wilkie
719f933c21 Refactor MakeAdjacencyID & ParseAdjacencyID; add ParseNodeID (which separates scope and the rest of node id) 2015-06-10 09:21:45 +00:00
Tom Wilkie
96327a48c1 Don't make adjacency edges into 'the internet' if they refer to valid nodes. 2015-06-10 08:42:53 +00:00
Tom Wilkie
cce2e3c0b5 Restore container details to their rightful position. 2015-06-10 07:53:57 +00:00
Peter Bourgon
667d8b8dd0 OriginHosts and OriginNodes become Origins
Another baby step towards #123, this change follows from #192 and merges
the two concepts of Origin in a renderable node. We also cut out a layer
of abstraction, and add an OriginTable method to Report, which directly
generates a table of info for the detail pane given any origin node ID.

Other changes from feedback:

- Assume origin IDs are unique and don't reflect.Dedupe
- Improve origin ID lookup
- Move OriginTable to detailed_node.go, as a free function
- rm app/detail_pane.go (empty)
2015-06-09 18:48:09 +02:00
Peter Bourgon
da90f4489a Remove dead code 2015-06-09 16:39:29 +02:00