Skip to content

Commit

Permalink
Merge pull request #2348 from weaveworks/mike/revert-k8s-filters
Browse files Browse the repository at this point in the history
Revert "Merge pull request #2285 from weaveworks/mike/k8s-ns-in-container-view"
  • Loading branch information
ekimekim authored Mar 17, 2017
2 parents d5b97f9 + d55c528 commit 286fe6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
24 changes: 9 additions & 15 deletions app/api_topologies.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,21 @@ func updateFilters(rpt report.Report, topologies []APITopologyDesc) []APITopolog
ns = append(ns, namespace)
}
sort.Strings(ns)
if len(ns) > 0 { // We only want to apply k8s filters when we have k8s-related nodes
for i, t := range topologies {
if t.id == containersID || t.id == containersByImageID || t.id == containersByHostnameID || t.id == podsID || t.id == servicesID || t.id == deploymentsID || t.id == replicaSetsID {
topologies[i] = mergeTopologyFilters(t, []APITopologyOptionGroup{
kubernetesFilters(ns...),
})
}
for i, t := range topologies {
if t.id == podsID || t.id == servicesID || t.id == deploymentsID || t.id == replicaSetsID {
topologies[i] = updateTopologyFilters(t, []APITopologyOptionGroup{
kubernetesFilters(ns...), unmanagedFilter,
})
}
}
return topologies
}

// mergeTopologyFilters recursively merges in new options on a topology description
func mergeTopologyFilters(t APITopologyDesc, options []APITopologyOptionGroup) APITopologyDesc {
t.Options = append(t.Options, options...)
// updateTopologyFilters recursively sets the options on a topology description
func updateTopologyFilters(t APITopologyDesc, options []APITopologyOptionGroup) APITopologyDesc {
t.Options = options
for i, sub := range t.SubTopologies {
t.SubTopologies[i] = mergeTopologyFilters(sub, options)
t.SubTopologies[i] = updateTopologyFilters(sub, options)
}
return t
}
Expand Down Expand Up @@ -202,31 +200,27 @@ func MakeRegistry() *Registry {
renderer: render.PodRenderer,
Name: "Pods",
Rank: 3,
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: replicaSetsID,
parent: podsID,
renderer: render.ReplicaSetRenderer,
Name: "replica sets",
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: deploymentsID,
parent: podsID,
renderer: render.DeploymentRenderer,
Name: "deployments",
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
id: servicesID,
parent: podsID,
renderer: render.PodServiceRenderer,
Name: "services",
Options: []APITopologyOptionGroup{unmanagedFilter},
HideIfEmpty: true,
},
APITopologyDesc{
Expand Down
15 changes: 2 additions & 13 deletions render/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
"github.com/weaveworks/scope/report"
)

const (
k8sNamespaceLabel = "io.kubernetes.pod.namespace"
)

// PreciousNodeRenderer ensures a node is never filtered out by decorators
type PreciousNodeRenderer struct {
PreciousNodeID string
Expand Down Expand Up @@ -285,7 +281,7 @@ func IsApplication(n report.Node) bool {
if roleLabel == "system" {
return false
}
namespace, _ := n.Latest.Lookup(docker.LabelPrefix + k8sNamespaceLabel)
namespace, _ := n.Latest.Lookup(docker.LabelPrefix + "io.kubernetes.pod.namespace")
if namespace == "kube-system" {
return false
}
Expand Down Expand Up @@ -324,14 +320,7 @@ func IsNotPseudo(n report.Node) bool {
// IsNamespace checks if the node is a pod/service in the specified namespace
func IsNamespace(namespace string) FilterFunc {
return func(n report.Node) bool {
tryKeys := []string{kubernetes.Namespace, docker.LabelPrefix + k8sNamespaceLabel}
gotNamespace := ""
for _, key := range tryKeys {
if value, ok := n.Latest.Lookup(key); ok {
gotNamespace = value
break
}
}
gotNamespace, _ := n.Latest.Lookup(kubernetes.Namespace)
return namespace == gotNamespace
}
}
Expand Down

0 comments on commit 286fe6b

Please sign in to comment.