diff --git a/pkg/haproxy/api/api.go b/pkg/haproxy/api/api.go index 8283d5ab..4a839c6b 100644 --- a/pkg/haproxy/api/api.go +++ b/pkg/haproxy/api/api.go @@ -15,6 +15,10 @@ import ( "github.com/haproxytech/kubernetes-ingress/pkg/utils" ) +// BufferSize is the default value of HAproxy tune.bufsize. Not recommended to change it +// Map payload or socket data cannot be bigger than tune.bufsize +const BufferSize = 16000 + type HAProxyClient interface { //nolint:interfacebloat APIStartTransaction() error APICommitTransaction() error diff --git a/pkg/haproxy/api/runtime.go b/pkg/haproxy/api/runtime.go index 6abf654a..bb194891 100644 --- a/pkg/haproxy/api/runtime.go +++ b/pkg/haproxy/api/runtime.go @@ -15,10 +15,6 @@ import ( var ErrMapNotFound = fmt.Errorf("map not found") -// bufsize is the default value of HAproxy tune.bufsize. Not recommended to change it -// Map payload cannot be bigger than tune.bufsize -const bufSize = 16000 - type RuntimeServerData struct { BackendName string ServerName string @@ -46,8 +42,8 @@ func (c *clientNative) SetServerAddrAndState(servers []RuntimeServerData) error backendNameSize := len(servers[0].BackendName) oneServerCommandSize := 65 + 2*backendNameSize size := oneServerCommandSize * len(servers) - if size > bufSize { - size = bufSize + if size > BufferSize { + size = BufferSize } var sb strings.Builder @@ -106,7 +102,8 @@ func (c *clientNative) runRaw(runtime runtime.Runtime, sb strings.Builder, backe if len(result[i]) > 5 { switch result[i][1:5] { case "[3]:", "[2]:", "[1]:", "[0]:": - logger.Errorf("[RUNTIME] [BACKEND] [SOCKET] backend %s: Error: '%s', server slots adjustment ?", backendName, result[i]) + logger.Errorf("[RUNTIME] [BACKEND] [SOCKET] backend %s', server slots adjustment ?", backendName) + logger.Tracef("[RUNTIME] [BACKEND] [SOCKET] backend %s: Error: '%s', server slots adjustment ?", backendName, result[i]) return errors.New("runtime update failed for " + backendName) } } diff --git a/pkg/haproxy/maps/main.go b/pkg/haproxy/maps/main.go index 843aced9..8496ee1d 100644 --- a/pkg/haproxy/maps/main.go +++ b/pkg/haproxy/maps/main.go @@ -50,10 +50,6 @@ var logger = utils.GetLogger() var mapDir string -// bufsize is the default value of HAproxy tune.bufsize. -// Map payload cannot be bigger than tune.bufsize -const bufSize = 16000 - type mapFile struct { rows []string hash uint64 @@ -69,7 +65,7 @@ func (mf *mapFile) getContent() (result []string, hash uint64) { sort.Strings(mf.rows) h := fnv.New64a() for _, r := range mf.rows { - if chunk.Len()+len(r) >= bufSize { + if chunk.Len()+len(r) >= api.BufferSize { result = append(result, chunk.String()) chunk.Reset() }