Skip to content

Commit e816e63

Browse files
committed
CNTRLPLANE-1576: add event-ttl configuration to kube-apiserver
This adds a minute/hour configuration duration to configure the event ttl setting in kube-apiserver. Default will stay 3h, as currently defined in KAS-O. Signed-off-by: Thomas Jungblut <[email protected]>
1 parent 230d0e0 commit e816e63

File tree

10 files changed

+158
-1
lines changed

10 files changed

+158
-1
lines changed

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/openapi.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30290,6 +30290,11 @@
3029030290
"forceRedeploymentReason"
3029130291
],
3029230292
"properties": {
30293+
"eventTTL": {
30294+
"description": "eventTTL specifies the amount of time that the events are stored before being deleted.\n\nThe value must be parseable as a time duration value; see <https://pkg.go.dev/time#ParseDuration>.\n\nIf configured, it must be a value of 1m (one minute) or greater, we only allow setting minute and hour durations (e.g. 5m or 5h).\n\nThe default value is 3h.",
30295+
"default": "3h",
30296+
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Duration"
30297+
},
3029330298
"failedRevisionLimit": {
3029430299
"description": "failedRevisionLimit is the number of failed static pod installer revisions to keep on disk and in the api -1 = unlimited, 0 or unset = 5 (default)",
3029530300
"type": "integer",

operator/v1/tests/kubeapiservers.operator.openshift.io/AAA_ungated.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tests:
1414
spec:
1515
logLevel: Normal
1616
operatorLogLevel: Normal
17+
eventTTL: "3h"
1718
onUpdate:
1819
- name: Should reject multiple nodes with nonzero target revisions
1920
initialCRDPatches:
@@ -140,6 +141,7 @@ tests:
140141
spec:
141142
logLevel: Normal
142143
operatorLogLevel: Normal
144+
eventTTL: "3h"
143145
status:
144146
nodeStatuses:
145147
- nodeName: a
@@ -166,6 +168,7 @@ tests:
166168
spec:
167169
logLevel: Normal
168170
operatorLogLevel: Normal
171+
eventTTL: "3h"
169172
status:
170173
nodeStatuses:
171174
- nodeName: a
@@ -192,6 +195,7 @@ tests:
192195
spec:
193196
logLevel: Normal
194197
operatorLogLevel: Normal
198+
eventTTL: "3h"
195199
status:
196200
nodeStatuses:
197201
- nodeName: a
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "KubeAPIServer"
3+
crdName: kubeapiservers.operator.openshift.io
4+
tests:
5+
onCreate:
6+
- name: Should be able to create default event ttl
7+
initial: |
8+
apiVersion: operator.openshift.io/v1
9+
kind: KubeAPIServer
10+
spec: {} # No spec is required for a KubeAPIServer
11+
expected: |
12+
apiVersion: operator.openshift.io/v1
13+
kind: KubeAPIServer
14+
spec:
15+
logLevel: Normal
16+
operatorLogLevel: Normal
17+
eventTTL: "3h"
18+
- name: Should be able to create a normal hour event ttl
19+
initial: |
20+
apiVersion: operator.openshift.io/v1
21+
kind: KubeAPIServer
22+
spec:
23+
eventTTL: "1h"
24+
expected: |
25+
apiVersion: operator.openshift.io/v1
26+
kind: KubeAPIServer
27+
spec:
28+
logLevel: Normal
29+
operatorLogLevel: Normal
30+
eventTTL: "1h"
31+
- name: Should be able to create a normal minute event ttl
32+
initial: |
33+
apiVersion: operator.openshift.io/v1
34+
kind: KubeAPIServer
35+
spec:
36+
eventTTL: "15m"
37+
expected: |
38+
apiVersion: operator.openshift.io/v1
39+
kind: KubeAPIServer
40+
spec:
41+
logLevel: Normal
42+
operatorLogLevel: Normal
43+
eventTTL: "15m"
44+
- name: Should not be able to create with seconds resolution
45+
initial: |
46+
apiVersion: operator.openshift.io/v1
47+
kind: KubeAPIServer
48+
metadata:
49+
name: gg1
50+
spec:
51+
eventTTL: "50s"
52+
expectedError: "spec.eventTTL in body should match"
53+
- name: Should not be able to create with day resolution
54+
initial: |
55+
apiVersion: operator.openshift.io/v1
56+
kind: KubeAPIServer
57+
metadata:
58+
name: gg1
59+
spec:
60+
eventTTL: "5d"
61+
expectedError: "spec.eventTTL in body should match"
62+
- name: Should not be able to create with year resolution
63+
initial: |
64+
apiVersion: operator.openshift.io/v1
65+
kind: KubeAPIServer
66+
metadata:
67+
name: gg2
68+
spec:
69+
eventTTL: "5y"
70+
expectedError: "spec.eventTTL in body should match"

operator/v1/types_kubeapiserver.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ type KubeAPIServer struct {
3535

3636
type KubeAPIServerSpec struct {
3737
StaticPodOperatorSpec `json:",inline"`
38+
39+
// eventTTL specifies the amount of time that the events are stored before being deleted.
40+
//
41+
// The value must be parseable as a time duration value;
42+
// see <https://pkg.go.dev/time#ParseDuration>.
43+
//
44+
// If configured, it must be a value of 1m (one minute) or greater, we only allow setting
45+
// minute and hour durations (e.g. 5m or 5h).
46+
//
47+
// The default value is 3h.
48+
//
49+
// +kubebuilder:validation:Format=duration
50+
// +kubebuilder:validation:Pattern=^(0|([0-9]+(\.[0-9]+)?(m|h))+)$
51+
// +kubebuilder:validation:Type:=string
52+
// +default="3h"
53+
// +optional
54+
EventTTL metav1.Duration `json:"eventTTL,omitempty"`
3855
}
3956

4057
type KubeAPIServerStatus struct {

operator/v1/zz_generated.crd-manifests/0000_20_kube-apiserver_01_kubeapiservers.crd.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ spec:
4747
description: spec is the specification of the desired behavior of the
4848
Kubernetes API Server
4949
properties:
50+
eventTTL:
51+
default: 3h
52+
description: |-
53+
eventTTL specifies the amount of time that the events are stored before being deleted.
54+
55+
The value must be parseable as a time duration value;
56+
see <https://pkg.go.dev/time#ParseDuration>.
57+
58+
If configured, it must be a value of 1m (one minute) or greater, we only allow setting
59+
minute and hour durations (e.g. 5m or 5h).
60+
61+
The default value is 3h.
62+
format: duration
63+
pattern: ^(0|([0-9]+(\.[0-9]+)?(m|h))+)$
64+
type: string
5065
failedRevisionLimit:
5166
description: |-
5267
failedRevisionLimit is the number of failed static pod installer revisions to keep on disk and in the api

operator/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/v1/zz_generated.featuregated-crd-manifests/kubeapiservers.operator.openshift.io/AAA_ungated.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ spec:
4848
description: spec is the specification of the desired behavior of the
4949
Kubernetes API Server
5050
properties:
51+
eventTTL:
52+
default: 3h
53+
description: |-
54+
eventTTL specifies the amount of time that the events are stored before being deleted.
55+
56+
The value must be parseable as a time duration value;
57+
see <https://pkg.go.dev/time#ParseDuration>.
58+
59+
If configured, it must be a value of 1m (one minute) or greater, we only allow setting
60+
minute and hour durations (e.g. 5m or 5h).
61+
62+
The default value is 3h.
63+
format: duration
64+
pattern: ^(0|([0-9]+(\.[0-9]+)?(m|h))+)$
65+
type: string
5166
failedRevisionLimit:
5267
description: |-
5368
failedRevisionLimit is the number of failed static pod installer revisions to keep on disk and in the api

operator/v1/zz_generated.swagger_doc_generated.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

payload-manifests/crds/0000_20_kube-apiserver_01_kubeapiservers.crd.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ spec:
4747
description: spec is the specification of the desired behavior of the
4848
Kubernetes API Server
4949
properties:
50+
eventTTL:
51+
default: 3h
52+
description: |-
53+
eventTTL specifies the amount of time that the events are stored before being deleted.
54+
55+
The value must be parseable as a time duration value;
56+
see <https://pkg.go.dev/time#ParseDuration>.
57+
58+
If configured, it must be a value of 1m (one minute) or greater, we only allow setting
59+
minute and hour durations (e.g. 5m or 5h).
60+
61+
The default value is 3h.
62+
format: duration
63+
pattern: ^(0|([0-9]+(\.[0-9]+)?(m|h))+)$
64+
type: string
5065
failedRevisionLimit:
5166
description: |-
5267
failedRevisionLimit is the number of failed static pod installer revisions to keep on disk and in the api

0 commit comments

Comments
 (0)