fixes dockerswarm (#1053)

fixes improper usage of host network services
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1028
This commit is contained in:
Nikolay 2021-02-04 16:56:42 +03:00 committed by Aliaksandr Valialkin
parent 2aa37b0450
commit 6fc2a8e544

View file

@ -99,6 +99,11 @@ func addServicesLabels(services []service, networksLabels map[string]map[string]
commonLabels["__meta_dockerswarm_service_label_"+discoveryutils.SanitizeLabelName(k)] = v commonLabels["__meta_dockerswarm_service_label_"+discoveryutils.SanitizeLabelName(k)] = v
} }
for _, vip := range service.Endpoint.VirtualIPs { for _, vip := range service.Endpoint.VirtualIPs {
// skip services without virtual address.
// usually its host services.
if vip.Addr == "" {
continue
}
ip, _, err := net.ParseCIDR(vip.Addr) ip, _, err := net.ParseCIDR(vip.Addr)
if err != nil { if err != nil {
logger.Errorf("cannot parse: %q as cidr for service label add, err: %v", vip.Addr, err) logger.Errorf("cannot parse: %q as cidr for service label add, err: %v", vip.Addr, err)