Skip to content

Commit a8aeeb0

Browse files
Merge branch 'master' of https://github.com/isabella-janssen/machine-config-operator into ocpbugs-38869-mcnDesiredConfig
2 parents be0f4ff + 1bffe82 commit a8aeeb0

File tree

3,319 files changed

+117068
-102816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,319 files changed

+117068
-102816
lines changed

.ci-operator.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: release
33
namespace: openshift
4-
tag: rhel-9-release-golang-1.22-openshift-4.18
4+
tag: rhel-9-release-golang-1.23-openshift-4.19

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use RHEL 9 as the primary builder base for the Machine Config Operator
2-
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-builder-multi-openshift-4.18 AS rhel9-builder
2+
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.23-openshift-4.19 AS rhel9-builder
33
ARG TAGS=""
44
WORKDIR /go/src/github.com/openshift/machine-config-operator
55
COPY . .
@@ -12,7 +12,7 @@ RUN --mount=type=cache,target=/go/rhel9/.cache,z \
1212
make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .
1313

1414
# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
15-
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.22-builder-multi-openshift-4.18 AS rhel8-builder
15+
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.23-openshift-4.19 AS rhel8-builder
1616
ARG TAGS=""
1717
WORKDIR /go/src/github.com/openshift/machine-config-operator
1818
# Copy the RHEL 8 machine-config-daemon binary and rename

Dockerfile.rhel7

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE IS GENERATED FROM Dockerfile DO NOT EDIT
22
# Use RHEL 9 as the primary builder base for the Machine Config Operator
3-
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-builder-multi-openshift-4.18 AS rhel9-builder
3+
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.23-openshift-4.19 AS rhel9-builder
44
ARG TAGS=""
55
WORKDIR /go/src/github.com/openshift/machine-config-operator
66
COPY . .
@@ -13,7 +13,7 @@ RUN --mount=type=cache,target=/go/rhel9/.cache,z \
1313
make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .
1414

1515
# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
16-
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.22-builder-multi-openshift-4.18 AS rhel8-builder
16+
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.23-openshift-4.19 AS rhel8-builder
1717
ARG TAGS=""
1818
WORKDIR /go/src/github.com/openshift/machine-config-operator
1919
# Copy the RHEL 8 machine-config-daemon binary and rename
@@ -24,7 +24,7 @@ RUN --mount=type=cache,target=/go/rhel8/.cache,z \
2424
--mount=type=cache,target=/go/rhel8/pkg/mod,z \
2525
make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .
2626

27-
FROM registry.ci.openshift.org/ocp/builder:rhel-9-enterprise-base-multi-openshift-4.18
27+
FROM registry.ci.openshift.org/ocp/4.19:base-rhel9
2828
ARG TAGS=""
2929
COPY install /manifests
3030
RUN --mount=type=cache,target=/var/cache/dnf,z \

docs/HACKING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ To use host binaries, run `chroot /host`
364364
Pod IP: 10.0.147.70
365365
If you don't see a command prompt, try pressing enter.
366366
sh-4.2# chroot /host
367-
sh-4.4# /sbin/iptables -D OPENSHIFT-BLOCK-OUTPUT 1
367+
sh-4.4# /sbin/iptables -nL FORWARD --line-numbers | grep -E '2262[34]' | awk '{print $1}' | xargs -n 1 echo | tac | xargs -n 1 /sbin/iptables -D FORWARD
368368
sh-4.4# curl -k https://<api-server-url>:22623/config/worker
369369
...
370370
sh-4.4# curl -H "Accept: application/vnd.coreos.ignition+json; version=3.2.0" -k https://<api-server-url>/config/worker

docs/MachineConfig.md

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ RHCOS is a minimal OCP focused OS which provides capabilities common across all
210210
| 4.11 | `usbguard`, `sandboxed-containers`, `kerberos` |
211211
| 4.14 | `usbguard`, `sandboxed-containers`, `kerberos`, `ipsec`, `wasm` |
212212
| 4.18 | `usbguard`, `sandboxed-containers`, `kerberos`, `ipsec`, `wasm` , `sysstat` |
213+
| 4.19 | `usbguard`, `sandboxed-containers`, `kerberos`, `ipsec`, `wasm` , `sysstat` , `two-node-ha` |
213214

214215
Extensions can be installed by creating a MachineConfig object. Extensions can be enabled as both day1 and day2. Check [installer guide](https://github.com/openshift/installer/blob/master/docs/user/customization.md#Enabling-RHCOS-Extensions) to enable extensions during cluster install.
215216

go.mod

+124-119
Large diffs are not rendered by default.

go.sum

+276-299
Large diffs are not rendered by default.

install/0000_90_machine-config_01_prometheus-rules.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ spec:
8989
annotations:
9090
summary: "Alerts the user that a node failed to reboot one or more times over a span of 5 minutes."
9191
description: "Reboot failed on {{ $labels.node }} , update may be blocked. For more details: oc logs -f -n {{ $labels.namespace }} {{ $labels.pod }} -c machine-config-daemon "
92+
runbook_url: https://github.com/openshift/runbooks/blob/master/alerts/machine-config-operator/MachineConfigDaemonRebootError.md
9293
- name: mcd-pivot-error
9394
rules:
9495
- alert: MCDPivotError

pkg/apihelpers/apihelpers.go

+19-11
Original file line numberDiff line numberDiff line change
@@ -326,35 +326,43 @@ func IsControllerConfigCompleted(ccName string, ccGetter func(string) (*mcfgv1.C
326326
}
327327

328328
// AreMCGeneratingSubControllersCompleted checks whether all MC producing sub-controllers are completed
329-
func AreMCGeneratingSubControllersCompleted(crcLister func(labels.Selector) ([]*mcfgv1.ContainerRuntimeConfig, error), mckLister func(labels.Selector) ([]*mcfgv1.KubeletConfig, error), selector labels.Selector) error {
329+
func AreMCGeneratingSubControllersCompletedForPool(crcLister func(labels.Selector) ([]*mcfgv1.ContainerRuntimeConfig, error), mckLister func(labels.Selector) ([]*mcfgv1.KubeletConfig, error), poolLabels map[string]string) error {
330330

331-
containerConfigs, err := crcLister(selector)
331+
containerConfigs, err := crcLister(labels.Everything())
332332
if err != nil {
333333
return err
334334
}
335335
for _, crc := range containerConfigs {
336-
if crc.Generation != crc.Status.ObservedGeneration {
337-
return fmt.Errorf("status for ContainerRuntimeConfig %s is being reported for %d, expecting it for %d", crc.ObjectMeta.Name, crc.Status.ObservedGeneration, crc.Generation)
336+
selector, err := metav1.LabelSelectorAsSelector(crc.Spec.MachineConfigPoolSelector)
337+
if err != nil {
338+
return fmt.Errorf("invalid label selector: %w", err)
338339
}
340+
if selector.Matches(labels.Set(poolLabels)) {
341+
if crc.Generation != crc.Status.ObservedGeneration {
342+
return fmt.Errorf("status for ContainerRuntimeConfig %s is being reported for %d, expecting it for %d", crc.ObjectMeta.Name, crc.Status.ObservedGeneration, crc.Generation)
343+
}
339344

340-
for _, condition := range crc.Status.Conditions {
341-
if condition.Type != mcfgv1.ContainerRuntimeConfigSuccess {
345+
if crc.Status.Conditions[len(crc.Status.Conditions)-1].Type != mcfgv1.ContainerRuntimeConfigSuccess {
342346
return fmt.Errorf("ContainerRuntimeConfig has not completed")
343347
}
344348
}
345349
}
346350

347-
kubeletConfigs, err := mckLister(selector)
351+
kubeletConfigs, err := mckLister(labels.Everything())
348352
if err != nil {
349353
return err
350354
}
351355
for _, mck := range kubeletConfigs {
352-
if mck.Generation != mck.Status.ObservedGeneration {
353-
return fmt.Errorf("status for KubeletConfig %s is being reported for %d, expecting it for %d", mck.ObjectMeta.Name, mck.Status.ObservedGeneration, mck.Generation)
356+
selector, err := metav1.LabelSelectorAsSelector(mck.Spec.MachineConfigPoolSelector)
357+
if err != nil {
358+
return fmt.Errorf("invalid label selector: %w", err)
354359
}
360+
if selector.Matches(labels.Set(poolLabels)) {
361+
if mck.Generation != mck.Status.ObservedGeneration {
362+
return fmt.Errorf("status for KubeletConfig %s is being reported for %d, expecting it for %d", mck.ObjectMeta.Name, mck.Status.ObservedGeneration, mck.Generation)
363+
}
355364

356-
for _, condition := range mck.Status.Conditions {
357-
if condition.Type != mcfgv1.KubeletConfigSuccess {
365+
if mck.Status.Conditions[len(mck.Status.Conditions)-1].Type != mcfgv1.KubeletConfigSuccess {
358366
return fmt.Errorf("KubeletConfig has not completed")
359367
}
360368
}

pkg/apihelpers/machineosbuild.go

+216
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,219 @@ func IsMachineOSBuildConditionPresentAndEqual(conditions []metav1.Condition, con
7878
}
7979
return false
8080
}
81+
82+
// Represents the successful conditions for a MachineOSBuild.
83+
func MachineOSBuildSucceededConditions() []metav1.Condition {
84+
return []metav1.Condition{
85+
{
86+
Type: string(mcfgv1.MachineOSBuildPrepared),
87+
Status: metav1.ConditionFalse,
88+
Reason: "Prepared",
89+
Message: "Build Prepared and Pending",
90+
},
91+
{
92+
Type: string(mcfgv1.MachineOSBuilding),
93+
Status: metav1.ConditionFalse,
94+
Reason: "Building",
95+
Message: "Image Build In Progress",
96+
},
97+
{
98+
Type: string(mcfgv1.MachineOSBuildFailed),
99+
Status: metav1.ConditionFalse,
100+
Reason: "Failed",
101+
Message: "Build Failed",
102+
},
103+
{
104+
Type: string(mcfgv1.MachineOSBuildInterrupted),
105+
Status: metav1.ConditionFalse,
106+
Reason: "Interrupted",
107+
Message: "Build Interrupted",
108+
},
109+
{
110+
Type: string(mcfgv1.MachineOSBuildSucceeded),
111+
Status: metav1.ConditionTrue,
112+
Reason: "Ready",
113+
Message: "Build Ready",
114+
},
115+
}
116+
}
117+
118+
// Represents the pending conditions for a MachineOSBuild.
119+
func MachineOSBuildPendingConditions() []metav1.Condition {
120+
return []metav1.Condition{
121+
{
122+
Type: string(mcfgv1.MachineOSBuildPrepared),
123+
Status: metav1.ConditionTrue,
124+
Reason: "Prepared",
125+
Message: "Build Prepared and Pending",
126+
},
127+
{
128+
Type: string(mcfgv1.MachineOSBuilding),
129+
Status: metav1.ConditionFalse,
130+
Reason: "Building",
131+
Message: "Image Build In Progress",
132+
},
133+
{
134+
Type: string(mcfgv1.MachineOSBuildFailed),
135+
Status: metav1.ConditionFalse,
136+
Reason: "Failed",
137+
Message: "Build Failed",
138+
},
139+
{
140+
Type: string(mcfgv1.MachineOSBuildInterrupted),
141+
Status: metav1.ConditionFalse,
142+
Reason: "Interrupted",
143+
Message: "Build Interrupted",
144+
},
145+
{
146+
Type: string(mcfgv1.MachineOSBuildSucceeded),
147+
Status: metav1.ConditionFalse,
148+
Reason: "Ready",
149+
Message: "Build Ready",
150+
},
151+
}
152+
}
153+
154+
// Represents the running conditions for a MachineOSBuild.
155+
func MachineOSBuildRunningConditions() []metav1.Condition {
156+
return []metav1.Condition{
157+
{
158+
Type: string(mcfgv1.MachineOSBuildPrepared),
159+
Status: metav1.ConditionFalse,
160+
Reason: "Prepared",
161+
Message: "Build Prepared and Pending",
162+
},
163+
{
164+
Type: string(mcfgv1.MachineOSBuilding),
165+
Status: metav1.ConditionTrue,
166+
Reason: "Building",
167+
Message: "Image Build In Progress",
168+
},
169+
{
170+
Type: string(mcfgv1.MachineOSBuildFailed),
171+
Status: metav1.ConditionFalse,
172+
Reason: "Failed",
173+
Message: "Build Failed",
174+
},
175+
{
176+
Type: string(mcfgv1.MachineOSBuildInterrupted),
177+
Status: metav1.ConditionFalse,
178+
Reason: "Interrupted",
179+
Message: "Build Interrupted",
180+
},
181+
{
182+
Type: string(mcfgv1.MachineOSBuildSucceeded),
183+
Status: metav1.ConditionFalse,
184+
Reason: "Ready",
185+
Message: "Build Ready",
186+
},
187+
}
188+
}
189+
190+
// Represents the failure conditions for a MachineOSBuild.
191+
func MachineOSBuildFailedConditions() []metav1.Condition {
192+
return []metav1.Condition{
193+
{
194+
Type: string(mcfgv1.MachineOSBuildPrepared),
195+
Status: metav1.ConditionFalse,
196+
Reason: "Prepared",
197+
Message: "Build Prepared and Pending",
198+
},
199+
{
200+
Type: string(mcfgv1.MachineOSBuilding),
201+
Status: metav1.ConditionFalse,
202+
Reason: "Building",
203+
Message: "Image Build In Progress",
204+
},
205+
{
206+
Type: string(mcfgv1.MachineOSBuildFailed),
207+
Status: metav1.ConditionTrue,
208+
Reason: "Failed",
209+
Message: "Build Failed",
210+
},
211+
{
212+
Type: string(mcfgv1.MachineOSBuildInterrupted),
213+
Status: metav1.ConditionFalse,
214+
Reason: "Interrupted",
215+
Message: "Build Interrupted",
216+
},
217+
{
218+
Type: string(mcfgv1.MachineOSBuildSucceeded),
219+
Status: metav1.ConditionFalse,
220+
Reason: "Ready",
221+
Message: "Build Ready",
222+
},
223+
}
224+
}
225+
226+
// Represents the interrupted conditions for a MachineOSBuild.
227+
func MachineOSBuildInterruptedConditions() []metav1.Condition {
228+
return []metav1.Condition{
229+
{
230+
Type: string(mcfgv1.MachineOSBuildPrepared),
231+
Status: metav1.ConditionFalse,
232+
Reason: "Prepared",
233+
Message: "Build Prepared and Pending",
234+
},
235+
{
236+
Type: string(mcfgv1.MachineOSBuilding),
237+
Status: metav1.ConditionFalse,
238+
Reason: "Building",
239+
Message: "Image Build In Progress",
240+
},
241+
{
242+
Type: string(mcfgv1.MachineOSBuildFailed),
243+
Status: metav1.ConditionFalse,
244+
Reason: "Failed",
245+
Message: "Build Failed",
246+
},
247+
{
248+
Type: string(mcfgv1.MachineOSBuildInterrupted),
249+
Status: metav1.ConditionTrue,
250+
Reason: "Interrupted",
251+
Message: "Build Interrupted",
252+
},
253+
{
254+
Type: string(mcfgv1.MachineOSBuildSucceeded),
255+
Status: metav1.ConditionFalse,
256+
Reason: "Ready",
257+
Message: "Build Ready",
258+
},
259+
}
260+
}
261+
262+
// Represents the initial MachineOSBuild state (all conditions false).
263+
func MachineOSBuildInitialConditions() []metav1.Condition {
264+
return []metav1.Condition{
265+
{
266+
Type: string(mcfgv1.MachineOSBuildPrepared),
267+
Status: metav1.ConditionFalse,
268+
Reason: "Prepared",
269+
Message: "Build Prepared and Pending",
270+
},
271+
{
272+
Type: string(mcfgv1.MachineOSBuilding),
273+
Status: metav1.ConditionFalse,
274+
Reason: "Building",
275+
Message: "Image Build In Progress",
276+
},
277+
{
278+
Type: string(mcfgv1.MachineOSBuildFailed),
279+
Status: metav1.ConditionFalse,
280+
Reason: "Failed",
281+
Message: "Build Failed",
282+
},
283+
{
284+
Type: string(mcfgv1.MachineOSBuildInterrupted),
285+
Status: metav1.ConditionFalse,
286+
Reason: "Interrupted",
287+
Message: "Build Interrupted",
288+
},
289+
{
290+
Type: string(mcfgv1.MachineOSBuildSucceeded),
291+
Status: metav1.ConditionFalse,
292+
Reason: "Ready",
293+
Message: "Build Ready",
294+
},
295+
}
296+
}

pkg/controller/build/buildrequest/buildrequest.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,16 @@ func (br buildRequestImpl) podToJob(pod *corev1.Pod) *batchv1.Job {
254254
// Set completion to 1 so that as soon as the pod has completed successfully the job is
255255
// considered a success
256256
var completions int32 = 1
257+
// Set the owner ref of the job to the MOSB
258+
oref := metav1.NewControllerRef(br.opts.MachineOSBuild, mcfgv1.SchemeGroupVersion.WithKind("MachineOSBuild"))
257259
return &batchv1.Job{
258-
ObjectMeta: pod.ObjectMeta,
260+
ObjectMeta: metav1.ObjectMeta{
261+
Name: pod.ObjectMeta.Name,
262+
Namespace: pod.ObjectMeta.Namespace,
263+
Labels: pod.ObjectMeta.Labels,
264+
Annotations: pod.ObjectMeta.Annotations,
265+
OwnerReferences: []metav1.OwnerReference{*oref},
266+
},
259267
TypeMeta: metav1.TypeMeta{
260268
APIVersion: "batch/v1",
261269
Kind: "Job",

pkg/controller/build/helpers.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ func isMachineOSBuildStatusUpdateNeeded(oldStatus, curStatus mcfgv1.MachineOSBui
141141
return true, fmt.Sprintf("transitioned from initial state -> transient state (%s)", curTransientState)
142142
}
143143

144-
// From pending -> building.
144+
// From pending -> building, but not building -> pending.
145145
if oldState.IsInTransientState() && curState.IsInTransientState() && oldTransientState != curTransientState {
146-
return true, fmt.Sprintf("transitioned from transient state (%s) -> transient state (%s)", oldTransientState, curTransientState)
146+
reason := fmt.Sprintf("transitioned from transient state (%s) -> transient state (%s)", oldTransientState, curTransientState)
147+
isValid := oldTransientState == mcfgv1.MachineOSBuildPrepared && curTransientState == mcfgv1.MachineOSBuilding
148+
return isValid, reason
147149
}
148150

149151
oldTerminalState := oldState.GetTerminalState()

0 commit comments

Comments
 (0)