Skip to content

Commit

Permalink
BUG/MINOR: prevents port conflicts on startup when using hostNetwork
Browse files Browse the repository at this point in the history
Creates new binds (instead of editing them) of the healthz and stats
frontends to avoid port conflicts at the first start of the HAProxy
when using hostNetwork: true.

Since these bind directives are not required, the first start of
HAProxy is not affected.
  • Loading branch information
fabianonunes committed Sep 7, 2023
1 parent 4d9884b commit de65bf9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 15 deletions.
4 changes: 0 additions & 4 deletions deploy/tests/integration/base-suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,21 @@ peers localinstance
frontend https
mode http
bind 127.0.0.1:8080 name v4
http-request set-var(txn.base) base
use_backend %[var(txn.path_match),field(1,.)]
frontend http
mode http
bind 127.0.0.1:4443 name v4
http-request set-var(txn.base) base
use_backend %[var(txn.path_match),field(1,.)]
frontend healthz
bind 127.0.0.1:1042 name v4
mode http
monitor-uri /healthz
option dontlog-normal
frontend stats
mode http
bind *:1024 name stats
stats enable
stats uri /
stats refresh 10s
Expand Down
5 changes: 0 additions & 5 deletions deploy/tests/tnr/routeacl/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (suite *UseBackendSuite) BeforeTest(suiteName, testName string) {
suite.T().Logf("temporary configuration dir %s", suite.test.TempDir)
}

//nolint:dupword
var haproxyConfig = `global
daemon
master-worker
Expand All @@ -75,25 +74,21 @@ peers localinstance
frontend https
mode http
bind 127.0.0.1:8080 name v4
http-request set-var(txn.base) base
use_backend %[var(txn.path_match),field(1,.)]
frontend http
mode http
bind 127.0.0.1:4443 name v4
http-request set-var(txn.base) base
use_backend %[var(txn.path_match),field(1,.)]
frontend healthz
bind 127.0.0.1:1042 name v4
mode http
monitor-uri /healthz
option dontlog-normal
frontend stats
mode http
bind *:1024 name stats
stats enable
stats uri /
stats refresh 10s
Expand Down
4 changes: 0 additions & 4 deletions fs/usr/local/etc/haproxy/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,21 @@ peers localinstance

frontend https
mode http
bind 127.0.0.1:8080 name v4
http-request set-var(txn.base) base
use_backend %[var(txn.path_match),field(1,.)]

frontend http
mode http
bind 127.0.0.1:4443 name v4
http-request set-var(txn.base) base
use_backend %[var(txn.path_match),field(1,.)]

frontend healthz
bind 127.0.0.1:1042 name v4
mode http
monitor-uri /healthz
option dontlog-normal

frontend stats
mode http
bind *:1024 name stats
http-request set-var(txn.base) base
http-request use-service prometheus-exporter if { path /metrics }
stats enable
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (c *HAProxyController) updateHAProxy() {
func (c *HAProxyController) setToReady() {
healthzPort := c.osArgs.HealthzBindPort
logger.Panic(c.clientAPIClosure(func() error {
return c.haproxy.FrontendBindEdit("healthz",
return c.haproxy.FrontendBindCreate("healthz",
models.Bind{
BindParams: models.BindParams{
Name: "v4",
Expand Down Expand Up @@ -237,7 +237,7 @@ func (c *HAProxyController) setToReady() {
}))

logger.Panic(c.clientAPIClosure(func() error {
return c.haproxy.FrontendBindEdit("stats",
return c.haproxy.FrontendBindCreate("stats",
models.Bind{
BindParams: models.BindParams{
Name: "stats",
Expand Down

0 comments on commit de65bf9

Please sign in to comment.