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

do not filter endpoints by procspied/ebpf in renderers #2652

Merged
merged 2 commits into from
Jun 28, 2017
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
24 changes: 12 additions & 12 deletions app/api_topologies.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,28 @@ func MakeRegistry() *Registry {
},
APITopologyDesc{
id: containersID,
renderer: render.ContainerWithImageNameRenderer,
renderer: render.FilterUnconnectedPseudo(render.ContainerWithImageNameRenderer),
Name: "Containers",
Rank: 2,
Options: containerFilters,
},
APITopologyDesc{
id: containersByHostnameID,
parent: containersID,
renderer: render.ContainerHostnameRenderer,
renderer: render.FilterUnconnectedPseudo(render.ContainerHostnameRenderer),
Name: "by DNS name",
Options: containerFilters,
},
APITopologyDesc{
id: containersByImageID,
parent: containersID,
renderer: render.ContainerImageRenderer,
renderer: render.FilterUnconnectedPseudo(render.ContainerImageRenderer),
Name: "by image",
Options: containerFilters,
},
APITopologyDesc{
id: podsID,
renderer: render.PodRenderer,
renderer: render.FilterUnconnectedPseudo(render.PodRenderer),
Name: "Pods",
Rank: 3,
Options: []APITopologyOptionGroup{unmanagedFilter},
Expand All @@ -257,30 +257,30 @@ func MakeRegistry() *Registry {
APITopologyDesc{
id: replicaSetsID,
parent: podsID,
renderer: render.ReplicaSetRenderer,
renderer: render.FilterUnconnectedPseudo(render.ReplicaSetRenderer),
Name: "replica sets",
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: kubeControllersID,
parent: podsID,
renderer: render.KubeControllerRenderer,
renderer: render.FilterUnconnectedPseudo(render.KubeControllerRenderer),
Name: "controllers",
Options: []APITopologyOptionGroup{unmanagedFilter, k8sControllersTypeFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: servicesID,
parent: podsID,
renderer: render.PodServiceRenderer,
renderer: render.FilterUnconnectedPseudo(render.PodServiceRenderer),
Name: "services",
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: ecsTasksID,
renderer: render.ECSTaskRenderer,
renderer: render.FilterUnconnectedPseudo(render.ECSTaskRenderer),
Name: "Tasks",
Rank: 3,
Options: []APITopologyOptionGroup{unmanagedFilter},
Expand All @@ -289,29 +289,29 @@ func MakeRegistry() *Registry {
APITopologyDesc{
id: ecsServicesID,
parent: ecsTasksID,
renderer: render.ECSServiceRenderer,
renderer: render.FilterUnconnectedPseudo(render.ECSServiceRenderer),
Name: "services",
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: swarmServicesID,
renderer: render.SwarmServiceRenderer,
renderer: render.FilterUnconnectedPseudo(render.SwarmServiceRenderer),
Name: "services",
Rank: 3,
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: hostsID,
renderer: render.HostRenderer,
renderer: render.FilterUnconnectedPseudo(render.HostRenderer),
Name: "Hosts",
Rank: 4,
},
APITopologyDesc{
id: weaveID,
parent: hostsID,
renderer: render.WeaveRenderer,
renderer: render.FilterUnconnectedPseudo(render.WeaveRenderer),
Name: "Weave Net",
},
)
Expand Down
19 changes: 8 additions & 11 deletions render/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@ var ContainerRenderer = MakeFilter(
),
)

var mapEndpoint2IP = MakeMap(
endpoint2IP,
// We drop endpoint nodes which were procspied, as they will be
// joined to containers through the process topology, and we don't
// want to double count edges.
MakeFilter(Complement(procspied), SelectEndpoint),
)
var mapEndpoint2IP = MakeMap(endpoint2IP, SelectEndpoint)

const originalNodeID = "original_node_id"
const originalNodeTopology = "original_node_topology"
Expand All @@ -74,13 +68,13 @@ func ConnectionJoin(r Renderer, toIPs func(report.Node) []string) Renderer {
return result
}

return FilterUnconnected(MakeMap(
return MakeMap(
ipToNode,
MakeReduce(
MakeMap(nodeToIP, r),
mapEndpoint2IP,
),
))
)
}

func ipToNode(n report.Node, _ report.Networks) report.Nodes {
Expand Down Expand Up @@ -121,8 +115,11 @@ func endpoint2IP(m report.Node, local report.Networks) report.Nodes {
return report.Nodes{}
}

if externalNode, ok := NewDerivedExternalNode(m, addr, local); ok {
return report.Nodes{externalNode.ID: externalNode}
// Nodes without a hostid may be pseudo nodes
if _, ok := m.Latest.Lookup(report.HostNodeID); !ok {
if externalNode, ok := NewDerivedExternalNode(m, addr, local); ok {
return report.Nodes{externalNode.ID: externalNode}
}
}

// We also allow for joining on ip:port pairs. This is useful for
Expand Down
37 changes: 16 additions & 21 deletions render/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/weaveworks/common/mtime"
"github.com/weaveworks/scope/probe/docker"
"github.com/weaveworks/scope/probe/endpoint"
"github.com/weaveworks/scope/probe/kubernetes"
"github.com/weaveworks/scope/report"
)
Expand Down Expand Up @@ -216,7 +215,7 @@ func Complement(f FilterFunc) FilterFunc {
// FilterUnconnected produces a renderer that filters unconnected nodes
// from the given renderer
func FilterUnconnected(r Renderer) Renderer {
return MakeFilter(
return MakeFilterPseudo(
func(node report.Node) bool {
_, ok := node.Latest.Lookup(IsConnected)
return ok
Expand All @@ -225,6 +224,21 @@ func FilterUnconnected(r Renderer) Renderer {
)
}

// FilterUnconnectedPseudo produces a renderer that filters
// unconnected pseudo nodes from the given renderer
func FilterUnconnectedPseudo(r Renderer) Renderer {
return MakeFilterPseudo(
func(node report.Node) bool {
if !IsPseudoTopology(node) {
return true
}
_, ok := node.Latest.Lookup(IsConnected)
return ok
},
ColorConnected(r),
)
}

// Noop allows all nodes through
func Noop(_ report.Node) bool { return true }

Expand All @@ -237,25 +251,6 @@ func IsRunning(n report.Node) bool {
// IsStopped checks if the node is *not* a running docker container
var IsStopped = Complement(IsRunning)

func procspied(node report.Node) bool {
_, ok := node.Latest.Lookup(endpoint.Procspied)
return ok
}

func procspiedOrEBPF(node report.Node) bool {
if procspied(node) {
return true
}
_, ok := node.Latest.Lookup(endpoint.EBPF)
return ok
}

// FilterProcspiedOrEBPF keeps only endpoints which were found via
// procspy or eBPF.
func FilterProcspiedOrEBPF(r Renderer) Renderer {
return MakeFilter(procspiedOrEBPF, r)
}

// IsApplication checks if the node is an "application" node
func IsApplication(n report.Node) bool {
containerName, _ := n.Latest.Lookup(docker.ContainerName)
Expand Down
2 changes: 1 addition & 1 deletion render/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func renderProcesses(rpt report.Report) bool {
}

// EndpointRenderer is a Renderer which produces a renderable endpoint graph.
var EndpointRenderer = FilterProcspiedOrEBPF(SelectEndpoint)
var EndpointRenderer = SelectEndpoint

This comment was marked as abuse.

This comment was marked as abuse.


// ProcessRenderer is a Renderer which produces a renderable process
// graph by merging the endpoint graph and the process topology.
Expand Down