diff --git a/configuration/backend_test.go b/configuration/backend_test.go index 8e228a84..fd864eee 100644 --- a/configuration/backend_test.go +++ b/configuration/backend_test.go @@ -260,6 +260,12 @@ func TestGetBackends(t *testing.T) { //nolint:gocognit,gocyclo t.Errorf("EmailAlert.Mailers is not localmailer1: %v", *b.EmailAlert.Mailers) } + if b.Name == "test" && (b.DefaultServer.LogBufsize == nil || *b.DefaultServer.LogBufsize != 6) { + t.Errorf("%v: DefaultServer.LogBufsize not 6: %v", b.Name, b.DefaultServer.LogBufsize) + } + if b.Name == "test2" && b.DefaultServer.LogBufsize != nil { + t.Errorf("%v: DefaultServer.LogBufsize should be nil: %v", b.Name, b.DefaultServer.LogBufsize) + } } } @@ -324,6 +330,9 @@ func TestGetBackend(t *testing.T) { if *b.DefaultServer.HealthCheckPort != 8888 { t.Errorf("%v: DefaultServer.HealthCheckPort not 8888: %v", b.Name, *b.DefaultServer.HealthCheckPort) } + if b.Name == "test" && (b.DefaultServer.LogBufsize == nil || *b.DefaultServer.LogBufsize != 6) { + t.Errorf("%v: DefaultServer.LogBufsize not 6: %v", b.Name, b.DefaultServer.LogBufsize) + } if *b.Cookie.Name != "BLA" { t.Errorf("%v: HTTPCookie Name not BLA: %v", b.Name, b.Cookie) } @@ -698,8 +707,9 @@ func TestCreateEditDeleteBackend(t *testing.T) { }, DefaultServer: &models.DefaultServer{ ServerParams: models.ServerParams{ - Fall: &tOut, - Inter: &tOut, + Fall: &tOut, + Inter: &tOut, + LogBufsize: misc.Int64P(123), }, }, HTTPConnectionMode: "http-keep-alive", diff --git a/configuration/configuration_test.go b/configuration/configuration_test.go index 7fc93307..6a796a9a 100644 --- a/configuration/configuration_test.go +++ b/configuration/configuration_test.go @@ -602,7 +602,7 @@ backend test option splice-request option splice-response option http-restrict-req-hdr-names preserve - default-server fall 2s rise 4s inter 5s port 8888 ws auto pool-low-conn 128 + default-server fall 2s rise 4s inter 5s port 8888 ws auto pool-low-conn 128 log-bufsize 6 stick store-request src table test stick match src table test stick on src table test @@ -638,7 +638,7 @@ backend test external-check command /bin/false use-server webserv if TRUE use-server webserv2 unless TRUE - server webserv 192.168.1.1:9200 maxconn 1000 ssl weight 10 inter 2s cookie BLAH slowstart 6000 proxy-v2-options authority,crc32c ws h1 pool-low-conn 128 id 1234 pool-purge-delay 10s tcp-ut 2s curves secp384r1 client-sigalgs ECDSA+SHA256:RSA+SHA256 sigalgs ECDSA+SHA256 + server webserv 192.168.1.1:9200 maxconn 1000 ssl weight 10 inter 2s cookie BLAH slowstart 6000 proxy-v2-options authority,crc32c ws h1 pool-low-conn 128 id 1234 pool-purge-delay 10s tcp-ut 2s curves secp384r1 client-sigalgs ECDSA+SHA256:RSA+SHA256 sigalgs ECDSA+SHA256 log-bufsize 10 server webserv2 192.168.1.1:9300 maxconn 1000 ssl weight 10 inter 2s cookie BLAH slowstart 6000 proxy-v2-options authority,crc32c ws h1 pool-low-conn 128 http-request set-dst hdr(x-dst) http-request set-dst-port int(4000) diff --git a/configuration/server.go b/configuration/server.go index 295810ea..fd97e9f1 100644 --- a/configuration/server.go +++ b/configuration/server.go @@ -365,6 +365,11 @@ func parseServerParams(serverOptions []params.ServerOption, serverParams *models serverParams.Fastinter = misc.ParseTimeout(v.Value) case "downinter": serverParams.Downinter = misc.ParseTimeout(v.Value) + case "log-bufsize": + l, err := strconv.ParseInt(v.Value, 10, 64) + if err == nil { + serverParams.LogBufsize = &l + } case "log-proto": serverParams.LogProto = v.Value case "maxconn": @@ -699,6 +704,9 @@ func serializeServerParams(s models.ServerParams) (options []params.ServerOption if s.Downinter != nil { options = append(options, ¶ms.ServerOptionValue{Name: "downinter", Value: strconv.FormatInt(*s.Downinter, 10)}) } + if s.LogBufsize != nil { + options = append(options, ¶ms.ServerOptionValue{Name: "log-bufsize", Value: strconv.FormatInt(*s.LogBufsize, 10)}) + } if s.LogProto != "" { options = append(options, ¶ms.ServerOptionValue{Name: "log-proto", Value: s.LogProto}) } diff --git a/configuration/server_test.go b/configuration/server_test.go index 461c7d8e..845e3a64 100644 --- a/configuration/server_test.go +++ b/configuration/server_test.go @@ -79,6 +79,13 @@ func TestGetServers(t *testing.T) { //nolint:gocognit,gocyclo t.Errorf("%v: ProxyV2Options[0] not crc32c: %s", s.Name, s.ProxyV2Options[1]) } } + + if s.Name == "webserv" && (s.LogBufsize == nil || *s.LogBufsize != 10) { + t.Errorf("%v: LogBufsize should be 10: %v", s.Name, s.LogBufsize) + } + if s.Name == "webserv2" && s.LogBufsize != nil { + t.Errorf("%v: LogBufsize should be nil: %v", s.Name, s.LogBufsize) + } } _, servers, err = clientTest.GetServers("backend", "test_2", "") @@ -158,6 +165,9 @@ func TestGetServer(t *testing.T) { if s.Sigalgs != "ECDSA+SHA256" { t.Errorf("%v: Sigalgs not ECDSA+SHA256: %v", s.Name, s.Sigalgs) } + if s.LogBufsize == nil || *s.LogBufsize != 10 { + t.Errorf("%v: LogBufsize should be 10: %v", s.Name, s.LogBufsize) + } _, err = s.MarshalBinary() if err != nil { @@ -259,6 +269,7 @@ func TestCreateEditDeleteServer(t *testing.T) { Curves: "brainpoolP384r1", Sigalgs: "RSA+SHA256", ClientSigalgs: "ECDSA+SHA256", + LogBufsize: misc.Int64P(11), }, } diff --git a/models/server_params.go b/models/server_params.go index dd3668c1..c194ba92 100644 --- a/models/server_params.go +++ b/models/server_params.go @@ -161,6 +161,9 @@ type ServerParams struct { // inter Inter *int64 `json:"inter,omitempty"` + // log bufsize + LogBufsize *int64 `json:"log-bufsize,omitempty"` + // log proto // Enum: [legacy octet-count] LogProto string `json:"log_proto,omitempty"` diff --git a/models/server_params_compare.go b/models/server_params_compare.go index 0b56660e..e34663c6 100644 --- a/models/server_params_compare.go +++ b/models/server_params_compare.go @@ -169,6 +169,10 @@ func (s ServerParams) Equal(t ServerParams, opts ...Options) bool { return false } + if !equalPointers(s.LogBufsize, t.LogBufsize) { + return false + } + if s.LogProto != t.LogProto { return false } @@ -541,6 +545,10 @@ func (s ServerParams) Diff(t ServerParams, opts ...Options) map[string][]interfa diff["Inter"] = []interface{}{ValueOrNil(s.Inter), ValueOrNil(t.Inter)} } + if !equalPointers(s.LogBufsize, t.LogBufsize) { + diff["LogBufsize"] = []interface{}{ValueOrNil(s.LogBufsize), ValueOrNil(t.LogBufsize)} + } + if s.LogProto != t.LogProto { diff["LogProto"] = []interface{}{s.LogProto, t.LogProto} } diff --git a/models/server_params_compare_test.go b/models/server_params_compare_test.go index 1cd5b334..05019711 100644 --- a/models/server_params_compare_test.go +++ b/models/server_params_compare_test.go @@ -92,6 +92,7 @@ func TestServerParamsEqualFalse(t *testing.T) { result.Fastinter = Ptr(*sample.Fastinter + 1) result.HealthCheckPort = Ptr(*sample.HealthCheckPort + 1) result.Inter = Ptr(*sample.Inter + 1) + result.LogBufsize = Ptr(*sample.LogBufsize + 1) result.MaxReuse = Ptr(*sample.MaxReuse + 1) result.Maxconn = Ptr(*sample.Maxconn + 1) result.Maxqueue = Ptr(*sample.Maxqueue + 1) @@ -192,6 +193,7 @@ func TestServerParamsDiffFalse(t *testing.T) { result.Fastinter = Ptr(*sample.Fastinter + 1) result.HealthCheckPort = Ptr(*sample.HealthCheckPort + 1) result.Inter = Ptr(*sample.Inter + 1) + result.LogBufsize = Ptr(*sample.LogBufsize + 1) result.MaxReuse = Ptr(*sample.MaxReuse + 1) result.Maxconn = Ptr(*sample.Maxconn + 1) result.Maxqueue = Ptr(*sample.Maxqueue + 1) @@ -211,7 +213,7 @@ func TestServerParamsDiffFalse(t *testing.T) { for _, sample := range samples { result := sample.a.Diff(sample.b) - if len(result) != 88 { + if len(result) != 89 { json := jsoniter.ConfigCompatibleWithStandardLibrary a, err := json.Marshal(&sample.a) if err != nil { @@ -221,7 +223,7 @@ func TestServerParamsDiffFalse(t *testing.T) { if err != nil { t.Errorf(err.Error()) } - t.Errorf("Expected ServerParams to be different in 88 cases, but it is not (%d) %s %s", len(result), a, b) + t.Errorf("Expected ServerParams to be different in 89 cases, but it is not (%d) %s %s", len(result), a, b) } } } diff --git a/specification/build/haproxy_spec.yaml b/specification/build/haproxy_spec.yaml index d3043635..3ea64836 100644 --- a/specification/build/haproxy_spec.yaml +++ b/specification/build/haproxy_spec.yaml @@ -630,6 +630,9 @@ definitions: inter: type: integer x-nullable: true + log-bufsize: + type: integer + x-nullable: true log_proto: enum: - legacy diff --git a/specification/models/configuration/server_params.yaml b/specification/models/configuration/server_params.yaml index b687a3ad..291c1014 100644 --- a/specification/models/configuration/server_params.yaml +++ b/specification/models/configuration/server_params.yaml @@ -142,6 +142,9 @@ server_params: log_proto: type: string enum: [legacy, octet-count] + log-bufsize: + type: integer + x-nullable: true maxconn: type: integer x-display-name: Max Concurrent Connections