From dd2e666a8d6b42426822b3eff667d252983875f8 Mon Sep 17 00:00:00 2001 From: akatsadimas Date: Thu, 7 Oct 2021 00:01:46 +0300 Subject: [PATCH 1/2] discovery/kubernetes: Warn user in case of endpoint over-capacity Signed-off-by: akatsadimas --- discovery/kubernetes/endpointslice.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/discovery/kubernetes/endpointslice.go b/discovery/kubernetes/endpointslice.go index 71d4e3776..4c5db2df2 100644 --- a/discovery/kubernetes/endpointslice.go +++ b/discovery/kubernetes/endpointslice.go @@ -322,6 +322,14 @@ func (e *EndpointSlice) buildEndpointSlice(eps *disv1beta1.EndpointSlice) *targe } } + v := eps.Labels[apiv1.EndpointsOverCapacity] + if v == "truncated" { + level.Warn(e.logger).Log("msg", "Number of endpoints in one Endpoints object truncated to 1000", "endpoint", eps.Name) + } + if v == "warning" { + level.Warn(e.logger).Log("msg", "Number of endpoints in one Endpoints object exceeds 1000", "endpoint", eps.Name) + } + // For all seen pods, check all container ports. If they were not covered // by one of the service endpoints, generate targets for them. for _, pe := range seenPods { From ee77a6212f22646445a4e9312734a5db713c9e72 Mon Sep 17 00:00:00 2001 From: akatsadimas Date: Fri, 8 Oct 2021 23:17:04 +0300 Subject: [PATCH 2/2] discovery/kubernetes: issue overcapacity warning for endpoint rather than endpointslice Signed-off-by: akatsadimas --- discovery/kubernetes/endpoints.go | 8 ++++++++ discovery/kubernetes/endpointslice.go | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/discovery/kubernetes/endpoints.go b/discovery/kubernetes/endpoints.go index 8fc158dd4..49e515a14 100644 --- a/discovery/kubernetes/endpoints.go +++ b/discovery/kubernetes/endpoints.go @@ -308,6 +308,14 @@ func (e *Endpoints) buildEndpoints(eps *apiv1.Endpoints) *targetgroup.Group { } } + v := eps.Labels[apiv1.EndpointsOverCapacity] + if v == "truncated" { + level.Warn(e.logger).Log("msg", "Number of endpoints in one Endpoints object exceeds 1000 and has been truncated, please use \"role: endpointslice\" instead", "endpoint", eps.Name) + } + if v == "warning" { + level.Warn(e.logger).Log("msg", "Number of endpoints in one Endpoints object exceeds 1000, please use \"role: endpointslice\" instead", "endpoint", eps.Name) + } + // For all seen pods, check all container ports. If they were not covered // by one of the service endpoints, generate targets for them. for _, pe := range seenPods { diff --git a/discovery/kubernetes/endpointslice.go b/discovery/kubernetes/endpointslice.go index 4c5db2df2..71d4e3776 100644 --- a/discovery/kubernetes/endpointslice.go +++ b/discovery/kubernetes/endpointslice.go @@ -322,14 +322,6 @@ func (e *EndpointSlice) buildEndpointSlice(eps *disv1beta1.EndpointSlice) *targe } } - v := eps.Labels[apiv1.EndpointsOverCapacity] - if v == "truncated" { - level.Warn(e.logger).Log("msg", "Number of endpoints in one Endpoints object truncated to 1000", "endpoint", eps.Name) - } - if v == "warning" { - level.Warn(e.logger).Log("msg", "Number of endpoints in one Endpoints object exceeds 1000", "endpoint", eps.Name) - } - // For all seen pods, check all container ports. If they were not covered // by one of the service endpoints, generate targets for them. for _, pe := range seenPods {