Skip to content

Commit

Permalink
BUG: recovers global and frontend config snippets after a faulty tran…
Browse files Browse the repository at this point in the history
…saction
  • Loading branch information
ivanmatmati authored and oktalz committed Dec 12, 2023
1 parent 17ea85e commit d421ee3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/annotations/cfgSnippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d421ee3

Please sign in to comment.