Skip to content

Commit 43090db

Browse files
Merge pull request #2709 from pablintino/osimagestream-default-stream
MCO-2126: Add defaultStream field to OSImageStream spec
2 parents 22c7448 + 523451b commit 43090db

11 files changed

Lines changed: 322 additions & 29 deletions

machineconfiguration/v1alpha1/tests/osimagestreams.machineconfiguration.openshift.io/OSStreams.yaml

Lines changed: 132 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ tests:
1919
name: cluster
2020
spec: {}
2121
22+
- name: Should be able to create an OSImageStream with spec.defaultStream
23+
initial: |
24+
apiVersion: machineconfiguration.openshift.io/v1alpha1
25+
kind: OSImageStream
26+
metadata:
27+
name: cluster
28+
spec:
29+
defaultStream: rhel-coreos
30+
expected: |
31+
apiVersion: machineconfiguration.openshift.io/v1alpha1
32+
kind: OSImageStream
33+
metadata:
34+
name: cluster
35+
spec:
36+
defaultStream: rhel-coreos
37+
2238
- name: Should reject a resource not named cluster
2339
initial: |
2440
apiVersion: machineconfiguration.openshift.io/v1alpha1
@@ -28,20 +44,42 @@ tests:
2844
spec: {}
2945
expectedError: "Invalid value: \"object\": osimagestream is a singleton, .metadata.name must be 'cluster'"
3046

47+
- name: Should reject spec.defaultStream with invalid characters
48+
initial: |
49+
apiVersion: machineconfiguration.openshift.io/v1alpha1
50+
kind: OSImageStream
51+
metadata:
52+
name: cluster
53+
spec:
54+
defaultStream: "invalid@stream!"
55+
expectedError: "a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
56+
57+
- name: Should reject spec.defaultStream that is too long
58+
initial: |
59+
apiVersion: machineconfiguration.openshift.io/v1alpha1
60+
kind: OSImageStream
61+
metadata:
62+
name: cluster
63+
spec:
64+
defaultStream: "this-is-a-very-long-stream-name-that-exceeds-the-maximum-allowed-length-of-253-characters-for-rfc1123-subdomain-validation-which-is-used-to-ensure-compatibility-with-dns-and-kubernetes-naming-standards-and-this-string-needs-to-be-even-longer-to-properly-test-the-limit"
65+
expectedError: "spec.defaultStream: Too long: may not be more than 253 bytes"
66+
3167
onUpdate:
3268
- name: Should be able to report a well formatted list of image streams
3369
initial: |
3470
apiVersion: machineconfiguration.openshift.io/v1alpha1
3571
kind: OSImageStream
3672
metadata:
3773
name: cluster
38-
spec: {}
74+
spec:
75+
defaultStream: rhel-coreos
3976
updated: |
4077
apiVersion: machineconfiguration.openshift.io/v1alpha1
4178
kind: OSImageStream
4279
metadata:
4380
name: cluster
44-
spec: {}
81+
spec:
82+
defaultStream: rhel-coreos
4583
status:
4684
defaultStream: "rhel-coreos"
4785
availableStreams:
@@ -56,7 +94,8 @@ tests:
5694
kind: OSImageStream
5795
metadata:
5896
name: cluster
59-
spec: {}
97+
spec:
98+
defaultStream: rhel-coreos
6099
status:
61100
defaultStream: "rhel-coreos"
62101
availableStreams:
@@ -67,19 +106,61 @@ tests:
67106
osImage: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
68107
osExtensionsImage: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e
69108
109+
- name: Should be able to update spec.defaultStream to a different valid value
110+
initial: |
111+
apiVersion: machineconfiguration.openshift.io/v1alpha1
112+
kind: OSImageStream
113+
metadata:
114+
name: cluster
115+
spec:
116+
defaultStream: rhel-coreos
117+
updated: |
118+
apiVersion: machineconfiguration.openshift.io/v1alpha1
119+
kind: OSImageStream
120+
metadata:
121+
name: cluster
122+
spec:
123+
defaultStream: rhel10-coreos
124+
expected: |
125+
apiVersion: machineconfiguration.openshift.io/v1alpha1
126+
kind: OSImageStream
127+
metadata:
128+
name: cluster
129+
spec:
130+
defaultStream: rhel10-coreos
131+
132+
- name: Should reject updating spec.defaultStream to invalid characters
133+
initial: |
134+
apiVersion: machineconfiguration.openshift.io/v1alpha1
135+
kind: OSImageStream
136+
metadata:
137+
name: cluster
138+
spec:
139+
defaultStream: rhel-coreos
140+
updated: |
141+
apiVersion: machineconfiguration.openshift.io/v1alpha1
142+
kind: OSImageStream
143+
metadata:
144+
name: cluster
145+
spec:
146+
defaultStream: "invalid@stream!"
147+
expectedError: "a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
148+
70149
- name: Should reject image URL without digest
71150
initial: |
72151
apiVersion: machineconfiguration.openshift.io/v1alpha1
73152
kind: OSImageStream
74153
metadata:
75154
name: cluster
76-
spec: {}
155+
spec:
156+
defaultStream: rhel-coreos
77157
updated: |
78158
apiVersion: machineconfiguration.openshift.io/v1alpha1
79159
kind: OSImageStream
80160
metadata:
81161
name: cluster
82-
spec: {}
162+
spec:
163+
defaultStream: rhel-coreos
83164
status:
84165
defaultStream: "rhel-coreos"
85166
availableStreams:
@@ -94,13 +175,15 @@ tests:
94175
kind: OSImageStream
95176
metadata:
96177
name: cluster
97-
spec: {}
178+
spec:
179+
defaultStream: rhel-coreos
98180
updated: |
99181
apiVersion: machineconfiguration.openshift.io/v1alpha1
100182
kind: OSImageStream
101183
metadata:
102184
name: cluster
103-
spec: {}
185+
spec:
186+
defaultStream: rhel-coreos
104187
status:
105188
defaultStream: "rhel-coreos"
106189
availableStreams:
@@ -115,13 +198,15 @@ tests:
115198
kind: OSImageStream
116199
metadata:
117200
name: cluster
118-
spec: {}
201+
spec:
202+
defaultStream: rhel-coreos
119203
updated: |
120204
apiVersion: machineconfiguration.openshift.io/v1alpha1
121205
kind: OSImageStream
122206
metadata:
123207
name: cluster
124-
spec: {}
208+
spec:
209+
defaultStream: rhel-coreos
125210
status:
126211
defaultStream: "rhel@coreos!"
127212
availableStreams:
@@ -136,13 +221,15 @@ tests:
136221
kind: OSImageStream
137222
metadata:
138223
name: cluster
139-
spec: {}
224+
spec:
225+
defaultStream: rhel-coreos
140226
updated: |
141227
apiVersion: machineconfiguration.openshift.io/v1alpha1
142228
kind: OSImageStream
143229
metadata:
144230
name: cluster
145-
spec: {}
231+
spec:
232+
defaultStream: rhel-coreos
146233
status:
147234
defaultStream: "rhel-coreos"
148235
availableStreams:
@@ -160,13 +247,15 @@ tests:
160247
kind: OSImageStream
161248
metadata:
162249
name: cluster
163-
spec: {}
250+
spec:
251+
defaultStream: rhel-coreos
164252
updated: |
165253
apiVersion: machineconfiguration.openshift.io/v1alpha1
166254
kind: OSImageStream
167255
metadata:
168256
name: cluster
169-
spec: {}
257+
spec:
258+
defaultStream: rhel-coreos
170259
status:
171260
defaultStream: "rhel-coreos"
172261
availableStreams:
@@ -181,13 +270,15 @@ tests:
181270
kind: OSImageStream
182271
metadata:
183272
name: cluster
184-
spec: {}
273+
spec:
274+
defaultStream: rhel-coreos
185275
updated: |
186276
apiVersion: machineconfiguration.openshift.io/v1alpha1
187277
kind: OSImageStream
188278
metadata:
189279
name: cluster
190-
spec: {}
280+
spec:
281+
defaultStream: rhel-coreos
191282
status:
192283
defaultStream: rhel-coreos
193284
availableStreams:
@@ -202,7 +293,8 @@ tests:
202293
kind: OSImageStream
203294
metadata:
204295
name: cluster
205-
spec: {}
296+
spec:
297+
defaultStream: rhel-coreos
206298
status:
207299
defaultStream: rhel-coreos
208300
availableStreams:
@@ -219,13 +311,15 @@ tests:
219311
kind: OSImageStream
220312
metadata:
221313
name: cluster
222-
spec: {}
314+
spec:
315+
defaultStream: rhel-coreos
223316
updated: |
224317
apiVersion: machineconfiguration.openshift.io/v1alpha1
225318
kind: OSImageStream
226319
metadata:
227320
name: cluster
228-
spec: {}
321+
spec:
322+
defaultStream: rhel-coreos
229323
status:
230324
availableStreams:
231325
- name: rhel-coreos
@@ -239,13 +333,15 @@ tests:
239333
kind: OSImageStream
240334
metadata:
241335
name: cluster
242-
spec: {}
336+
spec:
337+
defaultStream: rhel-coreos
243338
updated: |
244339
apiVersion: machineconfiguration.openshift.io/v1alpha1
245340
kind: OSImageStream
246341
metadata:
247342
name: cluster
248-
spec: {}
343+
spec:
344+
defaultStream: rhel-coreos
249345
status:
250346
defaultStream: rhel-coreos
251347
expectedStatusError: "status.availableStreams: Required value"
@@ -256,13 +352,15 @@ tests:
256352
kind: OSImageStream
257353
metadata:
258354
name: cluster
259-
spec: {}
355+
spec:
356+
defaultStream: rhel-coreos
260357
updated: |
261358
apiVersion: machineconfiguration.openshift.io/v1alpha1
262359
kind: OSImageStream
263360
metadata:
264361
name: cluster
265-
spec: {}
362+
spec:
363+
defaultStream: rhel-coreos
266364
status:
267365
defaultStream: rhel-coreos
268366
availableStreams: []
@@ -274,13 +372,15 @@ tests:
274372
kind: OSImageStream
275373
metadata:
276374
name: cluster
277-
spec: {}
375+
spec:
376+
defaultStream: rhel-coreos
278377
updated: |
279378
apiVersion: machineconfiguration.openshift.io/v1alpha1
280379
kind: OSImageStream
281380
metadata:
282381
name: cluster
283-
spec: {}
382+
spec:
383+
defaultStream: rhel-coreos
284384
status:
285385
defaultStream: non-existent-stream
286386
availableStreams:
@@ -295,13 +395,15 @@ tests:
295395
kind: OSImageStream
296396
metadata:
297397
name: cluster
298-
spec: {}
398+
spec:
399+
defaultStream: rhel-coreos
299400
updated: |
300401
apiVersion: machineconfiguration.openshift.io/v1alpha1
301402
kind: OSImageStream
302403
metadata:
303404
name: cluster
304-
spec: {}
405+
spec:
406+
defaultStream: rhel-coreos
305407
status:
306408
defaultStream: "invalid@stream!"
307409
availableStreams:
@@ -316,13 +418,15 @@ tests:
316418
kind: OSImageStream
317419
metadata:
318420
name: cluster
319-
spec: {}
421+
spec:
422+
defaultStream: rhel-coreos
320423
updated: |
321424
apiVersion: machineconfiguration.openshift.io/v1alpha1
322425
kind: OSImageStream
323426
metadata:
324427
name: cluster
325-
spec: {}
428+
spec:
429+
defaultStream: rhel-coreos
326430
status:
327431
defaultStream: "this-is-a-very-long-stream-name-that-exceeds-the-maximum-allowed-length-of-253-characters-for-rfc1123-subdomain-validation-which-is-used-to-ensure-compatibility-with-dns-and-kubernetes-naming-standards-and-this-string-needs-to-be-even-longer-to-properly-test-the-limit"
328432
availableStreams:

machineconfiguration/v1alpha1/types_osimagestream.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ type OSImageStreamStatus struct {
7474

7575
// OSImageStreamSpec defines the desired state of a OSImageStream.
7676
type OSImageStreamSpec struct {
77+
// defaultStream is the desired name of the stream that should be used as the
78+
// default when no specific stream is requested by a MachineConfigPool.
79+
//
80+
// This field is set by the installer during installation. Users may need to
81+
// update it if the currently selected stream is no longer available, for
82+
// example when the stream has reached its End of Life.
83+
// The MachineConfigOperator uses this value to determine which stream from
84+
// status.availableStreams to apply as the default for MachineConfigPools
85+
// that do not specify a stream override.
86+
//
87+
// It must be a valid RFC 1123 subdomain between 1 and 253 characters in length,
88+
// consisting of lowercase alphanumeric characters, hyphens ('-'), and periods ('.').
89+
//
90+
// +optional
91+
// +kubebuilder:validation:MinLength=1
92+
// +kubebuilder:validation:MaxLength=253
93+
// +kubebuilder:validation:XValidation:rule="!format.dns1123Subdomain().validate(self).hasValue()",message="a RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character."
94+
DefaultStream string `json:"defaultStream,omitempty"`
7795
}
7896

7997
type OSImageStreamSet struct {

0 commit comments

Comments
 (0)