Skip to content

Commit b924ea7

Browse files
hdurand0710oktalz
authored andcommitted
BUG/MEDIUM: fix constant reloads due to Prometheus
This fixes 2 issues: - constant reloads (each time there is an update is the k8s cluster) to Prometheus when the Ingress Controller is started with a --namespace-whitelist option and the namespace where the controller is running is not part of the white listed namespaces. In this situation, the prometheus backend was never created but we kept trying to create it - do not try to create the Prometheus backend if the flag --prometheus is not set
1 parent ebf1bbd commit b924ea7

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.aspell.yml

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ allowed:
3838
- optim
3939
- prometheus
4040
- configmaps
41+
- namespace
42+
- namespaces

pkg/controller/controller.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,14 @@ func (c *HAProxyController) updateHAProxy() {
151151
}
152152

153153
for _, namespace := range c.store.Namespaces {
154-
if !namespace.Relevant {
155-
continue
156-
}
157154
c.store.SecretsProcessed = map[string]struct{}{}
158155
for _, ingResource := range namespace.Ingresses {
156+
if !namespace.Relevant && !ingResource.Faked {
157+
// As we watch only for white-listed namespaces, we should not worry about iterating over
158+
// many ingresses in irrelevant namespaces.
159+
// There should only be fake ingresses in irrelevant namespaces so loop should be whithin small amount of ingresses (Prometheus)
160+
continue
161+
}
159162
i := ingress.New(ingResource, c.osArgs.IngressClass, c.osArgs.EmptyIngressClass, c.annotations)
160163
if !i.Supported(c.store, c.annotations) {
161164
logger.Debugf("ingress '%s/%s' ignored: no matching", ingResource.Namespace, ingResource.Name)

pkg/controller/handler.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ func (c *HAProxyController) initHandlers() {
5757

5858
defer func() { c.updateHandlers = append(c.updateHandlers, handler.Refresh{}) }()
5959

60-
c.beforeUpdateHandlers = []UpdateHandler{
61-
handler.PrometheusEndpoint{
62-
EventChan: c.eventChan,
63-
PodNs: c.podNamespace,
64-
},
60+
if c.osArgs.PrometheusEnabled {
61+
c.beforeUpdateHandlers = []UpdateHandler{
62+
handler.PrometheusEndpoint{
63+
EventChan: c.eventChan,
64+
PodNs: c.podNamespace,
65+
},
66+
}
6567
}
6668
// Need to be before Refresh. If after, maps are refreshed without pprof content
6769
if c.osArgs.PprofEnabled {

0 commit comments

Comments
 (0)