Skip to content

Commit 351bff5

Browse files
ivanmatmatioktalz
authored andcommitted
MINOR: put setReady in the main transaction
1 parent d3e1d79 commit 351bff5

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

pkg/controller/controller.go

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ func (c *HAProxyController) updateHAProxy() {
174174
logger.Error(handler.Update(c.store, c.haproxy, c.annotations))
175175
}
176176

177+
if !c.ready {
178+
c.setToReady()
179+
}
180+
177181
err = c.haproxy.APICommitTransaction()
178182
if err != nil {
179183
logger.Error("unable to Sync HAProxy configuration !!")
@@ -192,10 +196,6 @@ func (c *HAProxyController) updateHAProxy() {
192196
return
193197
}
194198

195-
if !c.ready {
196-
c.setToReady()
197-
}
198-
199199
if instance.NeedReload() {
200200
if err = c.haproxy.Service("reload"); err != nil {
201201
logger.Error(err)
@@ -213,38 +213,32 @@ func (c *HAProxyController) updateHAProxy() {
213213
// setToRready exposes readiness endpoint
214214
func (c *HAProxyController) setToReady() {
215215
healthzPort := c.osArgs.HealthzBindPort
216-
logger.Panic(c.clientAPIClosure(func() error {
217-
return c.haproxy.FrontendBindCreate("healthz",
216+
logger.Panic(c.haproxy.FrontendBindCreate("healthz",
217+
models.Bind{
218+
BindParams: models.BindParams{
219+
Name: "v4",
220+
},
221+
Address: fmt.Sprintf("0.0.0.0:%d", healthzPort),
222+
}))
223+
if !c.osArgs.DisableIPV6 {
224+
logger.Panic(c.haproxy.FrontendBindCreate("healthz",
218225
models.Bind{
219226
BindParams: models.BindParams{
220-
Name: "v4",
227+
Name: "v6",
228+
V4v6: true,
221229
},
222-
Address: fmt.Sprintf("0.0.0.0:%d", healthzPort),
223-
})
224-
}))
225-
if !c.osArgs.DisableIPV6 {
226-
logger.Panic(c.clientAPIClosure(func() error {
227-
return c.haproxy.FrontendBindCreate("healthz",
228-
models.Bind{
229-
BindParams: models.BindParams{
230-
Name: "v6",
231-
V4v6: true,
232-
},
233-
Address: fmt.Sprintf(":::%d", healthzPort),
234-
})
235-
}))
230+
Address: fmt.Sprintf(":::%d", healthzPort),
231+
}))
236232
}
237233

238-
logger.Panic(c.clientAPIClosure(func() error {
239-
return c.haproxy.FrontendBindCreate("stats",
240-
models.Bind{
241-
BindParams: models.BindParams{
242-
Name: "stats",
243-
},
244-
Address: fmt.Sprintf("*:%d", c.osArgs.StatsBindPort),
234+
logger.Panic(c.haproxy.FrontendBindCreate("stats",
235+
models.Bind{
236+
BindParams: models.BindParams{
237+
Name: "stats",
245238
},
246-
)
247-
}))
239+
Address: fmt.Sprintf("*:%d", c.osArgs.StatsBindPort),
240+
},
241+
))
248242

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

0 commit comments

Comments
 (0)