Skip to content

Commit

Permalink
render/pod: Remove redundant deployment mapping
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ekimekim committed Jul 3, 2017
1 parent c5b2c9d commit b7e24e8
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions render/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b7e24e8

Please sign in to comment.