From 1afa476b8a87d918036c86092c55842a5eae1664 Mon Sep 17 00:00:00 2001 From: Yao Zengzeng Date: Sat, 26 Oct 2019 10:06:00 +0800 Subject: [PATCH] minor fix for making map (#6076) Signed-off-by: YaoZengzeng --- discovery/kubernetes/ingress.go | 3 ++- discovery/kubernetes/node.go | 3 ++- discovery/kubernetes/service.go | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/discovery/kubernetes/ingress.go b/discovery/kubernetes/ingress.go index 1feffa68f9..10c729ede6 100644 --- a/discovery/kubernetes/ingress.go +++ b/discovery/kubernetes/ingress.go @@ -144,7 +144,8 @@ const ( ) func ingressLabels(ingress *v1beta1.Ingress) model.LabelSet { - ls := make(model.LabelSet, len(ingress.Labels)+len(ingress.Annotations)+2) + // Each label and annotation will create two key-value pairs in the map. + ls := make(model.LabelSet, 2*(len(ingress.Labels)+len(ingress.Annotations))+2) ls[ingressNameLabel] = lv(ingress.Name) ls[namespaceLabel] = lv(ingress.Namespace) diff --git a/discovery/kubernetes/node.go b/discovery/kubernetes/node.go index 677cb74b0c..08c933b389 100644 --- a/discovery/kubernetes/node.go +++ b/discovery/kubernetes/node.go @@ -151,7 +151,8 @@ const ( ) func nodeLabels(n *apiv1.Node) model.LabelSet { - ls := make(model.LabelSet, len(n.Labels)+len(n.Annotations)+1) + // Each label and annotation will create two key-value pairs in the map. + ls := make(model.LabelSet, 2*(len(n.Labels)+len(n.Annotations))+1) ls[nodeNameLabel] = lv(n.Name) diff --git a/discovery/kubernetes/service.go b/discovery/kubernetes/service.go index 858ef36bd3..ca01a5b38c 100644 --- a/discovery/kubernetes/service.go +++ b/discovery/kubernetes/service.go @@ -149,7 +149,8 @@ const ( ) func serviceLabels(svc *apiv1.Service) model.LabelSet { - ls := make(model.LabelSet, len(svc.Labels)+len(svc.Annotations)+2) + // Each label and annotation will create two key-value pairs in the map. + ls := make(model.LabelSet, 2*(len(svc.Labels)+len(svc.Annotations))+2) ls[serviceNameLabel] = lv(svc.Name) ls[namespaceLabel] = lv(svc.Namespace)