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 GitHub
parent 814455138a
commit 48c8c5093b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,6 +99,11 @@ func addServicesLabels(services []service, networksLabels map[string]map[string]
commonLabels["__meta_dockerswarm_service_label_"+discoveryutils.SanitizeLabelName(k)] = v
}
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)
if err != nil {
logger.Errorf("cannot parse: %q as cidr for service label add, err: %v", vip.Addr, err)