fix: filter pod by service name

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-09-29 15:23:51 +08:00
parent d2b1bf4ba0
commit fcd8d8ee1c

View File

@@ -140,7 +140,7 @@ func podBelongToService(item *v1.Pod, serviceName string) bool {
}
selector := labels.Set(service.Spec.Selector).AsSelectorPreValidated()
if !selector.Matches(labels.Set(item.Labels)) {
if selector.Empty() || !selector.Matches(labels.Set(item.Labels)) {
return false
}
return true