mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 17:50:39 +00:00
The existing technique of "reducing" the two rendered graphs for daemonsets and deployments had a glaring issue that no connections would ever be made between nodes of different types, since that information would've been discarded earlier in the process. It also makes it hard to identify "parentless" pods. This commit extends the Map2Parent function, teaching it: * To check multiple topologies for parents * To pass through nodes with no parents found without modification Since we already had two 'modes' for what to do with nodes without parents, and it would've been clunky to try to encode the third option into the existing PseudoNodeID arg in some way, we instead split it into two args, with the first being an enum specifying either the old pseudo node behaviour, the old drop behaviour, or the new keep behaviour. We then use the new Map2Parent to map pods to: * A replica set, if it has one * A daemonset, if it has one * Itself, if neither of the above and then map again from the results to any deployment, leaving as-is any nodes that don't map to a deployment. Hence we are left with: * Deployments * Daemonsets * Replica sets, but only if they map to no deployment * Pods, but only if they map to none of the above and connections between all these will be calculated correctly.
41 lines
902 B
Go
41 lines
902 B
Go
package render
|
|
|
|
import (
|
|
"github.com/weaveworks/scope/report"
|
|
)
|
|
|
|
// ECSTaskRenderer is a Renderer for Amazon ECS tasks.
|
|
var ECSTaskRenderer = ConditionalRenderer(renderECSTopologies,
|
|
MakeMap(
|
|
PropagateSingleMetrics(report.Container),
|
|
MakeReduce(
|
|
MakeMap(
|
|
Map2Parent([]string{report.ECSTask}, NoParentsPseudo, UnmanagedID, nil),
|
|
MakeFilter(
|
|
IsRunning,
|
|
ContainerWithImageNameRenderer,
|
|
),
|
|
),
|
|
SelectECSTask,
|
|
),
|
|
),
|
|
)
|
|
|
|
// ECSServiceRenderer is a Renderer for Amazon ECS services.
|
|
var ECSServiceRenderer = ConditionalRenderer(renderECSTopologies,
|
|
MakeMap(
|
|
PropagateSingleMetrics(report.ECSTask),
|
|
MakeReduce(
|
|
MakeMap(
|
|
Map2Parent([]string{report.ECSService}, NoParentsDrop, "", nil),
|
|
ECSTaskRenderer,
|
|
),
|
|
SelectECSService,
|
|
),
|
|
),
|
|
)
|
|
|
|
func renderECSTopologies(rpt report.Report) bool {
|
|
return len(rpt.ECSTask.Nodes)+len(rpt.ECSService.Nodes) >= 1
|
|
}
|