Skip to content

Commit 5f05b35

Browse files
Merge pull request #5280 from hasueki/fix-nto-reconcile
OCPBUGS-46354: fix(ho): Add all supported config schemas for NodePool NTO reconcile
2 parents 04b85e8 + ad2f927 commit 5f05b35

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

hypershift-operator/controllers/nodepool/nto.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import (
1111
"strings"
1212

1313
"github.com/go-logr/logr"
14+
configv1 "github.com/openshift/api/config/v1"
15+
configv1alpha1 "github.com/openshift/api/config/v1alpha1"
1416
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
17+
"github.com/openshift/api/operator/v1alpha1"
1518
performanceprofilev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2"
1619
tunedv1 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/tuned/v1"
1720
hyperv1 "github.com/openshift/hypershift/api/hypershift/v1beta1"
@@ -414,6 +417,9 @@ func BuildMirrorConfigs(ctx context.Context, cg *ConfigGenerator) ([]*MirrorConf
414417
func getMirrorConfigForManifest(manifest []byte) (*MirrorConfig, error) {
415418
scheme := runtime.NewScheme()
416419
_ = mcfgv1.Install(scheme)
420+
_ = v1alpha1.Install(scheme)
421+
_ = configv1.Install(scheme)
422+
_ = configv1alpha1.Install(scheme)
417423

418424
yamlSerializer := serializer.NewSerializerWithOptions(
419425
serializer.DefaultMetaFactory, scheme, scheme,

hypershift-operator/controllers/nodepool/nto_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,3 +1011,88 @@ func makePerformanceProfileStatusAsString(opts ...func(*performanceprofilev2.Per
10111011
b, _ := yaml.Marshal(status)
10121012
return string(b)
10131013
}
1014+
1015+
func TestGetMirrorConfigForManifest(t *testing.T) {
1016+
machineConfig := `
1017+
apiVersion: machineconfiguration.openshift.io/v1
1018+
kind: MachineConfig
1019+
metadata:
1020+
labels:
1021+
machineconfiguration.openshift.io/role: worker
1022+
name: valid-machineconfig
1023+
spec:
1024+
config:
1025+
ignition:
1026+
version: 2.2.0
1027+
storage:
1028+
files:
1029+
- contents:
1030+
source: data:text/plain;base64,dGhyb3dhd2F5Cg==
1031+
filesystem: root
1032+
mode: 493
1033+
path: /some/path
1034+
`
1035+
1036+
containerRuntimeConfig := `
1037+
apiVersion: machineconfiguration.openshift.io/v1
1038+
kind: ContainerRuntimeConfig
1039+
metadata:
1040+
name: valid-containerruntimeconfig
1041+
spec:
1042+
containerRuntimeConfig:
1043+
defaultRuntime: crun
1044+
`
1045+
1046+
kubeletConfig := `
1047+
apiVersion: machineconfiguration.openshift.io/v1
1048+
kind: KubeletConfig
1049+
metadata:
1050+
name: valid-kubeletconfig
1051+
spec:
1052+
kubeletConfig:
1053+
maxPods: 100
1054+
`
1055+
1056+
imageDigestMirrorSet := `
1057+
apiVersion: config.openshift.io/v1
1058+
kind: ImageDigestMirrorSet
1059+
metadata:
1060+
name: valid-idms
1061+
spec:
1062+
imageDigestMirrors:
1063+
- mirrorSourcePolicy: AllowContactingSource
1064+
mirrors:
1065+
- some.registry.io/registry-redhat-io
1066+
source: registry.redhat.io
1067+
`
1068+
1069+
testCases := []struct {
1070+
name string
1071+
input []byte
1072+
}{
1073+
{
1074+
name: "Valid MachineConfig",
1075+
input: []byte(machineConfig),
1076+
},
1077+
{
1078+
name: "Valid ContainerRuntimeConfig",
1079+
input: []byte(containerRuntimeConfig),
1080+
},
1081+
{
1082+
name: "Valid KubeletConfig",
1083+
input: []byte(kubeletConfig),
1084+
},
1085+
{
1086+
name: "Valid ImageDigestMirrorSet",
1087+
input: []byte(imageDigestMirrorSet),
1088+
},
1089+
}
1090+
1091+
for _, tc := range testCases {
1092+
t.Run(tc.name, func(t *testing.T) {
1093+
g := NewWithT(t)
1094+
_, err := getMirrorConfigForManifest(tc.input)
1095+
g.Expect(err).To(BeNil())
1096+
})
1097+
}
1098+
}

0 commit comments

Comments
 (0)