Skip to content

Commit

Permalink
MINOR: add log-bufsize option to server params
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Gramer <[email protected]>
  • Loading branch information
vgramer authored and mjuraga committed Nov 29, 2023
1 parent 94d82e0 commit 2e8501a
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 6 deletions.
14 changes: 12 additions & 2 deletions configuration/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions configuration/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -699,6 +704,9 @@ func serializeServerParams(s models.ServerParams) (options []params.ServerOption
if s.Downinter != nil {
options = append(options, &params.ServerOptionValue{Name: "downinter", Value: strconv.FormatInt(*s.Downinter, 10)})
}
if s.LogBufsize != nil {
options = append(options, &params.ServerOptionValue{Name: "log-bufsize", Value: strconv.FormatInt(*s.LogBufsize, 10)})
}
if s.LogProto != "" {
options = append(options, &params.ServerOptionValue{Name: "log-proto", Value: s.LogProto})
}
Expand Down
11 changes: 11 additions & 0 deletions configuration/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -259,6 +269,7 @@ func TestCreateEditDeleteServer(t *testing.T) {
Curves: "brainpoolP384r1",
Sigalgs: "RSA+SHA256",
ClientSigalgs: "ECDSA+SHA256",
LogBufsize: misc.Int64P(11),
},
}

Expand Down
3 changes: 3 additions & 0 deletions models/server_params.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions models/server_params_compare.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions models/server_params_compare_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions specification/build/haproxy_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ definitions:
inter:
type: integer
x-nullable: true
log-bufsize:
type: integer
x-nullable: true
log_proto:
enum:
- legacy
Expand Down
3 changes: 3 additions & 0 deletions specification/models/configuration/server_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e8501a

Please sign in to comment.