From b7e24e82b51cf053a0fea8b0c816395b2ce3c519 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Mon, 3 Jul 2017 11:49:31 -0700 Subject: [PATCH] render/pod: Remove redundant deployment mapping This map function isn't actually needed. Children are only populated from mapping to parents during rendering, so there's no pre-existing replicasets to map. Simply having the Map2Parent function map pods to deployments has it do the right thing. --- render/pod.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/render/pod.go b/render/pod.go index 5f4994c9a6..b52e04b09a 100644 --- a/render/pod.go +++ b/render/pod.go @@ -79,7 +79,7 @@ var PodServiceRenderer = ConditionalRenderer(renderKubernetesTopologies, var KubeControllerRenderer = ConditionalRenderer(renderKubernetesTopologies, renderParents( report.Pod, []string{report.Deployment, report.DaemonSet}, - NoParentsPseudo, UnmanagedID, makePodsChildren, + NoParentsPseudo, UnmanagedID, nil, PodRenderer, ), ) @@ -135,26 +135,6 @@ func (s selectPodsWithDeployments) Stats(rpt report.Report, _ Decorator) Stats { return Stats{} } -// When mapping from pods to deployments, complete the two-way relation by making the -// mapped-from pod a child of the mapped-to deployment, and remove any replica set children. -// This is needed because pods were originally mapped to deployments via an intermediate replica set -// which we need to remove. -func makePodsChildren(parent, original report.Node) report.Node { - children := parent.Children - // Gather all the replica sets... - replicaSetIDs := []string{} - children.ForEach(func(n report.Node) { - if n.Topology == report.ReplicaSet { - replicaSetIDs = append(replicaSetIDs, n.ID) - } - }) - // ...and delete them. - children = children.Delete(replicaSetIDs...) - // Then add in the mapped-from pod. - children = children.Add(original) - return parent.WithChildren(children) -} - // MapPod2IP maps pod nodes to their IP address. This allows pods to // be joined directly with the endpoint topology. func MapPod2IP(m report.Node) []string {