Skip to content

Commit d9187d2

Browse files
ivanmatmatioktalz
authored andcommitted
MINOR: remove any config snippet from pprof backend
1 parent 3ff14e4 commit d9187d2

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

pkg/annotations/cfgSnippetHandler.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type ConfigSnippetHandler struct{}
1313

1414
func (h ConfigSnippetHandler) Update(k store.K8s, api haproxy.HAProxy, ann Annotations) (reload bool, err error) {
1515
// We get the configmap configsnippet value
16-
configmapCfgSnippetValue, errConfigmapCfgSnippet := getConfigmapConfigSnippet(api)
16+
configmapCfgSnippetValue, errConfigmapCfgSnippet := getConfigmapConfigSnippet(k.BackendsWithNoConfigSnippets, api)
1717
if errConfigmapCfgSnippet != nil {
1818
return false, errConfigmapCfgSnippet
1919
}
@@ -22,7 +22,7 @@ func (h ConfigSnippetHandler) Update(k store.K8s, api haproxy.HAProxy, ann Annot
2222
return
2323
}
2424

25-
func getConfigmapConfigSnippet(api api.HAProxyClient) (configmapCfgSnippetValue []string, err error) {
25+
func getConfigmapConfigSnippet(backendsWithNoConfigSnippets map[string]struct{}, api api.HAProxyClient) (configmapCfgSnippetValue []string, err error) {
2626
// configmap config snippet if any.
2727
configmapCfgSnippetValue = []string{}
2828
// configmap config snippet will be hold in special backend 'configmap' with origin 'configmap'
@@ -34,6 +34,9 @@ func getConfigmapConfigSnippet(api api.HAProxyClient) (configmapCfgSnippetValue
3434
// to replicate everywhere the configmap insertion.
3535
if backends, errGet := api.BackendsGet(); errGet == nil {
3636
for _, backend := range backends {
37+
if _, ok := backendsWithNoConfigSnippets[backend.Name]; ok {
38+
continue
39+
}
3740
if _, ok := cfgSnippet.backends[backend.Name]; !ok {
3841
cfgSnippet.backends[backend.Name] = map[string]*cfgData{
3942
"configmap-insertion": {status: store.ADDED},

pkg/handler/pprof.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import (
2323
"github.com/haproxytech/kubernetes-ingress/pkg/store"
2424
)
2525

26+
const pprofBackend = "pprof"
27+
2628
type Pprof struct{}
2729

2830
func (handler Pprof) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (reload bool, err error) {
29-
pprofBackend := "pprof"
30-
31+
k.BackendsWithNoConfigSnippets[pprofBackend] = struct{}{}
3132
_, err = h.BackendGet(pprofBackend)
3233
if err != nil {
3334
err = h.BackendCreatePermanently(models.Backend{
@@ -38,7 +39,7 @@ func (handler Pprof) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annota
3839
return
3940
}
4041
err = h.BackendServerCreate(pprofBackend, models.Server{
41-
Name: "pprof",
42+
Name: pprofBackend,
4243
Address: "127.0.0.1:6060",
4344
})
4445
if err != nil {

pkg/store/store.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ import (
2424
const DefaultLocalBackend = "default-local-service"
2525

2626
type K8s struct {
27-
ConfigMaps ConfigMaps
28-
NamespacesAccess NamespacesWatch
29-
Namespaces map[string]*Namespace
30-
IngressClasses map[string]*IngressClass
31-
SecretsProcessed map[string]struct{}
32-
BackendsProcessed map[string]struct{}
33-
GatewayClasses map[string]*GatewayClass
34-
GatewayControllerName string
35-
PublishServiceAddresses []string
36-
NbrHAProxyInst int64
37-
UpdateAllIngresses bool
27+
ConfigMaps ConfigMaps
28+
NamespacesAccess NamespacesWatch
29+
Namespaces map[string]*Namespace
30+
IngressClasses map[string]*IngressClass
31+
SecretsProcessed map[string]struct{}
32+
BackendsProcessed map[string]struct{}
33+
GatewayClasses map[string]*GatewayClass
34+
GatewayControllerName string
35+
PublishServiceAddresses []string
36+
NbrHAProxyInst int64
37+
UpdateAllIngresses bool
38+
BackendsWithNoConfigSnippets map[string]struct{}
3839
}
3940

4041
type NamespacesWatch struct {
@@ -72,9 +73,10 @@ func NewK8sStore(args utils.OSArgs) K8s {
7273
Name: args.ConfigMapPatternFiles.Name,
7374
},
7475
},
75-
SecretsProcessed: map[string]struct{}{},
76-
BackendsProcessed: map[string]struct{}{},
77-
GatewayClasses: make(map[string]*GatewayClass),
76+
SecretsProcessed: map[string]struct{}{},
77+
BackendsProcessed: map[string]struct{}{},
78+
GatewayClasses: map[string]*GatewayClass{},
79+
BackendsWithNoConfigSnippets: map[string]struct{}{},
7880
}
7981
for _, namespace := range args.NamespaceWhitelist {
8082
store.NamespacesAccess.Whitelist[namespace] = struct{}{}

0 commit comments

Comments
 (0)