diff --git a/configuration/configuration_test.go b/configuration/configuration_test.go index 1c1e487d..19518648 100644 --- a/configuration/configuration_test.go +++ b/configuration/configuration_test.go @@ -53,6 +53,7 @@ global tune.bufsize 13 tune.comp.maxlevel 14 tune.disable-zero-copy-forwarding + tune.events.max-events-at-once 10 tune.fail-alloc tune.fd.edge-triggered on tune.h2.header-table-size 15 diff --git a/configuration/global.go b/configuration/global.go index 4f70dd27..f082ee10 100644 --- a/configuration/global.go +++ b/configuration/global.go @@ -2358,6 +2358,9 @@ func serializeTuneOptions(p parser.Parser, options *models.GlobalTuneOptions) er if err := serializeBoolOption(p, "tune.disable-zero-copy-forwarding", options.DisableZeroCopyForwarding); err != nil { return err } + if err := serializeInt64Option(p, "tune.events.max-events-at-once", options.EventsMaxEventsAtOnce); err != nil { + return err + } if err := serializeBoolOption(p, "tune.fail-alloc", options.FailAlloc); err != nil { return err } @@ -2757,6 +2760,12 @@ func parseTuneOptions(p parser.Parser) (*models.GlobalTuneOptions, error) { //no } options.DisableZeroCopyForwarding = boolOption + intOption, err = parseInt64Option(p, "tune.events.max-events-at-once") + if err != nil { + return nil, err + } + options.EventsMaxEventsAtOnce = intOption + boolOption, err = parseBoolOption(p, "tune.fail-alloc") if err != nil { return nil, err diff --git a/configuration/global_test.go b/configuration/global_test.go index f0b5f09f..468903a1 100644 --- a/configuration/global_test.go +++ b/configuration/global_test.go @@ -291,6 +291,9 @@ func TestGetGlobal(t *testing.T) { if !global.TuneOptions.DisableZeroCopyForwarding { t.Errorf("DisableZeroCopyForwarding is %v, expected true", global.TuneOptions.DisableZeroCopyForwarding) } + if global.TuneOptions.EventsMaxEventsAtOnce != 10 { + t.Errorf("TuneOptions.EventsMaxEventsAtOnce is %v, expected 10", global.TuneOptions.EventsMaxEventsAtOnce) + } if global.TuneOptions.H2HeaderTableSize != 15 { t.Errorf("H2HeaderTableSize is %v, expected 15", global.TuneOptions.H2HeaderTableSize) } @@ -727,6 +730,7 @@ func TestPutGlobal(t *testing.T) { }, TuneOptions: &models.GlobalTuneOptions{ DisableZeroCopyForwarding: true, + EventsMaxEventsAtOnce: 50, LuaLogLoggers: "disabled", LuaLogStderr: "disabled", MaxChecksPerThread: misc.Int64P(20), diff --git a/models/global.go b/models/global.go index a6629709..0abd7174 100644 --- a/models/global.go +++ b/models/global.go @@ -3063,6 +3063,11 @@ type GlobalTuneOptions struct { // disable zero copy forwarding DisableZeroCopyForwarding bool `json:"disable_zero_copy_forwarding,omitempty"` + // events max events at once + // Maximum: 10000 + // Minimum: 1 + EventsMaxEventsAtOnce int64 `json:"events_max_events_at_once,omitempty"` + // fail alloc FailAlloc bool `json:"fail_alloc,omitempty"` @@ -3300,6 +3305,10 @@ func (m *GlobalTuneOptions) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateEventsMaxEventsAtOnce(formats); err != nil { + res = append(res, err) + } + if err := m.validateFdEdgeTriggered(formats); err != nil { res = append(res, err) } @@ -3374,6 +3383,22 @@ func (m *GlobalTuneOptions) validateBuffersReserve(formats strfmt.Registry) erro return nil } +func (m *GlobalTuneOptions) validateEventsMaxEventsAtOnce(formats strfmt.Registry) error { + if swag.IsZero(m.EventsMaxEventsAtOnce) { // not required + return nil + } + + if err := validate.MinimumInt("tune_options"+"."+"events_max_events_at_once", "body", m.EventsMaxEventsAtOnce, 1, false); err != nil { + return err + } + + if err := validate.MaximumInt("tune_options"+"."+"events_max_events_at_once", "body", m.EventsMaxEventsAtOnce, 10000, false); err != nil { + return err + } + + return nil +} + var globalTuneOptionsTypeFdEdgeTriggeredPropEnum []interface{} func init() { diff --git a/models/global_compare.go b/models/global_compare.go index f382f664..9a117c12 100644 --- a/models/global_compare.go +++ b/models/global_compare.go @@ -2014,6 +2014,10 @@ func (s GlobalTuneOptions) Equal(t GlobalTuneOptions, opts ...Options) bool { return false } + if s.EventsMaxEventsAtOnce != t.EventsMaxEventsAtOnce { + return false + } + if s.FailAlloc != t.FailAlloc { return false } @@ -2325,6 +2329,10 @@ func (s GlobalTuneOptions) Diff(t GlobalTuneOptions, opts ...Options) map[string diff["DisableZeroCopyForwarding"] = []interface{}{s.DisableZeroCopyForwarding, t.DisableZeroCopyForwarding} } + if s.EventsMaxEventsAtOnce != t.EventsMaxEventsAtOnce { + diff["EventsMaxEventsAtOnce"] = []interface{}{s.EventsMaxEventsAtOnce, t.EventsMaxEventsAtOnce} + } + if s.FailAlloc != t.FailAlloc { diff["FailAlloc"] = []interface{}{s.FailAlloc, t.FailAlloc} } diff --git a/models/global_compare_test.go b/models/global_compare_test.go index 6a448144..2870e238 100644 --- a/models/global_compare_test.go +++ b/models/global_compare_test.go @@ -2718,6 +2718,7 @@ func TestGlobalTuneOptionsEqualFalse(t *testing.T) { result.Bufsize = sample.Bufsize + 1 result.CompMaxlevel = sample.CompMaxlevel + 1 result.DisableZeroCopyForwarding = !sample.DisableZeroCopyForwarding + result.EventsMaxEventsAtOnce = sample.EventsMaxEventsAtOnce + 1 result.FailAlloc = !sample.FailAlloc result.H2BeInitialWindowSize = sample.H2BeInitialWindowSize + 1 result.H2BeMaxConcurrentStreams = sample.H2BeMaxConcurrentStreams + 1 @@ -2863,6 +2864,7 @@ func TestGlobalTuneOptionsDiffFalse(t *testing.T) { result.Bufsize = sample.Bufsize + 1 result.CompMaxlevel = sample.CompMaxlevel + 1 result.DisableZeroCopyForwarding = !sample.DisableZeroCopyForwarding + result.EventsMaxEventsAtOnce = sample.EventsMaxEventsAtOnce + 1 result.FailAlloc = !sample.FailAlloc result.H2BeInitialWindowSize = sample.H2BeInitialWindowSize + 1 result.H2BeMaxConcurrentStreams = sample.H2BeMaxConcurrentStreams + 1 @@ -2931,7 +2933,7 @@ func TestGlobalTuneOptionsDiffFalse(t *testing.T) { for _, sample := range samples { result := sample.a.Diff(sample.b) - if len(result) != 75 { + if len(result) != 76 { json := jsoniter.ConfigCompatibleWithStandardLibrary a, err := json.Marshal(&sample.a) if err != nil { @@ -2941,7 +2943,7 @@ func TestGlobalTuneOptionsDiffFalse(t *testing.T) { if err != nil { t.Errorf(err.Error()) } - t.Errorf("Expected GlobalTuneOptions to be different in 75 cases, but it is not (%d) %s %s", len(result), a, b) + t.Errorf("Expected GlobalTuneOptions to be different in 76 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 d56fe682..73035e08 100644 --- a/specification/build/haproxy_spec.yaml +++ b/specification/build/haproxy_spec.yaml @@ -1590,6 +1590,10 @@ definitions: disable_zero_copy_forwarding: type: boolean x-display-name: Disable zero-copy forwarding + events_max_events_at_once: + maximum: 10000 + minimum: 1 + type: integer fail_alloc: type: boolean x-display-name: Failed Allocation Chance diff --git a/specification/models/configuration/global.yaml b/specification/models/configuration/global.yaml index 06533b0b..474640ce 100644 --- a/specification/models/configuration/global.yaml +++ b/specification/models/configuration/global.yaml @@ -300,6 +300,10 @@ global: disable_zero_copy_forwarding: type: boolean x-display-name: Disable zero-copy forwarding + events_max_events_at_once: + type: integer + minimum: 1 + maximum: 10000 fail_alloc: type: boolean x-display-name: Failed Allocation Chance