Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit per-host Uncontained pseudo nodes. #264

Merged
merged 1 commit into from
Jun 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions render/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,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
}

Expand All @@ -180,11 +179,22 @@ 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. If for whatever reason
// this node doesn't have a host id in their nodemetadata, it'll
// all get grouped into a single uncontained node.
id, ok := n.NodeMetadata[docker.ContainerID]
if !ok || n.Pseudo {
return newDerivedPseudoNode(UncontainedID, UncontainedMajor, n), true
if !ok {
hostID := report.ExtractHostID(n.NodeMetadata)

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

id = fmt.Sprintf("%s:%s", UncontainedID, hostID)

This comment was marked as abuse.

node := newDerivedPseudoNode(id, UncontainedMajor, n)
node.LabelMinor = hostID
return node, true
}

return newDerivedNode(id, n), true
Expand All @@ -203,7 +213,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
}

Expand All @@ -225,16 +234,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.ImageID]
if !ok || n.Pseudo {
return newDerivedPseudoNode(UncontainedID, UncontainedMajor, n), true
if !ok {
return n, false
}

return newDerivedNode(id, n), true
Expand Down
16 changes: 8 additions & 8 deletions render/topologies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,17 +412,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),

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

LabelMajor: render.UncontainedMajor,
LabelMinor: "",
LabelMinor: serverHostName,
Rank: "",
Pseudo: true,
Origins: report.MakeIDList(nonContainerProcessNodeID, serverHostNodeID),
Expand Down Expand Up @@ -458,17 +458,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),

This comment was marked as abuse.

LabelMajor: render.UncontainedMajor,
LabelMinor: "",
LabelMinor: serverHostName,
Rank: "",
Pseudo: true,
Origins: report.MakeIDList(nonContainerProcessNodeID, serverHostNodeID),
Expand Down