Skip to content

Commit

Permalink
Merge pull request #1832 from weaveworks/1824-wrong-pod-parents
Browse files Browse the repository at this point in the history
Only consider pod parents living in the same namespace
  • Loading branch information
Alfonso Acosta authored Aug 26, 2016
2 parents af48c7f + 8a7812e commit 7c2e3c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions probe/kubernetes/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (r *Reporter) replicaSetTopology(probeID string, deployments []Deployment)

for _, deployment := range deployments {
selectors = append(selectors, match(
deployment.Namespace(),
deployment.Selector(),
report.Deployment,
report.MakeDeploymentNodeID(deployment.UID()),
Expand Down Expand Up @@ -337,12 +338,13 @@ var GetNodeName = func(r *Reporter) (string, error) {
type labelledChild interface {
Labels() map[string]string
AddParent(string, string)
Namespace() string
}

// Match parses the selectors and adds the target as a parent if the selector matches.
func match(selector labels.Selector, topology, id string) func(labelledChild) {
func match(namespace string, selector labels.Selector, topology, id string) func(labelledChild) {
return func(c labelledChild) {
if selector.Matches(labels.Set(c.Labels())) {
if namespace == c.Namespace() && selector.Matches(labels.Set(c.Labels())) {
c.AddParent(topology, id)
}
}
Expand Down Expand Up @@ -370,13 +372,15 @@ func (r *Reporter) podTopology(services []Service, replicaSets []ReplicaSet) (re
})
for _, service := range services {
selectors = append(selectors, match(
service.Namespace(),
service.Selector(),
report.Service,
report.MakeServiceNodeID(service.UID()),
))
}
for _, replicaSet := range replicaSets {
selectors = append(selectors, match(
replicaSet.Namespace(),
replicaSet.Selector(),
report.ReplicaSet,
report.MakeReplicaSetNodeID(replicaSet.UID()),
Expand Down

0 comments on commit 7c2e3c8

Please sign in to comment.