Skip to content

Commit 5f1b949

Browse files
cxfcxfoktalz
authored andcommitted
MINOR: support thread pin on frontend/status
1 parent 5fbf0b2 commit 5f1b949

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

pkg/controller/controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ func (c *HAProxyController) setToReady() {
225225
return c.haproxy.FrontendBindCreate("healthz",
226226
models.Bind{
227227
BindParams: models.BindParams{
228-
Name: "v4",
228+
Name: "v4",
229+
Thread: c.osArgs.HealthzBindThread,
229230
},
230231
Address: fmt.Sprintf("0.0.0.0:%d", healthzPort),
231232
})
@@ -235,8 +236,9 @@ func (c *HAProxyController) setToReady() {
235236
return c.haproxy.FrontendBindCreate("healthz",
236237
models.Bind{
237238
BindParams: models.BindParams{
238-
Name: "v6",
239-
V4v6: true,
239+
Name: "v6",
240+
V4v6: true,
241+
Thread: c.osArgs.HealthzBindThread,
240242
},
241243
Address: fmt.Sprintf(":::%d", healthzPort),
242244
})

pkg/controller/handler.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ func (c *HAProxyController) startupHandlers() error {
9696
handlers := []UpdateHandler{
9797
handler.GlobalCfg{},
9898
handler.HTTPBind{
99-
HTTP: !c.osArgs.DisableHTTP,
100-
HTTPS: !c.osArgs.DisableHTTPS,
101-
IPv4: !c.osArgs.DisableIPV4,
102-
IPv6: !c.osArgs.DisableIPV6,
103-
HTTPPort: c.osArgs.HTTPBindPort,
104-
HTTPSPort: c.osArgs.HTTPSBindPort,
105-
IPv4Addr: c.osArgs.IPV4BindAddr,
106-
IPv6Addr: c.osArgs.IPV6BindAddr,
99+
HTTP: !c.osArgs.DisableHTTP,
100+
HTTPS: !c.osArgs.DisableHTTPS,
101+
IPv4: !c.osArgs.DisableIPV4,
102+
IPv6: !c.osArgs.DisableIPV6,
103+
HTTPPort: c.osArgs.HTTPBindPort,
104+
HTTPSPort: c.osArgs.HTTPSBindPort,
105+
IPv4Addr: c.osArgs.IPV4BindAddr,
106+
IPv6Addr: c.osArgs.IPV6BindAddr,
107+
HTTPBindThread: c.osArgs.HTTPBindThread,
108+
HTTPSBindThread: c.osArgs.HTTPSBindThread,
107109
},
108110
}
109111

pkg/handler/http-bind.go

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,38 @@ import (
2525
)
2626

2727
type HTTPBind struct {
28-
IPv4Addr string
29-
IPv6Addr string
30-
HTTPPort int64
31-
HTTPSPort int64
32-
HTTP bool
33-
HTTPS bool
34-
IPv4 bool
35-
IPv6 bool
28+
IPv4Addr string
29+
IPv6Addr string
30+
HTTPPort int64
31+
HTTPSPort int64
32+
HTTP bool
33+
HTTPS bool
34+
IPv4 bool
35+
IPv6 bool
36+
HTTPBindThread string
37+
HTTPSBindThread string
38+
}
39+
40+
type PortAndThread struct {
41+
Port int64
42+
Thread string
3643
}
3744

3845
func (handler HTTPBind) Update(k store.K8s, h haproxy.HAProxy, a annotations.Annotations) (err error) {
3946
var errors utils.Errors
40-
frontends := make(map[string]int64, 2)
47+
frontends := make(map[string]PortAndThread, 2)
4148
protos := make(map[string]string, 2)
4249
if handler.HTTP {
43-
frontends[h.FrontHTTP] = handler.HTTPPort
50+
frontends[h.FrontHTTP] = PortAndThread{
51+
Port: handler.HTTPPort,
52+
Thread: handler.HTTPBindThread,
53+
}
4454
}
4555
if handler.HTTPS {
46-
frontends[h.FrontHTTPS] = handler.HTTPSPort
56+
frontends[h.FrontHTTPS] = PortAndThread{
57+
Port: handler.HTTPSPort,
58+
Thread: handler.HTTPSBindThread,
59+
}
4760
}
4861
if handler.IPv4 {
4962
protos["v4"] = handler.IPv4Addr
@@ -61,11 +74,14 @@ func (handler HTTPBind) Update(k store.K8s, h haproxy.HAProxy, a annotations.Ann
6174
Address: ":::1024",
6275
}))
6376
}
64-
for ftName, ftPort := range frontends {
77+
for ftName, ftPortAndThread := range frontends {
78+
ftPort := ftPortAndThread.Port
79+
thread := ftPortAndThread.Thread
6580
for proto, addr := range protos {
6681
bind := models.Bind{
6782
BindParams: models.BindParams{
68-
Name: proto,
83+
Name: proto,
84+
Thread: thread,
6985
},
7086
Address: addr,
7187
Port: utils.PtrInt64(ftPort),

pkg/utils/flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ type OSArgs struct {
9292
ControllerPort int `long:"controller-port" description:"port to listen on for controller data: prometheus, pprof" default:"6060"`
9393
HTTPBindPort int64 `long:"http-bind-port" default:"8080" description:"port to listen on for HTTP traffic"`
9494
HTTPSBindPort int64 `long:"https-bind-port" default:"8443" description:"port to listen on for HTTPS traffic"`
95+
HTTPBindThread string `long:"http-bind-thread" description:"default http service bind thread params eg: 1-1" default:""`
96+
HTTPSBindThread string `long:"https-bind-thread" description:"default https service bind thread params eg: 1-1" default:""`
9597
SyncPeriod time.Duration `long:"sync-period" default:"5s" description:"Sets the period at which the controller syncs HAProxy configuration file"`
9698
CacheResyncPeriod time.Duration `long:"cache-resync-period" default:"10m" description:"Sets the underlying Shared Informer resync period: resyncing controller with informers cache"`
9799
HealthzBindPort int64 `long:"healthz-bind-port" default:"1042" description:"port to listen on for probes"`
100+
HealthzBindThread string `long:"healthz-bind-thread" description:"default healthz service bind thread params eg: 1-1" default:""`
98101
LogLevel LogLevelValue `long:"log" default:"info" description:"level of log messages you can see"`
99102
DisableIPV4 bool `long:"disable-ipv4" description:"toggle to disable the IPv4 protocol from all frontends"`
100103
External bool `short:"e" long:"external" description:"use as external Ingress Controller (out of k8s cluster)"`

0 commit comments

Comments
 (0)