Skip to content

Commit 1e795e3

Browse files
committed
add InternalReleaseImage controller
This controller takes care of the IRI deletion, and it avoids any machine config drifting - by generating or updating the IRI owned machine config
1 parent de7d985 commit 1e795e3

File tree

7 files changed

+687
-13
lines changed

7 files changed

+687
-13
lines changed

cmd/machine-config-controller/start.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
1414
containerruntimeconfig "github.com/openshift/machine-config-operator/pkg/controller/container-runtime-config"
1515
"github.com/openshift/machine-config-operator/pkg/controller/drain"
16+
"github.com/openshift/machine-config-operator/pkg/controller/internalreleaseimage"
1617
kubeletconfig "github.com/openshift/machine-config-operator/pkg/controller/kubelet-config"
1718
machinesetbootimage "github.com/openshift/machine-config-operator/pkg/controller/machine-set-boot-image"
1819
"github.com/openshift/machine-config-operator/pkg/controller/node"
@@ -128,6 +129,20 @@ func runStartCmd(_ *cobra.Command, _ []string) {
128129
ctrlctx.InformerFactory.Start(ctrlctx.Stop)
129130
}
130131

132+
if ctrlctx.FeatureGatesHandler.Enabled(features.FeatureGateNoRegistryClusterInstall) {
133+
iriController := internalreleaseimage.New(
134+
ctrlctx.InformerFactory.Machineconfiguration().V1alpha1().InternalReleaseImages(),
135+
ctrlctx.InformerFactory.Machineconfiguration().V1().ControllerConfigs(),
136+
ctrlctx.InformerFactory.Machineconfiguration().V1().MachineConfigs(),
137+
ctrlctx.ClientBuilder.KubeClientOrDie("internalreleaseimage-controller"),
138+
ctrlctx.ClientBuilder.MachineConfigClientOrDie("internalreleaseimage-controller"))
139+
140+
go iriController.Run(2, ctrlctx.Stop)
141+
// start the informers again to enable feature gated types.
142+
// see comments in SharedInformerFactory interface.
143+
ctrlctx.InformerFactory.Start(ctrlctx.Stop)
144+
}
145+
131146
if ctrlcommon.IsBootImageControllerRequired(ctrlctx) {
132147
machineSetBootImage := machinesetbootimage.New(
133148
ctrlctx.ClientBuilder.KubeClientOrDie("machine-set-boot-image-controller"),

install/image-references

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ spec:
4444
from:
4545
kind: DockerImage
4646
name: placeholder.url.oc.will.replace.this.org/placeholdernamespace:baremetal-runtimecfg
47+
- name: docker-registry
48+
from:
49+
kind: DockerImage
50+
name: placeholder.url.oc.will.replace.this.org/placeholdernamespace:docker-registry

pkg/controller/bootstrap/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ func (b *Bootstrap) Run(destDir string) error {
258258
return err
259259
}
260260
configs = append(configs, iriConfig)
261+
klog.Infof("Successfully generated MachineConfig from InternalReleaseImage.")
261262
}
262-
klog.Infof("Successfully generated MachineConfig from InternalReleaseImage.")
263263
}
264264

265265
// Create component MachineConfigs for pre-built images for hybrid OCL

pkg/controller/internalreleaseimage/internalreleaseimage_bootstrap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestRunInternalReleaseImageBootstrap(t *testing.T) {
1313
cc := &mcfgv1.ControllerConfig{
1414
Spec: mcfgv1.ControllerConfigSpec{
1515
Images: map[string]string{
16-
templatectrl.DockerRegistryKey: "docker-image-pullspec",
16+
templatectrl.DockerRegistryKey: "docker-registry-image-pullspec",
1717
},
1818
},
1919
}
@@ -23,5 +23,5 @@ func TestRunInternalReleaseImageBootstrap(t *testing.T) {
2323
assert.Equal(t, mc.Name, iriMachineConfigName)
2424
assert.Equal(t, mc.Labels[mcfgv1.MachineConfigRoleLabelKey], "master")
2525
assert.Equal(t, mc.OwnerReferences[0].Kind, "InternalReleaseImage")
26-
assert.Contains(t, string(mc.Spec.Config.Raw), "docker-image-pullspec")
26+
assert.Contains(t, string(mc.Spec.Config.Raw), "docker-registry-image-pullspec")
2727
}

0 commit comments

Comments
 (0)