Skip to content

Commit cfdda14

Browse files
authored
Merge pull request #4756 from djoshy/reconcile-ocl-api
MCO-1437: MCO-1476: MCO-1477: MCO-1284: Adapt MCO to OCL v1 API
2 parents eef257f + 1de506c commit cfdda14

File tree

127 files changed

+4093
-1688
lines changed

Some content is hidden

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

127 files changed

+4093
-1688
lines changed

cmd/machine-config-controller/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
250250
ctx.InformerFactory.Machineconfiguration().V1().MachineConfigPools(),
251251
ctx.KubeInformerFactory.Core().V1().Nodes(),
252252
ctx.KubeInformerFactory.Core().V1().Pods(),
253-
ctx.TechPreviewInformerFactory.Machineconfiguration().V1alpha1().MachineOSConfigs(),
253+
ctx.InformerFactory.Machineconfiguration().V1().MachineOSConfigs(),
254254
ctx.ConfigInformerFactory.Config().V1().Schedulers(),
255255
ctx.ClientBuilder.KubeClientOrDie("node-update-controller"),
256256
ctx.ClientBuilder.MachineConfigClientOrDie("node-update-controller"),

devex/cmd/onclustertesting/ci.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,7 @@ func setupMoscForCI(cs *framework.ClientSet, opts opts, poolName string) error {
142142
}
143143
}
144144

145-
if err := waitForBuildToComplete(ctx, cs, poolName); err != nil {
146-
return err
147-
}
148-
149-
return nil
145+
return waitForBuildToComplete(ctx, cs, poolName)
150146
}
151147

152148
func waitForPoolsToComplete(cs *framework.ClientSet, pools []string) error {

devex/cmd/onclustertesting/machineosconfigs.go

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import (
66
"time"
77

88
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
9-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
10-
clientmachineconfigv1alpha1 "github.com/openshift/client-go/machineconfiguration/clientset/versioned/typed/machineconfiguration/v1alpha1"
9+
clientmachineconfigv1 "github.com/openshift/client-go/machineconfiguration/clientset/versioned/typed/machineconfiguration/v1"
1110
"github.com/openshift/machine-config-operator/devex/internal/pkg/utils"
1211
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
1312
"github.com/openshift/machine-config-operator/test/framework"
@@ -25,47 +24,41 @@ type moscOpts struct {
2524
finalImagePullspec string
2625
}
2726

28-
func newMachineOSConfig(opts moscOpts) *mcfgv1alpha1.MachineOSConfig {
29-
return &mcfgv1alpha1.MachineOSConfig{
27+
func newMachineOSConfig(opts moscOpts) *mcfgv1.MachineOSConfig {
28+
return &mcfgv1.MachineOSConfig{
3029
ObjectMeta: metav1.ObjectMeta{
3130
Name: opts.poolName,
3231
Labels: map[string]string{
3332
createdByOnClusterBuildsHelper: "",
3433
},
3534
},
36-
Spec: mcfgv1alpha1.MachineOSConfigSpec{
37-
MachineConfigPool: mcfgv1alpha1.MachineConfigPoolReference{
35+
Spec: mcfgv1.MachineOSConfigSpec{
36+
MachineConfigPool: mcfgv1.MachineConfigPoolReference{
3837
Name: opts.poolName,
3938
},
40-
BuildInputs: mcfgv1alpha1.BuildInputs{
41-
BaseImagePullSecret: mcfgv1alpha1.ImageSecretObjectReference{
42-
Name: opts.pullSecretName,
43-
},
44-
RenderedImagePushSecret: mcfgv1alpha1.ImageSecretObjectReference{
45-
Name: opts.pushSecretName,
46-
},
47-
RenderedImagePushspec: opts.finalImagePullspec,
48-
ImageBuilder: &mcfgv1alpha1.MachineOSImageBuilder{
49-
ImageBuilderType: mcfgv1alpha1.PodBuilder,
50-
},
51-
Containerfile: []mcfgv1alpha1.MachineOSContainerfile{
52-
{
53-
ContainerfileArch: mcfgv1alpha1.NoArch,
54-
Content: opts.containerfileContents,
55-
},
56-
},
39+
BaseImagePullSecret: &mcfgv1.ImageSecretObjectReference{
40+
Name: opts.pullSecretName,
5741
},
58-
BuildOutputs: mcfgv1alpha1.BuildOutputs{
59-
CurrentImagePullSecret: mcfgv1alpha1.ImageSecretObjectReference{
60-
Name: opts.finalPullSecretName,
42+
RenderedImagePushSecret: mcfgv1.ImageSecretObjectReference{
43+
Name: opts.pushSecretName,
44+
},
45+
RenderedImagePushSpec: mcfgv1.ImageTagFormat(opts.finalImagePullspec),
46+
ImageBuilder: mcfgv1.MachineOSImageBuilder{
47+
ImageBuilderType: mcfgv1.MachineOSImageBuilderType("PodImageBuilder"),
48+
},
49+
Containerfile: []mcfgv1.MachineOSContainerfile{
50+
{
51+
ContainerfileArch: mcfgv1.NoArch,
52+
Content: opts.containerfileContents,
6153
},
6254
},
6355
},
6456
}
57+
6558
}
6659

67-
func getMachineOSConfigForPool(cs *framework.ClientSet, pool *mcfgv1.MachineConfigPool) (*mcfgv1alpha1.MachineOSConfig, error) {
68-
client := clientmachineconfigv1alpha1.NewForConfigOrDie(cs.GetRestConfig())
60+
func getMachineOSConfigForPool(cs *framework.ClientSet, pool *mcfgv1.MachineConfigPool) (*mcfgv1.MachineOSConfig, error) {
61+
client := clientmachineconfigv1.NewForConfigOrDie(cs.GetRestConfig())
6962

7063
moscList, err := client.MachineOSConfigs().List(context.TODO(), metav1.ListOptions{})
7164
if err != nil {
@@ -89,8 +82,8 @@ func getMachineOSConfigForPool(cs *framework.ClientSet, pool *mcfgv1.MachineConf
8982
return nil, fmt.Errorf("expected one MachineOSConfig for MachineConfigPool %s, found multiple: %v", pool.Name, names)
9083
}
9184

92-
func filterMachineOSConfigsForPool(moscList *mcfgv1alpha1.MachineOSConfigList, pool *mcfgv1.MachineConfigPool) []*mcfgv1alpha1.MachineOSConfig {
93-
found := []*mcfgv1alpha1.MachineOSConfig{}
85+
func filterMachineOSConfigsForPool(moscList *mcfgv1.MachineOSConfigList, pool *mcfgv1.MachineConfigPool) []*mcfgv1.MachineOSConfig {
86+
found := []*mcfgv1.MachineOSConfig{}
9487

9588
for _, mosc := range moscList.Items {
9689
if mosc.Spec.MachineConfigPool.Name == pool.Name {
@@ -102,8 +95,8 @@ func filterMachineOSConfigsForPool(moscList *mcfgv1alpha1.MachineOSConfigList, p
10295
return found
10396
}
10497

105-
func createMachineOSConfig(cs *framework.ClientSet, mosc *mcfgv1alpha1.MachineOSConfig) error {
106-
client := clientmachineconfigv1alpha1.NewForConfigOrDie(cs.GetRestConfig())
98+
func createMachineOSConfig(cs *framework.ClientSet, mosc *mcfgv1.MachineOSConfig) error {
99+
client := clientmachineconfigv1.NewForConfigOrDie(cs.GetRestConfig())
107100

108101
_, err := client.MachineOSConfigs().Create(context.TODO(), mosc, metav1.CreateOptions{})
109102
if err != nil {
@@ -115,7 +108,7 @@ func createMachineOSConfig(cs *framework.ClientSet, mosc *mcfgv1alpha1.MachineOS
115108
}
116109

117110
func deleteMachineOSConfigs(cs *framework.ClientSet) error {
118-
client := clientmachineconfigv1alpha1.NewForConfigOrDie(cs.GetRestConfig())
111+
client := clientmachineconfigv1.NewForConfigOrDie(cs.GetRestConfig())
119112

120113
moscList, err := client.MachineOSConfigs().List(context.TODO(), metav1.ListOptions{})
121114
if err != nil {
@@ -135,7 +128,7 @@ func deleteMachineOSConfigs(cs *framework.ClientSet) error {
135128
}
136129

137130
func deleteMachineOSBuilds(cs *framework.ClientSet) error {
138-
client := clientmachineconfigv1alpha1.NewForConfigOrDie(cs.GetRestConfig())
131+
client := clientmachineconfigv1.NewForConfigOrDie(cs.GetRestConfig())
139132

140133
mosbList, err := client.MachineOSBuilds().List(context.TODO(), metav1.ListOptions{})
141134
if err != nil {
@@ -162,7 +155,7 @@ func waitForBuildToComplete(ctx context.Context, cs *framework.ClientSet, poolNa
162155

163156
start := time.Now()
164157

165-
return waitForMachineOSBuildToReachState(ctx, cs, poolName, func(mosb *mcfgv1alpha1.MachineOSBuild, err error) (bool, error) {
158+
return waitForMachineOSBuildToReachState(ctx, cs, poolName, func(mosb *mcfgv1.MachineOSBuild, err error) (bool, error) {
166159
// There is a lag between when the MachineOSConfig is created and the
167160
// MachineOSBuild object gets created and is available.
168161
if err != nil && !utils.IsNotFoundErr(err) {
@@ -206,7 +199,7 @@ func waitForBuildToComplete(ctx context.Context, cs *framework.ClientSet, poolNa
206199
})
207200
}
208201

209-
func waitForMachineOSBuildToReachState(ctx context.Context, cs *framework.ClientSet, poolName string, condFunc func(*mcfgv1alpha1.MachineOSBuild, error) (bool, error)) error {
202+
func waitForMachineOSBuildToReachState(ctx context.Context, cs *framework.ClientSet, poolName string, condFunc func(*mcfgv1.MachineOSBuild, error) (bool, error)) error {
210203
return wait.PollUntilContextCancel(ctx, time.Second, true, func(funcCtx context.Context) (bool, error) {
211204
mosb, err := utils.GetMachineOSBuildForPoolName(funcCtx, cs, poolName)
212205
return condFunc(mosb, err)

devex/cmd/onclustertesting/opts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"os"
66

7-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
7+
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
88
"k8s.io/klog/v2"
99
)
1010

@@ -80,7 +80,7 @@ func (o *opts) shouldCloneGlobalPullSecret() bool {
8080
return isNoneSet(o.pullSecretName, o.pullSecretPath)
8181
}
8282

83-
func (o *opts) toMachineOSConfig() (*mcfgv1alpha1.MachineOSConfig, error) {
83+
func (o *opts) toMachineOSConfig() (*mcfgv1.MachineOSConfig, error) {
8484
pushSecretName, err := o.getPushSecretName()
8585
if err != nil {
8686
return nil, err

devex/cmd/onclustertesting/teardown.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,5 @@ func mobTeardown(cs *framework.ClientSet, targetPool string) error {
8585
return err
8686
}
8787

88-
if err := deleteMachineOSConfigs(cs); err != nil {
89-
return err
90-
}
91-
92-
return nil
88+
return deleteMachineOSConfigs(cs)
9389
}

devex/internal/pkg/rollout/machineconfigpool.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"time"
99

1010
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
11-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
1211
errhelpers "github.com/openshift/machine-config-operator/devex/internal/pkg/errors"
1312
"github.com/openshift/machine-config-operator/devex/internal/pkg/utils"
1413
"github.com/openshift/machine-config-operator/pkg/apihelpers"
@@ -426,10 +425,10 @@ func isNodeImageDone(node *corev1.Node) bool {
426425
return isNodeDone(node) && current == desired
427426
}
428427

429-
func isNodeDoneAtMosc(mosc *mcfgv1alpha1.MachineOSConfig, node *corev1.Node) bool {
428+
func isNodeDoneAtMosc(mosc *mcfgv1.MachineOSConfig, node *corev1.Node) bool {
430429
current := node.Annotations[daemonconsts.CurrentImageAnnotationKey]
431430
desired := node.Annotations[daemonconsts.DesiredImageAnnotationKey]
432-
return isNodeDone(node) && isNodeImageDone(node) && desired == mosc.Status.CurrentImagePullspec && desired != "" && current != ""
431+
return isNodeDone(node) && isNodeImageDone(node) && desired == string(mosc.Status.CurrentImagePullSpec) && desired != "" && current != ""
433432
}
434433

435434
func isNodeDone(node *corev1.Node) bool {

devex/internal/pkg/rollout/nodeimage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package rollout
22

33
import (
4-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
4+
mcfgv1 "github.com/openshift/api/machineconfiguration/v1alpha1"
55
daemonconsts "github.com/openshift/machine-config-operator/pkg/daemon/constants"
66
corev1 "k8s.io/api/core/v1"
77
)
88

9-
func isNodeImageEqualToMachineOSConfig(node corev1.Node, mosc *mcfgv1alpha1.MachineOSConfig) bool {
9+
func isNodeImageEqualToMachineOSConfig(node corev1.Node, mosc *mcfgv1.MachineOSConfig) bool {
1010
desired := node.Annotations[daemonconsts.DesiredImageAnnotationKey]
1111
current := node.Annotations[daemonconsts.CurrentImageAnnotationKey]
1212
mcdState := node.Annotations[daemonconsts.MachineConfigDaemonStateAnnotationKey]

devex/internal/pkg/utils/apiutils.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77

88
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
9-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
109
"github.com/openshift/machine-config-operator/test/framework"
1110
apierrs "k8s.io/apimachinery/pkg/api/errors"
1211
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -21,7 +20,7 @@ type notFoundErr struct {
2120
func newNotFoundErr(resource, poolName string) error {
2221
return &notFoundErr{
2322
poolName: poolName,
24-
err: apierrs.NewNotFound(mcfgv1alpha1.GroupVersion.WithResource(resource).GroupResource(), ""),
23+
err: apierrs.NewNotFound(mcfgv1.GroupVersion.WithResource(resource).GroupResource(), ""),
2524
}
2625
}
2726

@@ -47,7 +46,7 @@ func IsMachineConfigPoolLayered(ctx context.Context, cs *framework.ClientSet, mc
4746
return mosc != nil && !IsNotFoundErr(err), nil
4847
}
4948

50-
func GetMachineOSBuildForPoolName(ctx context.Context, cs *framework.ClientSet, poolName string) (*mcfgv1alpha1.MachineOSBuild, error) {
49+
func GetMachineOSBuildForPoolName(ctx context.Context, cs *framework.ClientSet, poolName string) (*mcfgv1.MachineOSBuild, error) {
5150
mcp, err := cs.MachineConfigPools().Get(ctx, poolName, metav1.GetOptions{})
5251
if err != nil {
5352
return nil, err
@@ -56,7 +55,7 @@ func GetMachineOSBuildForPoolName(ctx context.Context, cs *framework.ClientSet,
5655
return GetMachineOSBuildForPool(ctx, cs, mcp)
5756
}
5857

59-
func GetMachineOSConfigForPoolName(ctx context.Context, cs *framework.ClientSet, poolName string) (*mcfgv1alpha1.MachineOSConfig, error) {
58+
func GetMachineOSConfigForPoolName(ctx context.Context, cs *framework.ClientSet, poolName string) (*mcfgv1.MachineOSConfig, error) {
6059
mcp, err := cs.MachineConfigPools().Get(ctx, poolName, metav1.GetOptions{})
6160
if err != nil {
6261
return nil, err
@@ -65,24 +64,24 @@ func GetMachineOSConfigForPoolName(ctx context.Context, cs *framework.ClientSet,
6564
return GetMachineOSConfigForPool(ctx, cs, mcp)
6665
}
6766

68-
func GetMachineOSBuildForPool(ctx context.Context, cs *framework.ClientSet, mcp *mcfgv1.MachineConfigPool) (*mcfgv1alpha1.MachineOSBuild, error) {
69-
mosbList, err := cs.MachineOSBuilds().List(ctx, metav1.ListOptions{})
67+
func GetMachineOSBuildForPool(ctx context.Context, cs *framework.ClientSet, mcp *mcfgv1.MachineConfigPool) (*mcfgv1.MachineOSBuild, error) {
68+
mosbList, err := cs.MachineconfigurationV1Interface.MachineOSBuilds().List(ctx, metav1.ListOptions{})
7069
if err != nil {
7170
return nil, err
7271
}
7372

7473
for _, mosb := range mosbList.Items {
7574
mosb := mosb
76-
if mosb.Spec.DesiredConfig.Name == mcp.Spec.Configuration.Name {
75+
if mosb.Spec.MachineConfig.Name == mcp.Spec.Configuration.Name {
7776
return &mosb, nil
7877
}
7978
}
8079

8180
return nil, newNotFoundErr("machineosbuilds", mcp.Name)
8281
}
8382

84-
func GetMachineOSConfigForPool(ctx context.Context, cs *framework.ClientSet, mcp *mcfgv1.MachineConfigPool) (*mcfgv1alpha1.MachineOSConfig, error) {
85-
moscList, err := cs.MachineOSConfigs().List(ctx, metav1.ListOptions{})
83+
func GetMachineOSConfigForPool(ctx context.Context, cs *framework.ClientSet, mcp *mcfgv1.MachineConfigPool) (*mcfgv1.MachineOSConfig, error) {
84+
moscList, err := cs.MachineconfigurationV1Interface.MachineOSConfigs().List(ctx, metav1.ListOptions{})
8685
if err != nil {
8786
return nil, err
8887
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/imdario/mergo v0.3.16
3030
github.com/opencontainers/go-digest v1.0.0
3131
github.com/openshift/api v0.0.0-20250102185430-d6d8306a24ec
32-
github.com/openshift/client-go v0.0.0-20241203091221-452dfb8fa071
32+
github.com/openshift/client-go v0.0.0-20250106104058-89709a455e2a
3333
github.com/openshift/library-go v0.0.0-20241022210936-abb8c75b88dc
3434
github.com/openshift/runtime-utils v0.0.0-20230921210328-7bdb5b9c177b
3535
github.com/prometheus/client_golang v1.20.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bl
596596
github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
597597
github.com/openshift/api v0.0.0-20250102185430-d6d8306a24ec h1:VEDRGJmiYeN0V0xW1aI9wfzEMgaMZOVasy3FzEz27Lo=
598598
github.com/openshift/api v0.0.0-20250102185430-d6d8306a24ec/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
599-
github.com/openshift/client-go v0.0.0-20241203091221-452dfb8fa071 h1:l0++HnGVKBcs8kXFL/1yeozxioxPGNpp0PYe3Y+0sq4=
600-
github.com/openshift/client-go v0.0.0-20241203091221-452dfb8fa071/go.mod h1:gL0laCCiIaNTNw1ZsMQZXBVu2NeQFpNWm9bLtYO9+ZU=
599+
github.com/openshift/client-go v0.0.0-20250106104058-89709a455e2a h1:8lwO4lGTwHuVXsIeFoW3t7AEBROW5quMj5YjH9jF+98=
600+
github.com/openshift/client-go v0.0.0-20250106104058-89709a455e2a/go.mod h1:34qRf2MsrJKXKAL8qxIkxZ3O5G+YhOB7foCR04H26JE=
601601
github.com/openshift/kube-openapi v0.0.0-20230816122517-ffc8f001abb0 h1:GPlAy197Jkr+D0T2FNWanamraTdzS/r9ZkT29lxvHaA=
602602
github.com/openshift/kube-openapi v0.0.0-20230816122517-ffc8f001abb0/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM=
603603
github.com/openshift/library-go v0.0.0-20241022210936-abb8c75b88dc h1:fwtWTW+QcTyzGVAYxMPz9amtAURWvSs8p+a37nG/43c=

manifests/machineconfigdaemon/daemonset.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ spec:
4242
- mountPath: /rootfs
4343
name: rootfs
4444
mountPropagation: HostToContainer
45-
{{- range .MachineOSConfigs }}
46-
- mountPath: /run/secrets/os-image-pull-secrets/{{ .Spec.MachineConfigPool.Name }}
47-
name: {{ .Spec.BuildOutputs.CurrentImagePullSecret.Name }}
48-
{{- end }}
4945
livenessProbe:
5046
initialDelaySeconds: 120
5147
periodSeconds: 30
@@ -116,11 +112,6 @@ spec:
116112
- configMap:
117113
name: kube-rbac-proxy
118114
name: mcd-auth-proxy-config
119-
{{- range .MachineOSConfigs }}
120-
- secret:
121-
secretName: {{ .Spec.BuildOutputs.CurrentImagePullSecret.Name }}
122-
name: {{ .Spec.BuildOutputs.CurrentImagePullSecret.Name }}
123-
{{- end }}
124115
tolerations:
125116
# MCD needs to run everywhere. Tolerate all taints.
126117
- operator: Exists

0 commit comments

Comments
 (0)