diff --git a/render/mapping.go b/render/mapping.go index dd38d17040..34b9f957c2 100644 --- a/render/mapping.go +++ b/render/mapping.go @@ -154,7 +154,6 @@ func MapEndpoint2Process(n RenderableNode) (RenderableNode, bool) { pid, ok := n.NodeMetadata["pid"] if !ok { - // TODO: Propogate a pseudo node instead of dropping this? return RenderableNode{}, false } @@ -179,11 +178,20 @@ func MapProcess2Container(n RenderableNode) (RenderableNode, bool) { return n, true } + // Don't propogate non-internet pseudo nodes + if n.Pseudo { + return n, false + } + // Otherwise, if the process is not in a container, group it - // into an "Uncontained" node + // into an per-host "Uncontained" node id, ok := n.NodeMetadata["docker_container_id"] - if !ok || n.Pseudo { - return newDerivedPseudoNode(UncontainedID, UncontainedMajor, n), true + if !ok { + hostID := report.ExtractHostID(n.NodeMetadata) + id = fmt.Sprintf("%s:%s", UncontainedID, hostID) + node := newDerivedPseudoNode(id, UncontainedMajor, n) + node.LabelMinor = hostID + return node, true } return newDerivedNode(id, n), true @@ -202,7 +210,6 @@ func MapProcess2Name(n RenderableNode) (RenderableNode, bool) { name, ok := n.NodeMetadata["comm"] if !ok { - // TODO: Propogate a pseudo node instead of dropping this? return RenderableNode{}, false } @@ -224,16 +231,16 @@ func MapProcess2Name(n RenderableNode) (RenderableNode, bool) { // It does not have enough info to do that, and the resulting graph // must be merged with a container graph to get that info. func MapContainer2ContainerImage(n RenderableNode) (RenderableNode, bool) { - // Propogate the internet pseudo node - if n.ID == TheInternetID { + // Propogate all pseudo nodes + if n.Pseudo { return n, true } - // Otherwise, if the process is not in a container, group it - // into an "Uncontained" node + // Otherwise, if some some reason the container doesn't have a image_id + // (maybe slightly out of sync reports), just drop it id, ok := n.NodeMetadata["docker_image_id"] - if !ok || n.Pseudo { - return newDerivedPseudoNode(UncontainedID, UncontainedMajor, n), true + if !ok { + return n, false } return newDerivedNode(id, n), true diff --git a/render/topologies_test.go b/render/topologies_test.go index 920b409d12..a83be7e499 100644 --- a/render/topologies_test.go +++ b/render/topologies_test.go @@ -411,17 +411,17 @@ func TestContainerRenderer(t *testing.T) { LabelMinor: serverHostName, Rank: serverContainerImageID, Pseudo: false, - Adjacency: report.MakeIDList(clientContainerID, render.UncontainedID, render.TheInternetID), + Adjacency: report.MakeIDList(clientContainerID, render.TheInternetID), Origins: report.MakeIDList(serverContainerNodeID, server80NodeID, serverProcessNodeID, serverHostNodeID), AggregateMetadata: render.AggregateMetadata{ render.KeyBytesIngress: 150, render.KeyBytesEgress: 1500, }, }, - render.UncontainedID: { - ID: render.UncontainedID, + fmt.Sprintf("%s:%s", render.UncontainedID, serverHostName): { + ID: fmt.Sprintf("%s:%s", render.UncontainedID, serverHostName), LabelMajor: render.UncontainedMajor, - LabelMinor: "", + LabelMinor: serverHostName, Rank: "", Pseudo: true, Origins: report.MakeIDList(nonContainerProcessNodeID, serverHostNodeID), @@ -457,17 +457,17 @@ func TestContainerImageRenderer(t *testing.T) { LabelMinor: "", Rank: serverContainerImageID, Pseudo: false, - Adjacency: report.MakeIDList(clientContainerImageID, render.UncontainedID, render.TheInternetID), + Adjacency: report.MakeIDList(clientContainerImageID, render.TheInternetID), Origins: report.MakeIDList(serverContainerImageNodeID, serverContainerNodeID, server80NodeID, serverProcessNodeID, serverHostNodeID), AggregateMetadata: render.AggregateMetadata{ render.KeyBytesIngress: 150, render.KeyBytesEgress: 1500, }, }, - render.UncontainedID: { - ID: render.UncontainedID, + fmt.Sprintf("%s:%s", render.UncontainedID, serverHostName): { + ID: fmt.Sprintf("%s:%s", render.UncontainedID, serverHostName), LabelMajor: render.UncontainedMajor, - LabelMinor: "", + LabelMinor: serverHostName, Rank: "", Pseudo: true, Origins: report.MakeIDList(nonContainerProcessNodeID, serverHostNodeID),