Skip to content

Commit

Permalink
MINOR: put setReady in the main transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmatmati authored and oktalz committed Nov 21, 2024
1 parent c28d620 commit 97b2159
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ func (c *HAProxyController) updateHAProxy() {

fs.Writer.WaitUntilWritesDone()

if !c.ready {
c.setToReady()
}

err = c.haproxy.APICommitTransaction()
if err != nil {
logger.Error("unable to Sync HAProxy configuration !!")
Expand All @@ -195,10 +199,6 @@ func (c *HAProxyController) updateHAProxy() {
return
}

if !c.ready {
c.setToReady()
}

if instance.NeedReload() {
fs.RunDelayedFuncs()
if err = c.haproxy.Service("reload"); err != nil {
Expand All @@ -220,41 +220,35 @@ func (c *HAProxyController) updateHAProxy() {
// setToRready exposes readiness endpoint
func (c *HAProxyController) setToReady() {
healthzPort := c.osArgs.HealthzBindPort
logger.Panic(c.clientAPIClosure(func() error {
return c.haproxy.FrontendBindCreate("healthz",
logger.Panic(c.haproxy.FrontendBindCreate("healthz",
models.Bind{
BindParams: models.BindParams{
Name: "v4",
Thread: c.osArgs.HealthzBindThread,
},
Address: fmt.Sprintf("0.0.0.0:%d", healthzPort),
}))
if !c.osArgs.DisableIPV6 {
logger.Panic(c.haproxy.FrontendBindCreate("healthz",
models.Bind{
BindParams: models.BindParams{
Name: "v4",
Name: "v6",
V4v6: true,
Thread: c.osArgs.HealthzBindThread,
},
Address: fmt.Sprintf("0.0.0.0:%d", healthzPort),
})
}))
if !c.osArgs.DisableIPV6 {
logger.Panic(c.clientAPIClosure(func() error {
return c.haproxy.FrontendBindCreate("healthz",
models.Bind{
BindParams: models.BindParams{
Name: "v6",
V4v6: true,
Thread: c.osArgs.HealthzBindThread,
},
Address: fmt.Sprintf(":::%d", healthzPort),
})
}))
Address: fmt.Sprintf(":::%d", healthzPort),
}))
}

logger.Panic(c.clientAPIClosure(func() error {
return c.haproxy.FrontendBindCreate("stats",
models.Bind{
BindParams: models.BindParams{
Name: "stats",
Thread: c.osArgs.StatsBindThread,
},
Address: fmt.Sprintf("*:%d", c.osArgs.StatsBindPort),
logger.Panic(c.haproxy.FrontendBindCreate("stats",
models.Bind{
BindParams: models.BindParams{
Name: "stats",
Thread: c.osArgs.StatsBindThread,
},
)
}))
Address: fmt.Sprintf("*:%d", c.osArgs.StatsBindPort),
},
))

logger.Debugf("healthz frontend exposed for readiness probe")
cm := c.store.ConfigMaps.Main
Expand Down

0 comments on commit 97b2159

Please sign in to comment.