Skip to content

Commit 2f61fd4

Browse files
committed
MINOR: provide initial local peer
1 parent 467bbe8 commit 2f61fd4

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

fs/usr/local/etc/haproxy/haproxy.cfg

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
global
1010
daemon
11+
localpeer local
1112
master-worker
1213
pidfile /var/run/haproxy.pid
1314
stats socket /var/run/haproxy-runtime-api.sock level admin expose-fd listeners
@@ -23,7 +24,7 @@ defaults haproxytech
2324
timeout http-keep-alive 60000
2425

2526
peers localinstance
26-
27+
peer local 127.0.0.1:10000
2728

2829
frontend https
2930
mode http

pkg/controller/controller.go

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ func (c *HAProxyController) clientAPIClosure(fn func() error) (err error) {
8383
// Start initializes and runs HAProxyController
8484
func (c *HAProxyController) Start() {
8585
logger.Panic(c.clientAPIClosure(func() error {
86+
err := c.haproxy.PeerEntryDelete("localinstance", "local")
87+
if err != nil {
88+
return err
89+
}
8690
return c.haproxy.PeerEntryCreateOrEdit("localinstance",
8791
models.PeerEntry{
8892
Name: c.Hostname,

pkg/haproxy/api/api.go

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type HAProxyClient interface { //nolint:interfacebloat
9191
TCPRequestRuleCreate(parentType, parentName string, rule models.TCPRequestRule) error
9292
TCPRequestRulesGet(parentType, parentName string) (models.TCPRequestRules, error)
9393
TCPRequestRuleDeleteAll(parentType, parentName string) (err error)
94+
PeerEntryDelete(peerSection string, name string) error
9495
PeerEntryEdit(peerSection string, peer models.PeerEntry) error
9596
PeerEntryCreateOrEdit(peerSection string, peer models.PeerEntry) error
9697
RefreshBackends() (deleted []string, err error)

pkg/haproxy/api/frontend.go

+8
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,11 @@ func (c *clientNative) PeerEntryCreateOrEdit(peerSection string, peerEntry model
255255
}
256256
return err
257257
}
258+
259+
func (c *clientNative) PeerEntryDelete(peerSection, entry string) error {
260+
cfg, err := c.nativeAPI.Configuration()
261+
if err != nil {
262+
return err
263+
}
264+
return cfg.DeletePeerEntry(entry, peerSection, c.activeTransaction, 0)
265+
}

0 commit comments

Comments
 (0)