make process-by-name topology show something (again)

...when 'Hide Unconnected' is selected, which is the default.

Here's the problem...

The connectedness filter looks for `is_connected` marks in the Latest
map of the nodes. The mark is added by ColorConnected, which is
invoked by ProcessRenderer. That in turn is the base renderer for
ProcessNameRenderer, which is what the process-by-name view
renders. However, the process2Names mapping does not propagate any
metadata, hence there are no `is_connected` marks on the result
nodes. Consequently they are all filtered out.

The problem was introduced in #3009, when I added the ability for
users to chose whether to show or hide unconnected
processes (previously unconnected processes were always hidden) -
looks like I failed to check that the process-by-name view was working
with the new filter. Oops.

The fix is to move the ColorConnected call from ProcessRenderer to the
higher-level renderers - ProcessWithContainerNameRenderer (which is
what the 'Processes' view renders) and ProcessNameRenderer.

This has the beneficial side effect of improving performance for other
renderers which invoke ProcessRenderer, none of which need
connectedness-coloring.

Fixes #3205
This commit is contained in:
Matthias Radestock
2018-06-03 07:01:40 +01:00
parent 3a718d6702
commit 15b605f804

View File

@@ -20,10 +20,8 @@ func renderProcesses(rpt report.Report) bool {
}
// ProcessRenderer is a Renderer which produces a renderable process
// graph by merging the endpoint graph and the process topology. It
// also colors connected nodes, so we can apply a filter to show/hide
// unconnected nodes depending on user choice.
var ProcessRenderer = Memoise(ColorConnected(endpoints2Processes{}))
// graph by merging the endpoint graph and the process topology.
var ProcessRenderer = Memoise(endpoints2Processes{})
// processWithContainerNameRenderer is a Renderer which produces a process
// graph enriched with container names where appropriate
@@ -52,17 +50,23 @@ func (r processWithContainerNameRenderer) Render(rpt report.Report) Nodes {
return Nodes{Nodes: outputs, Filtered: processes.Filtered}
}
// ProcessWithContainerNameRenderer is a Renderer which produces a process
// graph enriched with container names where appropriate
// ProcessWithContainerNameRenderer is a Renderer which produces a
// process graph enriched with container names where appropriate.
//
// It also colors connected nodes, so we can apply a filter to
// show/hide unconnected nodes depending on user choice.
//
// not memoised
var ProcessWithContainerNameRenderer = processWithContainerNameRenderer{ProcessRenderer}
var ProcessWithContainerNameRenderer = ColorConnected(processWithContainerNameRenderer{ProcessRenderer})
// ProcessNameRenderer is a Renderer which produces a renderable process
// name graph by munging the progess graph.
// ProcessNameRenderer is a Renderer which produces a renderable
// process name graph by munging the progess graph.
//
// It also colors connected nodes, so we can apply a filter to
// show/hide unconnected nodes depending on user choice.
//
// not memoised
var ProcessNameRenderer = CustomRenderer{RenderFunc: processes2Names, Renderer: ProcessRenderer}
var ProcessNameRenderer = ColorConnected(CustomRenderer{RenderFunc: processes2Names, Renderer: ProcessRenderer})
// endpoints2Processes joins the endpoint topology to the process
// topology, matching on hostID and pid.