Skip to content

Commit 7eb7ab6

Browse files
Merge pull request #4439 from pmtk/fix-cfg
USHIFT-5282: Fix default config + test
2 parents e87b992 + 8162a0b commit 7eb7ab6

File tree

8 files changed

+119
-133
lines changed

8 files changed

+119
-133
lines changed

cmd/generate-config/config/config-openapi-spec.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,14 @@
269269
"clientFinTimeout": {
270270
"description": "clientFinTimeout defines how long a connection will be held open while\nwaiting for the client response to the server/backend closing the\nconnection.\n\n\nIf unset, the default timeout is 1s",
271271
"type": "string",
272-
"format": "duration"
272+
"format": "duration",
273+
"default": "1s"
273274
},
274275
"clientTimeout": {
275276
"description": "clientTimeout defines how long a connection will be held open while\nwaiting for a client response.\n\n\nIf unset, the default timeout is 30s",
276277
"type": "string",
277-
"format": "duration"
278+
"format": "duration",
279+
"default": "30s"
278280
},
279281
"headerBufferBytes": {
280282
"description": "headerBufferBytes describes how much memory should be reserved\n(in bytes) for IngressController connection sessions.\nNote that this value must be at least 16384 if HTTP/2 is\nenabled for the IngressController (https://tools.ietf.org/html/rfc7540).\nIf this field is empty, the IngressController will use a default value\nof 32768 bytes.\n\n\nSetting this field is generally not recommended as headerBufferBytes\nvalues that are too small may break the IngressController and\nheaderBufferBytes values that are too large could cause the\nIngressController to use significantly more memory than necessary.",
@@ -291,6 +293,7 @@
291293
"healthCheckInterval": {
292294
"description": "healthCheckInterval defines how long the router waits between two consecutive\nhealth checks on its configured backends. This value is applied globally as\na default for all routes, but may be overridden per-route by the route annotation\n\"router.openshift.io/haproxy.health.check.interval\".\n\n\nExpects an unsigned duration string of decimal numbers, each with optional\nfraction and a unit suffix, eg \"300ms\", \"1.5h\" or \"2h45m\".\nValid time units are \"ns\", \"us\" (or \"µs\" U+00B5 or \"μs\" U+03BC), \"ms\", \"s\", \"m\", \"h\".\n\n\nSetting this to less than 5s can cause excess traffic due to too frequent\nTCP health checks and accompanying SYN packet storms. Alternatively, setting\nthis too high can result in increased latency, due to backend servers that are no\nlonger available, but haven't yet been detected as such.\n\n\nAn empty or zero healthCheckInterval means no opinion and IngressController chooses\na default, which is subject to change over time.\nCurrently the default healthCheckInterval value is 5s.\n\n\nCurrently the minimum allowed value is 1s and the maximum allowed value is\n2147483647ms (24.85 days). Both are subject to change over time.",
293295
"type": "string",
296+
"default": "5s",
294297
"pattern": "^(0|([0-9]+(\\.[0-9]+)?(ns|us|µs|μs|ms|s|m|h))+)$"
295298
},
296299
"maxConnections": {
@@ -301,12 +304,14 @@
301304
"serverFinTimeout": {
302305
"description": "serverFinTimeout defines how long a connection will be held open while\nwaiting for the server/backend response to the client closing the\nconnection.\n\n\nIf unset, the default timeout is 1s",
303306
"type": "string",
304-
"format": "duration"
307+
"format": "duration",
308+
"default": "1s"
305309
},
306310
"serverTimeout": {
307311
"description": "serverTimeout defines how long a connection will be held open while\nwaiting for a server/backend response.\n\n\nIf unset, the default timeout is 30s",
308312
"type": "string",
309-
"format": "duration"
313+
"format": "duration",
314+
"default": "30s"
310315
},
311316
"threadCount": {
312317
"description": "threadCount defines the number of threads created per HAProxy process.\nCreating more threads allows each ingress controller pod to handle more\nconnections, at the cost of more system resources being used. HAProxy\ncurrently supports up to 64 threads. If this field is empty, the\nIngressController will use the default value. The current default is 4\nthreads, but this may change in future releases.\n\n\nSetting this field is generally not recommended. Increasing the number\nof HAProxy threads allows ingress controller pods to utilize more CPU\ntime under load, potentially starving other pods if set too high.\nReducing the number of threads may cause the ingress controller to\nperform poorly.",
@@ -318,12 +323,14 @@
318323
"tlsInspectDelay": {
319324
"description": "tlsInspectDelay defines how long the router can hold data to find a\nmatching route.\n\n\nSetting this too short can cause the router to fall back to the default\ncertificate for edge-terminated or reencrypt routes even when a better\nmatching certificate could be used.\n\n\nIf unset, the default inspect delay is 5s",
320325
"type": "string",
321-
"format": "duration"
326+
"format": "duration",
327+
"default": "5s"
322328
},
323329
"tunnelTimeout": {
324330
"description": "tunnelTimeout defines how long a tunnel connection (including\nwebsockets) will be held open while the tunnel is idle.\n\n\nIf unset, the default timeout is 1h",
325331
"type": "string",
326-
"format": "duration"
332+
"format": "duration",
333+
"default": "1h"
327334
}
328335
}
329336
}

cmd/generate-config/parser.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6+
"strings"
67

78
"gopkg.in/yaml.v3"
89
v1ext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
@@ -81,7 +82,7 @@ func (p crdParser) toYamlNodeObject(val map[string]v1ext.JSONSchemaProps) *yaml.
8182
}
8283

8384
if !p.NoComments {
84-
keyNode.HeadComment = field.Description
85+
keyNode.HeadComment = strings.ReplaceAll(field.Description, "\n\n\n", "\n#\n")
8586
}
8687

8788
var valueNode *yaml.Node
@@ -134,9 +135,12 @@ func (p crdParser) toYamlNodeArray(val *v1ext.JSONSchemaPropsOrArray) *yaml.Node
134135
case jsonTypeArray:
135136
valueNode = p.toYamlNodeArray(val.Schema.Items)
136137
default:
137-
valueNode = p.toYamlNodeValue(*val.Schema)
138+
// No default to avoid arrays ending up [""].
139+
// Instead, they'll appear as [].
140+
}
141+
if valueNode != nil {
142+
node.Content = append(node.Content, valueNode)
138143
}
139-
node.Content = append(node.Content, valueNode)
140144

141145
return node
142146
}

docs/user/howto_config.md

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ apiServer:
1717
namedCertificates:
1818
- certPath: ""
1919
keyPath: ""
20-
names:
21-
- ""
22-
subjectAltNames:
23-
- ""
20+
names: []
21+
subjectAltNames: []
2422
tls:
25-
cipherSuites:
26-
- ""
23+
cipherSuites: []
2724
minVersion: ""
2825
debugging:
2926
logLevel: ""
@@ -35,11 +32,9 @@ ingress:
3532
defaultHTTPVersion: 0
3633
forwardedHeaderPolicy: ""
3734
httpCompression:
38-
mimeTypes:
39-
- ""
35+
mimeTypes: []
4036
httpEmptyRequestsPolicy: ""
41-
listenAddress:
42-
- ""
37+
listenAddress: []
4338
logEmptyRequests: ""
4439
ports:
4540
http: 0
@@ -61,23 +56,19 @@ ingress:
6156
tunnelTimeout: ""
6257
kubelet:
6358
manifests:
64-
kustomizePaths:
65-
- ""
59+
kustomizePaths: []
6660
network:
67-
clusterNetwork:
68-
- ""
61+
clusterNetwork: []
6962
cniPlugin: ""
70-
serviceNetwork:
71-
- ""
63+
serviceNetwork: []
7264
serviceNodePortRange: ""
7365
node:
7466
hostnameOverride: ""
7567
nodeIP: ""
7668
nodeIPv6: ""
7769
storage:
7870
driver: ""
79-
optionalCsiComponents:
80-
- ""
71+
optionalCsiComponents: []
8172

8273
```
8374
<!---
@@ -102,13 +93,10 @@ apiServer:
10293
namedCertificates:
10394
- certPath: ""
10495
keyPath: ""
105-
names:
106-
- ""
107-
subjectAltNames:
108-
- ""
96+
names: []
97+
subjectAltNames: []
10998
tls:
110-
cipherSuites:
111-
- ""
99+
cipherSuites: []
112100
minVersion: VersionTLS12
113101
debugging:
114102
logLevel: Normal
@@ -120,11 +108,9 @@ ingress:
120108
defaultHTTPVersion: 1
121109
forwardedHeaderPolicy: ""
122110
httpCompression:
123-
mimeTypes:
124-
- ""
111+
mimeTypes: []
125112
httpEmptyRequestsPolicy: Respond
126-
listenAddress:
127-
- ""
113+
listenAddress: []
128114
logEmptyRequests: Log
129115
ports:
130116
http: 80
@@ -133,17 +119,17 @@ ingress:
133119
namespaceOwnership: InterNamespaceAllowed
134120
status: Managed
135121
tuningOptions:
136-
clientFinTimeout: ""
137-
clientTimeout: ""
122+
clientFinTimeout: 1s
123+
clientTimeout: 30s
138124
headerBufferBytes: 0
139125
headerBufferMaxRewriteBytes: 0
140-
healthCheckInterval: ""
126+
healthCheckInterval: 5s
141127
maxConnections: 0
142-
serverFinTimeout: ""
143-
serverTimeout: ""
128+
serverFinTimeout: 1s
129+
serverTimeout: 30s
144130
threadCount: 0
145-
tlsInspectDelay: ""
146-
tunnelTimeout: ""
131+
tlsInspectDelay: 5s
132+
tunnelTimeout: 1h
147133
kubelet:
148134
manifests:
149135
kustomizePaths:
@@ -164,8 +150,7 @@ node:
164150
nodeIPv6: ""
165151
storage:
166152
driver: ""
167-
optionalCsiComponents:
168-
- ""
153+
optionalCsiComponents: []
169154

170155
```
171156
<!---

0 commit comments

Comments
 (0)