Stop tagging pods with host ID

So they can be reported centrally, find the pod host ID from the child
containers.
This commit is contained in:
Bryan Boreham
2018-10-11 17:54:29 +00:00
parent 98d52bd480
commit 1279a02b7d
2 changed files with 30 additions and 9 deletions
+28 -8
View File
@@ -53,14 +53,16 @@ var PodRenderer = Memoise(ConditionalRenderer(renderKubernetesTopologies,
},
MakeReduce(
PropagateSingleMetrics(report.Container,
Map2Parent{topologies: []string{report.Pod}, noParentsPseudoID: UnmanagedID,
chainRenderer: MakeFilter(
ComposeFilterFuncs(
IsRunning,
Complement(isPauseContainer),
),
ContainerWithImageNameRenderer,
)},
MakeMap(propagateHostID,
Map2Parent{topologies: []string{report.Pod}, noParentsPseudoID: UnmanagedID,
chainRenderer: MakeFilter(
ComposeFilterFuncs(
IsRunning,
Complement(isPauseContainer),
),
ContainerWithImageNameRenderer,
)},
),
),
ConnectionJoin(MapPod2IP, report.Pod),
KubernetesVolumesRenderer,
@@ -68,6 +70,24 @@ var PodRenderer = Memoise(ConditionalRenderer(renderKubernetesTopologies,
),
))
// Pods are not tagged with a Host ID, but their container children are.
// If n doesn't already have a host ID, copy it from one of the children
func propagateHostID(n report.Node) report.Node {
if _, found := n.Latest.Lookup(report.HostNodeID); found {
return n
}
var first *report.Node
n.Children.ForEach(func(child report.Node) {
if first == nil {
first = &child
}
})
if first != nil {
n.Latest = n.Latest.Propagate(first.Latest, report.HostNodeID)
}
return n
}
// PodServiceRenderer is a Renderer which produces a renderable kubernetes services
// graph by merging the pods graph and the services topology.
//