From d421ee30937b467d732457599af105da60d20b9b Mon Sep 17 00:00:00 2001 From: Ivan Matmati Date: Thu, 30 Nov 2023 10:12:15 +0100 Subject: [PATCH] BUG: recovers global and frontend config snippets after a faulty transaction --- pkg/annotations/cfgSnippet.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/annotations/cfgSnippet.go b/pkg/annotations/cfgSnippet.go index 543e6dfc..d72eb161 100644 --- a/pkg/annotations/cfgSnippet.go +++ b/pkg/annotations/cfgSnippet.go @@ -224,13 +224,15 @@ func (a *CfgSnippet) Process(k store.K8s, annotations ...map[string]string) erro } func UpdateGlobalCfgSnippet(api api.HAProxyClient) (updated []string, err error) { - if len(cfgSnippet.global.updated) == 0 { - return - } err = api.GlobalCfgSnippet(cfgSnippet.global.value) if err != nil { return } + + if len(cfgSnippet.global.updated) == 0 { + return + } + updated = cfgSnippet.global.updated cfgSnippet.global.updated = nil return @@ -242,13 +244,16 @@ func UpdateFrontendCfgSnippet(api api.HAProxyClient, frontends ...string) (updat if !ok { continue } - if len(data.updated) == 0 { - continue - } + err = api.FrontendCfgSnippetSet(ft, data.value) if err != nil { return } + + if len(data.updated) == 0 { + continue + } + updated = append(updated, data.updated...) data.updated = nil cfgSnippet.frontends[ft] = data