Commit Graph

596 Commits

Author SHA1 Message Date
Matthias Radestock
27c2f3a5d2 refactor: use propagateLatest
instead of the equivalent long-hand code.
2017-12-28 12:50:11 +00:00
Matthias Radestock
e69c8209fb remove redundant operation
We were setting the very same k/v that we just looked up.
2017-12-28 12:50:11 +00:00
Matthias Radestock
a8ad7f8898 refactor: simplify summarisation of internet nodes 2017-12-28 12:48:13 +00:00
Matthias Radestock
3d1a44aae0 extract label from id when summarising un[contained,managed]
I missed this in #2998.
2017-12-28 12:48:12 +00:00
Matthias Radestock
0b4512bd9b refactor: clarify and comment on summarisation logic 2017-12-27 13:54:30 +00:00
Matthias Radestock
705c6d159d sensible defaults/fallback for label and shape 2017-12-27 13:54:30 +00:00
Matthias Radestock
4206760021 refactor: lift some code out of inner loop 2017-12-27 13:54:30 +00:00
Matthias Radestock
7c5e9339bb render parents which we cannot resolve
The id and topology are enough to get some basic info for rendering.

This isn't just a fall-through for exceptional cases.
ContainerwithImageNameRenderer produces parent references using the
image name without version as the ID, and containers-by-image topology
uses that for grouping. By contrast, the container-image topology in
the report is keyed on docker image IDs.
2017-12-27 13:54:30 +00:00
Matthias Radestock
b88a2e4509 render sensible labels for parent nodes with little/no metadata
We eliminate the custom parent renderer, which was a very partial
implementation MakeBasicNodeSummary.

We also ensure that parents are always rendered in the same, sensible
order. Previously the order was an alphabetic sort of the parent
topology IDs. Now lower level topologies come before higher level
topologies.
2017-12-27 13:54:30 +00:00
Matthias Radestock
8cf65ea8b6 use BasicNodeSummary for rendering links in connection table
instead of the full NodeSummary
2017-12-27 13:54:30 +00:00
Matthias Radestock
0237b13916 refactor: extract BasicNodeSummary
This is sufficient for rendering links to nodes, and is cheaper to
compute that the full NodeSummary.
2017-12-27 13:54:30 +00:00
Matthias Radestock
367f2db003 always render metric urls
Fixes an omission.
2017-12-27 13:54:29 +00:00
Matthias Radestock
d1149dc29e add a basic test for rendering nodes with little/no metadata 2017-12-27 13:54:29 +00:00
Matthias Radestock
a9b8ced0a7 refactor: drop superfluous return value
Now that summary renderers always produce something, they no longer
need to indicate whether they did.
2017-12-27 13:54:29 +00:00
Matthias Radestock
da11655659 render sensible labels for group nodes with little/no metadata
The node ID of group nodes is in fact the same value as we get from
looking up the metadata key contained in the group topology id. So
just use that since a) we always have it, and b) we save a LatestMap
lookup.
2017-12-27 13:54:29 +00:00
Matthias Radestock
15881cd7fd render sensible labels for weave peer nodes with little/no metadata
We fall back to using the peerName as the label, which we always have.
2017-12-27 13:54:29 +00:00
Matthias Radestock
5e099640eb render sensible labels for swarm service nodes with little/no metadata
We fall back to using the service ID as the label.
2017-12-27 13:54:29 +00:00
Matthias Radestock
9aed0792ac render sensible labels for ecs task nodes with little/no metadata
We fall back to using the ARN as the label.
2017-12-27 13:54:29 +00:00
Matthias Radestock
289226707d render sensible labels for k8s nodes with little/no metadata
We fall back to using the object id as the label.
2017-12-27 13:54:29 +00:00
Matthias Radestock
f192e79346 render sensible labels for host nodes with little/no metadata
The node id, which we always have, actually contains the hostname.
2017-12-27 13:54:29 +00:00
Matthias Radestock
b83f7e8ce6 render sensible labels for images with little/no metadata
We fall back to image id when we cannot find a name. We extract the
image id from the node id rather than the docker.ImageID latest map
entry since that way we are guaranteed to get it.
2017-12-27 13:54:29 +00:00
Matthias Radestock
19dc67b6cf render sensible labels for pseudo nodes with little/no metadata
The main change here is to to label the node with its pseudoID as the
last resort.

We also set the rank to the pseudoID instead of the full node id,
since including the "pseudo:" prefix is not conducive to good ranking.

The rest is just moving from 'if' to 'switch'.
2017-12-27 13:54:27 +00:00
Matthias Radestock
d92c4b12c3 render sensible labels for containers with little/no metadata
We fall back to the truncated container id when we cannot find a
name. NB: this also happens when rendering a container as a parent.

We cope with the absence of an image name and/or host name.
2017-12-27 13:54:08 +00:00
Matthias Radestock
e5149aa7cd render sensible labels for processes with little/no metadata
We cope with the absence of the process name and/or container name,
and extract the hostID and pid from the node id rather than metadata
since that way we are guaranteed to get values for them.
2017-12-27 13:54:07 +00:00
Matthias Radestock
ec589e08f6 refactor: introduce ParseGroupNodeTopology 2017-12-26 02:27:54 +00:00
Matthias Radestock
b8eeadda34 refactor: don't set shape based on unitialised topology
This doesn't make any difference to the outcome - we were simply
setting the shape in the NodeSummary to "", which is what it starts
out as - but looks less weird in the code.
2017-12-26 02:27:54 +00:00
Matthias Radestock
bd214227dc introduce ParsePseudoNodeID
unused for now

A convenient place to document and deal with the ugliness.
2017-12-26 02:27:54 +00:00
Matthias Radestock
56a1efd38a optimisation: pre-allocate some maps
This doesn't make much of a difference, since we don't create many of
these. But it's easy enough to do, and every little helps.
2017-12-26 00:35:02 +00:00
Matthias Radestock
590fa55cf5 refactor: banish TheInternet
TheInternet hasn't existed as a single node for a long time.

We also move & export the IsInternetNode predicate so it can be used
in more places.
2017-12-25 18:29:04 +00:00
Matthias Radestock
ceb3539d35 ensure hostNodeIDs actually are what they claim
It's a dynamic type check of sorts.

In the process we stop abusing ParseNodeID for extracting the host,
which in turn allows us to clarify its purpose.
2017-12-25 18:14:34 +00:00
Matthias Radestock
a8e3d04d21 cosmetic: fix some comments 2017-12-25 16:21:46 +00:00
Matthias Radestock
3de04685f8 optimisation: pre-allocate, and fewer slices during summarisation
Pre-allocating slices really pays dividends when we create loads of
them and they don't grow very large.

We take special care to return nil rather than 0-length slices. This
a) saves further on allocation, and b) is required for some crude
tests to pass that match on nil rather than length.

Also, a bunch of code in templates/tables used slices as Maybe's,
i.e. returning nil or a single-element slice, which is horrendously
inefficient. Eliminating these saves a lot of allocations.
2017-12-25 12:33:43 +00:00
Matthias Radestock
fc66827af7 refactor: don't set shape based on unitialised topology
This doesn't make any difference to the outcome - we were simply
setting the shape in the NodeSummary to "", which is what it starts
out as - but looks less weird in the code.
2017-12-23 22:39:08 +00:00
Matthias Radestock
d861b41837 refactor: inline summarisation of metadata, metrics, tables
This removes a bunch of duplication and scattering of little pieces of
code.
2017-12-23 22:34:45 +00:00
Matthias Radestock
651e42e54e fix accidental report fixture modification
Report.Copy() shallow-copies the nodes in Report.Nodes. Hence
Node.Metrics is shared between the original and the copy. Hence bad
things happen when modifying it.

This bug has laid dormant because by luck other tests in detailed_test
involving metrics are executed first.
2017-12-23 22:21:24 +00:00
Matthias Radestock
724ea0c230 refactor: extract common code of joinResults.addChild variants 2017-12-21 10:05:56 +00:00
Matthias Radestock
9713a156c7 refactor: extract helper 2017-12-21 10:05:56 +00:00
Matthias Radestock
7d261d0ca0 don't map image adjacencies to hosts
it's just wrong
2017-12-21 10:05:56 +00:00
Matthias Radestock
ee4a56e8ad optimse common one->one mapping case
one->many is much rarer
2017-12-19 19:34:52 +00:00
Matthias Radestock
25eeec0227 enhance joinResult to handle mapping one node to multiple nodes 2017-12-18 21:13:15 +00:00
Matthias Radestock
f920f1b9d2 refactor: extract helper to add joinResult mapping 2017-12-18 18:41:52 +00:00
Matthias Radestock
ba7af78cfa ensure result adjacencies start empty
Any existing list would be mutated by result(), which is bad.

Note that all the existing newJoinResults() call sites pass in nodes
with no adjacencies, so this is purely a safety measure.
2017-12-17 18:24:32 +00:00
Matthias Radestock
a6f24fc151 remove superfluous lookups
Since we seed the joinResult with the nodes from the topology we are
mapping to, we know the 'create' function is only called when there is
no node with the specified id.

This neatly makes the 'create' function only do what it says,
i.e. return _new_ nodes.
2017-12-17 18:24:32 +00:00
Matthias Radestock
ac87c2b6e8 optimise & simplify node propagation in joinResult
Instead of copying unmatched nodes at the end, and matched nodes when
we encounter them, copy *all* nodes at the beginning.
2017-12-17 18:14:48 +00:00
Matthias Radestock
4dde1ce715 optimise and align endpoints2Hosts
Avoid a reduce step by joining the host topology in endpoints2Hosts.

This is similar to what we do in connectionJoin and
endpoints2Processes.
2017-12-17 18:14:47 +00:00
Matthias Radestock
f16908aea9 refactor: fix up adjacencies as part of joinResult.result() 2017-12-17 18:14:47 +00:00
Matthias Radestock
e5117a652f remove superfluous fixupAdjacencies calls
fixupAdjacencies fixes up adjancencies of mapped nodes. The nodes at
the call sites we are removing aren't mapped.
2017-12-17 18:14:30 +00:00
Matthias Radestock
cc859926ef tiny simplifying refactor 2017-12-17 15:36:28 +00:00
Matthias Radestock
0c894e9446 refactor: drop networks from render.MapFunc
All the MapFuncs that needed networks have been elevated to Renderers.
2017-12-17 00:18:12 +00:00
Matthias Radestock
20138b9218 don't exclude NATed connections in mapping to processes
We used to ignore source endpoints that are associated with multiple
destination endpoints, which is a partial workaround for our inability
to correctly represent two connections from the same source ip/port
but different processes, or the same destination ip/port but different
processes. See #2665.

However, that condition is too coarse. In particular, we end up
ignoring endpoints that are connected to NATed destinations, since the
latter are represented by two (or more) endpoints.

The change here corrects that.
2017-12-15 11:40:43 +00:00