Skip to content

Commit 3cc10b2

Browse files
OCPNODE-3372: Remove omitempty from defaultRuntime as its handled in MCO with additional test cases
1 parent f52b842 commit 3cc10b2

File tree

6 files changed

+63
-7
lines changed

6 files changed

+63
-7
lines changed

machineconfiguration/v1/tests/containerruntimeconfigs.machineconfiguration.openshift.io/AAA_ungated.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "ContainerRuntimeConfig"
33
crdName: containerruntimeconfigs.machineconfiguration.openshift.io
44
tests:
55
onCreate:
6-
- name: Should be able to create a minimal ContainerRuntimeConfig
6+
- name: Should be able to create a minimal ContainerRuntimeConfig and default runtime set
77
initial: |
88
apiVersion: machineconfiguration.openshift.io/v1
99
kind: ContainerRuntimeConfig
@@ -13,4 +13,5 @@ tests:
1313
apiVersion: machineconfiguration.openshift.io/v1
1414
kind: ContainerRuntimeConfig
1515
spec:
16-
containerRuntimeConfig: {}
16+
containerRuntimeConfig:
17+
defaultRuntime: ""

machineconfiguration/v1/tests/containerruntimeconfigs.machineconfiguration.openshift.io/DefaultRuntimeConfig.yaml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ tests:
2828
kind: ContainerRuntimeConfig
2929
spec:
3030
containerRuntimeConfig:
31+
defaultRuntime: ""
3132
logLevel: info
3233
- name: Should fail if set to a number
3334
initial: |
@@ -66,35 +67,85 @@ tests:
6667
spec:
6768
containerRuntimeConfig:
6869
defaultRuntime: crun
69-
- name: Should be able to set runc in ContainerRuntimeConfig
70+
- name: Should be able to set runc in ContainerRuntimeConfig with other params
7071
initial: |
7172
apiVersion: machineconfiguration.openshift.io/v1
7273
kind: ContainerRuntimeConfig
7374
spec:
7475
containerRuntimeConfig:
7576
defaultRuntime: runc
77+
logLevel: info
7678
expected: |
7779
apiVersion: machineconfiguration.openshift.io/v1
7880
kind: ContainerRuntimeConfig
7981
spec:
8082
containerRuntimeConfig:
8183
defaultRuntime: runc
82-
- name: Should be able to set other parameters
84+
logLevel: info
85+
onUpdate:
86+
- name: Should not be able to update from default to invalid value
87+
initialCRDPatches:
88+
- op: remove
89+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum
8390
initial: |
8491
apiVersion: machineconfiguration.openshift.io/v1
8592
kind: ContainerRuntimeConfig
8693
spec:
8794
containerRuntimeConfig:
88-
defaultRuntime: runc
95+
defaultRuntime: ""
96+
logLevel: fatal
97+
updated: |
98+
apiVersion: machineconfiguration.openshift.io/v1
99+
kind: ContainerRuntimeConfig
100+
spec:
101+
containerRuntimeConfig:
102+
defaultRuntime: docker
103+
logLevel: info
104+
expectedError: "Unsupported value: \"docker\": supported values: \"crun\", \"runc\", \"\""
105+
- name: Should be able to update from not set to default when other params are set
106+
initial: |
107+
apiVersion: machineconfiguration.openshift.io/v1
108+
kind: ContainerRuntimeConfig
109+
spec:
110+
containerRuntimeConfig: {}
111+
updated: |
112+
apiVersion: machineconfiguration.openshift.io/v1
113+
kind: ContainerRuntimeConfig
114+
spec:
115+
containerRuntimeConfig:
89116
logLevel: info
90117
expected: |
118+
apiVersion: machineconfiguration.openshift.io/v1
119+
kind: ContainerRuntimeConfig
120+
spec:
121+
containerRuntimeConfig:
122+
defaultRuntime: ""
123+
logLevel: info
124+
- name: Should be able to update from runc to crun with other parameters
125+
initialCRDPatches:
126+
- op: remove
127+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum
128+
initial: |
91129
apiVersion: machineconfiguration.openshift.io/v1
92130
kind: ContainerRuntimeConfig
93131
spec:
94132
containerRuntimeConfig:
95133
defaultRuntime: runc
134+
logLevel: fatal
135+
updated: |
136+
apiVersion: machineconfiguration.openshift.io/v1
137+
kind: ContainerRuntimeConfig
138+
spec:
139+
containerRuntimeConfig:
140+
defaultRuntime: crun
141+
logLevel: info
142+
expected: |
143+
apiVersion: machineconfiguration.openshift.io/v1
144+
kind: ContainerRuntimeConfig
145+
spec:
146+
containerRuntimeConfig:
147+
defaultRuntime: crun
96148
logLevel: info
97-
onUpdate:
98149
- name: Should be able to update other parameters with invalid defaultRuntime
99150
initialCRDPatches:
100151
- op: remove

machineconfiguration/v1/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,9 @@ type ContainerRuntimeConfiguration struct {
851851
// When omitted, this means no opinion and the platform is left to choose a reasonable default,
852852
// which is subject to change over time. Currently, the default is `crun`.
853853
// +kubebuilder:validation:Enum=crun;runc;""
854+
// +kubebuilder:default:=""
854855
// +optional
855-
DefaultRuntime ContainerRuntimeDefaultRuntime `json:"defaultRuntime,omitempty"`
856+
DefaultRuntime ContainerRuntimeDefaultRuntime `json:"defaultRuntime"`
856857
}
857858

858859
type ContainerRuntimeDefaultRuntime string

machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_containerruntimeconfigs.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ spec:
5353
runtime.
5454
properties:
5555
defaultRuntime:
56+
default: ""
5657
description: |-
5758
defaultRuntime is the name of the OCI runtime to be used as the default for containers.
5859
Allowed values are `runc`, `crun`, and omitted (`""`).

machineconfiguration/v1/zz_generated.featuregated-crd-manifests/containerruntimeconfigs.machineconfiguration.openshift.io/AAA_ungated.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ spec:
5454
runtime.
5555
properties:
5656
defaultRuntime:
57+
default: ""
5758
description: |-
5859
defaultRuntime is the name of the OCI runtime to be used as the default for containers.
5960
Allowed values are `runc`, `crun`, and omitted (`""`).

payload-manifests/crds/0000_80_machine-config_01_containerruntimeconfigs.crd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ spec:
5353
runtime.
5454
properties:
5555
defaultRuntime:
56+
default: ""
5657
description: |-
5758
defaultRuntime is the name of the OCI runtime to be used as the default for containers.
5859
Allowed values are `runc`, `crun`, and omitted (`""`).

0 commit comments

Comments
 (0)