Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apis/proxy/v1alpha1/instance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ type DefaultsConfiguration struct {
// +kubebuilder:default=http
// +kubebuilder:validation:Enum=http;tcp
Mode string `json:"mode"`
// Maxconn sets the maximum per-process number of concurrent connections for defaults.
// +optional
Maxconn *int64 `json:"maxconn,omitempty"`
// ErrorFiles custom error files to be used
// +optional
ErrorFiles []*configv1alpha1.ErrorFile `json:"errorFiles,omitempty"`
Expand Down Expand Up @@ -692,6 +695,7 @@ func (d *DefaultsConfiguration) Model() (models.Defaults, error) {

defaults.Name = defaultsSectionName
defaults.Mode = d.Mode
defaults.Maxconn = d.Maxconn

for name, timeout := range d.Timeouts {
switch name {
Expand Down
46 changes: 46 additions & 0 deletions apis/proxy/v1alpha1/instance_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,49 @@ func TestDefaultsConfigurationAddToParserWithRetries(t *testing.T) {
t.Fatalf("expected config to contain retries 5, got:\n%s", cfg)
}
}

func TestDefaultsConfigurationModelWithMaxconn(t *testing.T) {
d := &DefaultsConfiguration{
Mode: "http",
Maxconn: ptr.To(int64(2000)),
Timeouts: map[string]metav1.Duration{
"client": {Duration: 5 * time.Second},
"connect": {Duration: 5 * time.Second},
"server": {Duration: 10 * time.Second},
},
}

model, err := d.Model()
if err != nil {
t.Fatalf("Model() returned error: %v", err)
}

if model.Maxconn == nil || *model.Maxconn != 2000 {
t.Fatalf("expected maxconn 2000, got %#v", model.Maxconn)
}
}

func TestDefaultsConfigurationAddToParserWithMaxconn(t *testing.T) {
d := &DefaultsConfiguration{
Mode: "http",
Maxconn: ptr.To(int64(2000)),
Timeouts: map[string]metav1.Duration{
"client": {Duration: 5 * time.Second},
"connect": {Duration: 5 * time.Second},
"server": {Duration: 10 * time.Second},
},
}

p, err := parser.New()
if err != nil {
t.Fatalf("parser.New() returned error: %v", err)
}

if err := d.AddToParser(p); err != nil {
t.Fatalf("AddToParser() returned error: %v", err)
}

if !strings.Contains(p.String(), "maxconn 2000") {
t.Fatalf("expected generated config to contain maxconn 2000, got:\n%s", p.String())
}
}
5 changes: 5 additions & 0 deletions apis/proxy/v1alpha1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,7 @@ _Appears in:_
| Field | Description | Default | Validation |
| --- | --- | --- | --- |
| `mode` _string_ | Mode can be either 'tcp' or 'http'. In tcp mode it is a layer 4 proxy. In http mode it is a layer 7 proxy. | http | Enum: [http tcp] <br /> |
| `maxconn` _integer_ | Maxconn sets the maximum per-process number of concurrent connections for defaults. | | Optional: \{\} <br /> |
| `errorFiles` _[ErrorFile](#errorfile) array_ | ErrorFiles custom error files to be used | | Optional: \{\} <br /> |
| `timeouts` _object (keys:string, values:[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#duration-v1-meta))_ | Timeouts: check, client, client-fin, connect, http-keep-alive, http-request, queue, server, server-fin, tunnel.<br />The timeout value specified in milliseconds by default, but can be in any other unit if the number is suffixed by the unit.<br />More info: https://cbonte.github.io/haproxy-dconv/2.6/configuration.html | \{ client:5s connect:5s server:10s \} | |
| `retries` _integer_ | Retries sets the maximum number of retries on a connection failure. | | Minimum: 1 <br />Optional: \{\} <br /> |
Expand Down
5 changes: 5 additions & 0 deletions helm/haproxy-operator/crds/proxy.haproxy.com_instances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ spec:
format: int64
minimum: 1
type: integer
maxconn:
description: Maxconn sets the maximum per-process number
of concurrent connections for defaults.
format: int64
type: integer
timeouts:
additionalProperties:
type: string
Expand Down
Loading