Skip to content

Commit

Permalink
Merge pull request #1350 from weaveworks/1246-k8s-unmanaged
Browse files Browse the repository at this point in the history
Add a 'Unmanaged' node to k8s views which included non-k8s containers.
  • Loading branch information
paulbellamy committed Apr 20, 2016
2 parents c9b12db + 6db171b commit 8f3402f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
9 changes: 9 additions & 0 deletions render/detailed/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ func pseudoNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
return base, true
}

// try rendering it as an unmanaged node
if strings.HasPrefix(n.ID, render.MakePseudoNodeID(render.UnmanagedID)) {
base.Label = render.UnmanagedMajor
base.Shape = Square
base.Stack = true
base.LabelMinor = report.ExtractHostID(n)
return base, true
}

// try rendering it as an endpoint
if addr, ok := n.Latest.Lookup(endpoint.Addr); ok {
base.Label = addr
Expand Down
11 changes: 9 additions & 2 deletions render/expected/expected.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ var (
render.OutgoingInternetID: theOutgoingInternetNode,
}

unmanagedServerID = render.MakePseudoNodeID(render.UnmanagedID, fixture.ServerHostID)
unmanagedServerNode = pseudo(unmanagedServerID, render.OutgoingInternetID).WithChildren(report.MakeNodeSet(
uncontainedServerNode,
RenderedEndpoints[fixture.NonContainerNodeID],
RenderedProcesses[fixture.NonContainerProcessNodeID],
))

RenderedPods = report.Nodes{
fixture.ClientPodNodeID: pod(fixture.ClientPodNodeID, fixture.ServerPodNodeID).
WithChildren(report.MakeNodeSet(
Expand All @@ -252,7 +259,7 @@ var (
RenderedContainers[fixture.ServerContainerNodeID],
)),

uncontainedServerID: uncontainedServerNode,
unmanagedServerID: unmanagedServerNode,
render.IncomingInternetID: theIncomingInternetNode(fixture.ServerPodNodeID),
render.OutgoingInternetID: theOutgoingInternetNode,
}
Expand All @@ -272,7 +279,7 @@ var (
RenderedPods[fixture.ServerPodNodeID],
)),

uncontainedServerID: uncontainedServerNode,
unmanagedServerID: unmanagedServerNode,
render.IncomingInternetID: theIncomingInternetNode(fixture.ServiceNodeID),
render.OutgoingInternetID: theOutgoingInternetNode,
}
Expand Down
18 changes: 16 additions & 2 deletions render/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const (
UncontainedID = "uncontained"
UncontainedMajor = "Uncontained"

UnmanagedID = "unmanaged"
UnmanagedMajor = "Unmanaged"

TheInternetID = "theinternet"
IncomingInternetID = "in-" + TheInternetID
OutgoingInternetID = "out-" + TheInternetID
Expand Down Expand Up @@ -364,6 +367,13 @@ func MapEndpoint2Host(n report.Node, local report.Networks) report.Nodes {
// 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 MapContainer2Pod(n report.Node, _ report.Networks) report.Nodes {
// Uncontainerd becomes unmanaged in the pods view
if strings.HasPrefix(n.ID, MakePseudoNodeID(UncontainedID)) {
id := MakePseudoNodeID(UnmanagedID, report.ExtractHostID(n))
node := NewDerivedPseudoNode(id, n)
return report.Nodes{id: node}
}

// Propagate all pseudo nodes
if n.Topology == Pseudo {
return report.Nodes{n.ID: n}
Expand All @@ -373,11 +383,15 @@ func MapContainer2Pod(n report.Node, _ report.Networks) report.Nodes {
// slightly out of sync reports, or its not in a pod), just drop it
namespace, ok := n.Latest.Lookup(kubernetes.Namespace)
if !ok {
return report.Nodes{}
id := MakePseudoNodeID(UnmanagedID, report.ExtractHostID(n))
node := NewDerivedPseudoNode(id, n)
return report.Nodes{id: node}
}
podID, ok := n.Latest.Lookup(kubernetes.PodID)
if !ok {
return report.Nodes{}
id := MakePseudoNodeID(UnmanagedID, report.ExtractHostID(n))
node := NewDerivedPseudoNode(id, n)
return report.Nodes{id: node}
}
podName := strings.TrimPrefix(podID, namespace+"/")
id := report.MakePodNodeID(namespace, podName)
Expand Down

0 comments on commit 8f3402f

Please sign in to comment.