Skip to content

Commit d4b9cf5

Browse files
Mo3m3noktalz
authored andcommitted
BUG/MINOR: remove backend cfgSnippet state when backend is deleted
1 parent 07e10cd commit d4b9cf5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

controller/annotations/cfgSnippet.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ type cfgData struct {
2121
updated []string
2222
}
2323

24+
// cfgSnippet is a particular type of config that is not
25+
// handled by the upstram library haproxytech/client-native.
26+
// Which means there is no client-native models to
27+
// store, exchange and query cfgSnippet Data. Thus this logic
28+
// is directly handled by Ingress Controller in this package.
29+
//
30+
// The code in this file need to be rewritten to avoid init,
31+
// global variables and rather expose a clean interface.
2432
var cfgSnippet struct {
2533
global *cfgData
2634
frontends map[string]*cfgData
@@ -137,3 +145,10 @@ func UpdateBackendCfgSnippet(api api.HAProxyClient, backend string) (updated []s
137145
cfgSnippet.backends[backend] = data
138146
return
139147
}
148+
149+
func RemoveBackendCfgSnippet(backend string) {
150+
if cfgSnippet.backends == nil {
151+
return
152+
}
153+
delete(cfgSnippet.backends, backend)
154+
}

controller/handler/refresh.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (h Refresh) clearBackends(api api.HAProxyClient, cfg *config.ControllerCfg)
5858
if err := api.BackendDelete(backend.Name); err != nil {
5959
logger.Panic(err)
6060
}
61+
annotations.RemoveBackendCfgSnippet(backend.Name)
6162
}
6263
}
6364
}

0 commit comments

Comments
 (0)