Skip to content

Commit ed654ed

Browse files
Merge pull request #2370 from ngopalak-redhat/ngopalak/OCPNODE-3372_defaultRuntime
OCPNODE-3372: Update defaultRuntime doc to show options and set default to crun
2 parents 4a5da13 + 3ae73f9 commit ed654ed

File tree

6 files changed

+186
-9
lines changed

6 files changed

+186
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "ContainerRuntimeConfig"
3+
crdName: containerruntimeconfigs.machineconfiguration.openshift.io
4+
tests:
5+
onCreate:
6+
- name: Should fail if set to empty string
7+
initial: |
8+
apiVersion: machineconfiguration.openshift.io/v1
9+
kind: ContainerRuntimeConfig
10+
spec:
11+
containerRuntimeConfig:
12+
defaultRuntime: ""
13+
expectedError: "spec.containerRuntimeConfig.defaultRuntime: Unsupported value: \"\": supported values: \"crun\", \"runc\""
14+
- name: Should not fail if not set and other fields set
15+
initial: |
16+
apiVersion: machineconfiguration.openshift.io/v1
17+
kind: ContainerRuntimeConfig
18+
spec:
19+
containerRuntimeConfig:
20+
logLevel: info
21+
expected: |
22+
apiVersion: machineconfiguration.openshift.io/v1
23+
kind: ContainerRuntimeConfig
24+
spec:
25+
containerRuntimeConfig:
26+
logLevel: info
27+
- name: Should fail if set to a number
28+
initial: |
29+
apiVersion: machineconfiguration.openshift.io/v1
30+
kind: ContainerRuntimeConfig
31+
spec:
32+
containerRuntimeConfig:
33+
defaultRuntime: 1234
34+
expectedError: "spec.containerRuntimeConfig.defaultRuntime: Invalid value: \"integer\": spec.containerRuntimeConfig.defaultRuntime in body must be of type string: \"integer\", spec.containerRuntimeConfig.defaultRuntime: Unsupported value: 1234: supported values: \"crun\", \"runc\""
35+
- name: Should fail if set to a blank string
36+
initial: |
37+
apiVersion: machineconfiguration.openshift.io/v1
38+
kind: ContainerRuntimeConfig
39+
spec:
40+
containerRuntimeConfig:
41+
defaultRuntime: " "
42+
expectedError: "Unsupported value: \" \": supported values: \"crun\", \"runc\""
43+
- name: Should fail if invalid ContainerRuntimeConfig is provided
44+
initial: |
45+
apiVersion: machineconfiguration.openshift.io/v1
46+
kind: ContainerRuntimeConfig
47+
spec:
48+
containerRuntimeConfig:
49+
defaultRuntime: docker
50+
expectedError: "Unsupported value: \"docker\": supported values: \"crun\", \"runc\""
51+
- name: Should be able to set crun in ContainerRuntimeConfig
52+
initial: |
53+
apiVersion: machineconfiguration.openshift.io/v1
54+
kind: ContainerRuntimeConfig
55+
spec:
56+
containerRuntimeConfig:
57+
defaultRuntime: crun
58+
expected: |
59+
apiVersion: machineconfiguration.openshift.io/v1
60+
kind: ContainerRuntimeConfig
61+
spec:
62+
containerRuntimeConfig:
63+
defaultRuntime: crun
64+
- name: Should be able to set runc in ContainerRuntimeConfig with other params
65+
initial: |
66+
apiVersion: machineconfiguration.openshift.io/v1
67+
kind: ContainerRuntimeConfig
68+
spec:
69+
containerRuntimeConfig:
70+
defaultRuntime: runc
71+
logLevel: info
72+
expected: |
73+
apiVersion: machineconfiguration.openshift.io/v1
74+
kind: ContainerRuntimeConfig
75+
spec:
76+
containerRuntimeConfig:
77+
defaultRuntime: runc
78+
logLevel: info
79+
onUpdate:
80+
- name: Case 1 - Change another field - Should be able to update other parameters with invalid defaultRuntime
81+
initialCRDPatches:
82+
- op: remove
83+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum
84+
initial: |
85+
apiVersion: machineconfiguration.openshift.io/v1
86+
kind: ContainerRuntimeConfig
87+
spec:
88+
containerRuntimeConfig:
89+
defaultRuntime: docker
90+
logLevel: fatal
91+
updated: |
92+
apiVersion: machineconfiguration.openshift.io/v1
93+
kind: ContainerRuntimeConfig
94+
spec:
95+
containerRuntimeConfig:
96+
defaultRuntime: docker
97+
logLevel: info
98+
expected: |
99+
apiVersion: machineconfiguration.openshift.io/v1
100+
kind: ContainerRuntimeConfig
101+
spec:
102+
containerRuntimeConfig:
103+
defaultRuntime: docker
104+
logLevel: info
105+
- name: Case 2 - Remove the field - Should be able to update from invalid to removed
106+
initialCRDPatches:
107+
- op: remove
108+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum
109+
initial: |
110+
apiVersion: machineconfiguration.openshift.io/v1
111+
kind: ContainerRuntimeConfig
112+
spec:
113+
containerRuntimeConfig:
114+
defaultRuntime: docker
115+
updated: |
116+
apiVersion: machineconfiguration.openshift.io/v1
117+
kind: ContainerRuntimeConfig
118+
spec:
119+
containerRuntimeConfig: {}
120+
expected: |
121+
apiVersion: machineconfiguration.openshift.io/v1
122+
kind: ContainerRuntimeConfig
123+
spec:
124+
containerRuntimeConfig: {}
125+
- name: Case 3 - Update the field - Should be able to update from invalid to correct value
126+
initialCRDPatches:
127+
- op: remove
128+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/containerRuntimeConfig/properties/defaultRuntime/enum
129+
initial: |
130+
apiVersion: machineconfiguration.openshift.io/v1
131+
kind: ContainerRuntimeConfig
132+
spec:
133+
containerRuntimeConfig:
134+
defaultRuntime: docker
135+
updated: |
136+
apiVersion: machineconfiguration.openshift.io/v1
137+
kind: ContainerRuntimeConfig
138+
spec:
139+
containerRuntimeConfig:
140+
defaultRuntime: runc
141+
expected: |
142+
apiVersion: machineconfiguration.openshift.io/v1
143+
kind: ContainerRuntimeConfig
144+
spec:
145+
containerRuntimeConfig:
146+
defaultRuntime: runc

machineconfiguration/v1/types.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,18 +844,25 @@ type ContainerRuntimeConfiguration struct {
844844
// +optional
845845
OverlaySize *resource.Quantity `json:"overlaySize,omitempty"`
846846

847-
// defaultRuntime is the name of the OCI runtime to be used as the default.
847+
// defaultRuntime is the name of the OCI runtime to be used as the default for containers.
848+
// Allowed values are `runc` and `crun`.
849+
// When set to `runc`, OpenShift will use runc to execute the container
850+
// When set to `crun`, OpenShift will use crun to execute the container
851+
// When omitted, this means no opinion and the platform is left to choose a reasonable default,
852+
// which is subject to change over time. Currently, the default is `crun`.
853+
// +kubebuilder:validation:Enum=crun;runc
848854
// +optional
849855
DefaultRuntime ContainerRuntimeDefaultRuntime `json:"defaultRuntime,omitempty"`
850856
}
851857

852858
type ContainerRuntimeDefaultRuntime string
853859

860+
// These constants are used in the Machine Config Operator (MCO)
854861
const (
855862
ContainerRuntimeDefaultRuntimeEmpty = ""
856863
ContainerRuntimeDefaultRuntimeRunc = "runc"
857864
ContainerRuntimeDefaultRuntimeCrun = "crun"
858-
ContainerRuntimeDefaultRuntimeDefault = ContainerRuntimeDefaultRuntimeRunc
865+
ContainerRuntimeDefaultRuntimeDefault = ContainerRuntimeDefaultRuntimeCrun
859866
)
860867

861868
// ContainerRuntimeConfigStatus defines the observed state of a ContainerRuntimeConfig

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ spec:
5353
runtime.
5454
properties:
5555
defaultRuntime:
56-
description: defaultRuntime is the name of the OCI runtime to
57-
be used as the default.
56+
description: |-
57+
defaultRuntime is the name of the OCI runtime to be used as the default for containers.
58+
Allowed values are `runc` and `crun`.
59+
When set to `runc`, OpenShift will use runc to execute the container
60+
When set to `crun`, OpenShift will use crun to execute the container
61+
When omitted, this means no opinion and the platform is left to choose a reasonable default,
62+
which is subject to change over time. Currently, the default is `crun`.
63+
enum:
64+
- crun
65+
- runc
5866
type: string
5967
logLevel:
6068
description: |-

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ spec:
5454
runtime.
5555
properties:
5656
defaultRuntime:
57-
description: defaultRuntime is the name of the OCI runtime to
58-
be used as the default.
57+
description: |-
58+
defaultRuntime is the name of the OCI runtime to be used as the default for containers.
59+
Allowed values are `runc` and `crun`.
60+
When set to `runc`, OpenShift will use runc to execute the container
61+
When set to `crun`, OpenShift will use crun to execute the container
62+
When omitted, this means no opinion and the platform is left to choose a reasonable default,
63+
which is subject to change over time. Currently, the default is `crun`.
64+
enum:
65+
- crun
66+
- runc
5967
type: string
6068
logLevel:
6169
description: |-

machineconfiguration/v1/zz_generated.swagger_doc_generated.go

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

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ spec:
5353
runtime.
5454
properties:
5555
defaultRuntime:
56-
description: defaultRuntime is the name of the OCI runtime to
57-
be used as the default.
56+
description: |-
57+
defaultRuntime is the name of the OCI runtime to be used as the default for containers.
58+
Allowed values are `runc` and `crun`.
59+
When set to `runc`, OpenShift will use runc to execute the container
60+
When set to `crun`, OpenShift will use crun to execute the container
61+
When omitted, this means no opinion and the platform is left to choose a reasonable default,
62+
which is subject to change over time. Currently, the default is `crun`.
63+
enum:
64+
- crun
65+
- runc
5866
type: string
5967
logLevel:
6068
description: |-

0 commit comments

Comments
 (0)