Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use RHEL 9 as the primary builder base for the Machine Config Operator
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.20 AS rhel9-builder
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS rhel9-builder
ARG TAGS=""
WORKDIR /go/src/github.com/openshift/machine-config-operator
COPY . .
Expand All @@ -12,7 +12,7 @@ RUN --mount=type=cache,target=/go/rhel9/.cache,z \
make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .

# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.24-openshift-4.20 AS rhel8-builder
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.24-openshift-4.21 AS rhel8-builder
ARG TAGS=""
WORKDIR /go/src/github.com/openshift/machine-config-operator
# Copy the RHEL 8 machine-config-daemon binary and rename
Expand Down
157 changes: 78 additions & 79 deletions go.mod

Large diffs are not rendered by default.

273 changes: 132 additions & 141 deletions go.sum

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/resourceapply/machineconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestApplyMachineConfig(t *testing.T) {
}
actual := actions[1].(clienttesting.CreateAction).GetObject().(*mcfgv1.MachineConfig)
if !equality.Semantic.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual))
t.Error(diff.Diff(expected, actual))
}
},
}, {
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestApplyMachineConfig(t *testing.T) {
}
actual := actions[1].(clienttesting.UpdateAction).GetObject().(*mcfgv1.MachineConfig)
if !equality.Semantic.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual))
t.Error(diff.Diff(expected, actual))
}
},
}, {
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestApplyMachineConfig(t *testing.T) {
}
actual := actions[1].(clienttesting.UpdateAction).GetObject().(*mcfgv1.MachineConfig)
if !equality.Semantic.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual))
t.Error(diff.Diff(expected, actual))
}
},
}, {
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestApplyMachineConfig(t *testing.T) {
}
actual := actions[1].(clienttesting.UpdateAction).GetObject().(*mcfgv1.MachineConfig)
if !equality.Semantic.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual))
t.Error(diff.Diff(expected, actual))
}
},
}, {
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestApplyMachineConfig(t *testing.T) {
}
actual := actions[1].(clienttesting.UpdateAction).GetObject().(*mcfgv1.MachineConfig)
if !equality.Semantic.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual))
t.Error(diff.Diff(expected, actual))
}
},
}, {
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestApplyMachineConfig(t *testing.T) {
}
actual := actions[1].(clienttesting.UpdateAction).GetObject().(*mcfgv1.MachineConfig)
if !equality.Semantic.DeepEqual(expected, actual) {
t.Error(diff.ObjectDiff(expected, actual))
t.Error(diff.Diff(expected, actual))
}
},
}}
Expand Down
17 changes: 15 additions & 2 deletions pkg/controller/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (

apicfgv1 "github.com/openshift/api/config/v1"
apicfgv1alpha1 "github.com/openshift/api/config/v1alpha1"
"github.com/openshift/api/features"
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
apioperatorsv1alpha1 "github.com/openshift/api/operator/v1alpha1"
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
containerruntimeconfig "github.com/openshift/machine-config-operator/pkg/controller/container-runtime-config"
Expand Down Expand Up @@ -70,11 +72,12 @@ func (b *Bootstrap) Run(destDir string) error {

scheme := runtime.NewScheme()
mcfgv1.Install(scheme)
mcfgv1alpha1.Install(scheme)
apioperatorsv1alpha1.Install(scheme)
apicfgv1.Install(scheme)
apicfgv1alpha1.Install(scheme)
codecFactory := serializer.NewCodecFactory(scheme)
decoder := codecFactory.UniversalDecoder(mcfgv1.GroupVersion, apioperatorsv1alpha1.GroupVersion, apicfgv1.GroupVersion, apicfgv1alpha1.GroupVersion)
decoder := codecFactory.UniversalDecoder(mcfgv1.GroupVersion, mcfgv1alpha1.GroupVersion, apioperatorsv1alpha1.GroupVersion, apicfgv1.GroupVersion, apicfgv1alpha1.GroupVersion)

var (
cconfig *mcfgv1.ControllerConfig
Expand All @@ -91,6 +94,7 @@ func (b *Bootstrap) Run(destDir string) error {
imagePolicies []*apicfgv1.ImagePolicy
imgCfg *apicfgv1.Image
apiServer *apicfgv1.APIServer
iri *mcfgv1alpha1.InternalReleaseImage
)
for _, info := range infos {
if info.IsDir() {
Expand Down Expand Up @@ -154,6 +158,10 @@ func (b *Bootstrap) Run(destDir string) error {
if obj.GetName() == ctrlcommon.APIServerInstanceName {
apiServer = obj
}
case *mcfgv1alpha1.InternalReleaseImage:
if obj.GetName() == ctrlcommon.InternalReleaseImageInstanceName {
iri = obj
}
default:
klog.Infof("skipping %q [%d] manifest because of unhandled %T", file.Name(), idx+1, obji)
}
Expand All @@ -174,7 +182,12 @@ func (b *Bootstrap) Run(destDir string) error {
return fmt.Errorf("error creating feature gates handler: %w", err)
}

iconfigs, err := template.RunBootstrap(b.templatesDir, cconfig, psraw, apiServer)
var internalReleaseImage *mcfgv1alpha1.InternalReleaseImage
if fgHandler != nil && fgHandler.Enabled(features.FeatureGateNoRegistryClusterOperations) {
internalReleaseImage = iri
}

iconfigs, err := template.RunBootstrap(b.templatesDir, cconfig, psraw, apiServer, internalReleaseImage)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ spec:
t.Fatalf("failed to parse manifest: %v", err)
}
if !reflect.DeepEqual(got, test.want) {
t.Fatalf("mismatch found %s", diff.ObjectDiff(got, test.want))
t.Fatalf("mismatch found %s", diff.Diff(got, test.want))
}
})
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const (
// APIServerInstanceName is a singleton name for APIServer configuration
APIServerInstanceName = "cluster"

// InternalReleaseImageInstanceName is a singleton name for InternalReleaseImage configuration
InternalReleaseImageInstanceName = "cluster"

// APIServerInstanceName is a singleton name for APIServer configuration
APIServerBootstrapFileLocation = "/etc/mcs/bootstrap/api-server/api-server.yaml"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func checkAction(expected, actual core.Action, t *testing.T, index int) {

if !equality.Semantic.DeepEqual(expObject, object) {
t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expObject, object))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expObject, object))
}
case core.PatchAction:
e, _ := expected.(core.PatchAction)
Expand All @@ -427,7 +427,7 @@ func checkAction(expected, actual core.Action, t *testing.T, index int) {

if !equality.Semantic.DeepEqual(expPatch, patch) {
t.Errorf("Action %s %s has wrong patch\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expPatch, patch))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expPatch, patch))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/container-runtime-config/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ func TestUpdatePolicyJSON(t *testing.T) {
return
}
if !reflect.DeepEqual(gotConf, tt.want) {
t.Errorf("updatePolicyJSON() Diff:\n %s", diff.ObjectGoPrintDiff(tt.want, gotConf))
t.Errorf("updatePolicyJSON() Diff:\n %s", diff.Diff(tt.want, gotConf))
}
// Ensure that the generated configuration is actually valid.
_, err = signature.NewPolicyFromBytes(got)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ func (f *fixture) validateMachineConfig() {
require.NoError(f.t, err)
if !equality.Semantic.DeepEqual(actualKubeletConfig.FeatureGates, expectedKubeletConfig.FeatureGates) {
f.t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
actual.GetVerb(), actual.GetResource().Resource, diff.ObjectGoPrintDiff(actualKubeletConfig.FeatureGates, expectedKubeletConfig.FeatureGates))
actual.GetVerb(), actual.GetResource().Resource, diff.Diff(actualKubeletConfig.FeatureGates, expectedKubeletConfig.FeatureGates))
}
if !equality.Semantic.DeepEqual(actualKubeletConfig.MaxPods, expectedKubeletConfig.MaxPods) {
f.t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
actual.GetVerb(), actual.GetResource().Resource, diff.ObjectGoPrintDiff(actualKubeletConfig.MaxPods, expectedKubeletConfig.MaxPods))
actual.GetVerb(), actual.GetResource().Resource, diff.Diff(actualKubeletConfig.MaxPods, expectedKubeletConfig.MaxPods))
}
}
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func checkAction(expected, actual core.Action, t *testing.T, index int) {

if !equality.Semantic.DeepEqual(expObject, object) {
t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expObject, object))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expObject, object))
}
case core.PatchAction:
e, _ := expected.(core.PatchAction)
Expand All @@ -392,7 +392,7 @@ func checkAction(expected, actual core.Action, t *testing.T, index int) {

if !equality.Semantic.DeepEqual(expPatch, patch) {
t.Errorf("Action %s %s has wrong patch\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expPatch, patch))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expPatch, patch))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/render/render_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func checkAction(expected, actual core.Action, t *testing.T) {

if !equality.Semantic.DeepEqual(expObject, object) {
t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expObject, object))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expObject, object))
}
case core.UpdateAction:
e, _ := expected.(core.UpdateAction)
Expand All @@ -179,7 +179,7 @@ func checkAction(expected, actual core.Action, t *testing.T) {

if !equality.Semantic.DeepEqual(expObject, object) {
t.Errorf("Action %s %s has wrong object\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expObject, object))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expObject, object))
}
case core.PatchAction:
e, _ := expected.(core.PatchAction)
Expand All @@ -188,7 +188,7 @@ func checkAction(expected, actual core.Action, t *testing.T) {

if !equality.Semantic.DeepEqual(expPatch, expPatch) {
t.Errorf("Action %s %s has wrong patch\nDiff:\n %s",
a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintDiff(expPatch, patch))
a.GetVerb(), a.GetResource().Resource, diff.Diff(expPatch, patch))
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions pkg/controller/template/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/openshift/library-go/pkg/cloudprovider"

mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
"github.com/openshift/machine-config-operator/pkg/constants"
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
"github.com/openshift/machine-config-operator/pkg/version"
Expand All @@ -43,9 +44,10 @@ const (
// RenderConfig is wrapper around ControllerConfigSpec.
type RenderConfig struct {
*mcfgv1.ControllerConfigSpec
PullSecret string
TLSMinVersion string
TLSCipherSuites []string
PullSecret string
TLSMinVersion string
TLSCipherSuites []string
InternalReleaseImage *mcfgv1alpha1.InternalReleaseImage

// no need to set this, will be automatically configured
Constants map[string]string
Expand All @@ -63,6 +65,7 @@ const (
workerRole = "worker"
arbiterRole = "arbiter"
cloudPlatformAltDNS = "cloud-platform-alt-dns"
iri = "internalreleaseimage"
)

// generateTemplateMachineConfigs returns MachineConfig objects from the templateDir and a config object
Expand Down Expand Up @@ -254,6 +257,10 @@ func getPaths(config *RenderConfig, platformString string) []string {
platformBasedPaths = append(platformBasedPaths, tnf)
}

if config.InternalReleaseImage != nil {
platformBasedPaths = append(platformBasedPaths, iri)
}

return platformBasedPaths
}

Expand Down
16 changes: 10 additions & 6 deletions pkg/controller/template/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestCloudProvider(t *testing.T) {
},
}

got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, name, dummyTemplate)
got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil, nil}, name, dummyTemplate)
if err != nil {
t.Fatalf("expected nil error %v", err)
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestCredentialProviderConfigFlag(t *testing.T) {
},
}

got, err := renderTemplate(RenderConfig{&config.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, name, dummyTemplate)
got, err := renderTemplate(*dummyRenderConfig(config), name, dummyTemplate)
if err != nil {
t.Fatalf("expected nil error %v", err)
}
Expand Down Expand Up @@ -239,14 +239,14 @@ func TestInvalidPlatform(t *testing.T) {

// we must treat unrecognized constants as "none"
controllerConfig.Spec.Infra.Status.PlatformStatus.Type = "_bad_"
_, err = generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, templateDir)
_, err = generateTemplateMachineConfigs(dummyRenderConfig(controllerConfig), templateDir)
if err != nil {
t.Errorf("expect nil error, got: %v", err)
}

// explicitly blocked
controllerConfig.Spec.Infra.Status.PlatformStatus.Type = "_base"
_, err = generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, templateDir)
_, err = generateTemplateMachineConfigs(dummyRenderConfig(controllerConfig), templateDir)
expectErr(err, "failed to create MachineConfig for role master: platform _base unsupported")
}

Expand All @@ -257,7 +257,7 @@ func TestGenerateMachineConfigs(t *testing.T) {
t.Fatalf("failed to get controllerconfig config: %v", err)
}

cfgs, err := generateTemplateMachineConfigs(&RenderConfig{&controllerConfig.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, templateDir)
cfgs, err := generateTemplateMachineConfigs(dummyRenderConfig(controllerConfig), templateDir)
if err != nil {
t.Fatalf("failed to generate machine configs: %v", err)
}
Expand Down Expand Up @@ -438,14 +438,18 @@ func TestGetPaths(t *testing.T) {
}
c.res = append(c.res, platformBase)

got := getPaths(&RenderConfig{&config.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil}, config.Spec.Platform)
got := getPaths(dummyRenderConfig(config), config.Spec.Platform)
if reflect.DeepEqual(got, c.res) {
t.Fatalf("mismatch got: %s want: %s", got, c.res)
}
})
}
}

func dummyRenderConfig(config *mcfgv1.ControllerConfig) *RenderConfig {
return &RenderConfig{&config.Spec, `{"dummy":"dummy"}`, "dummy", nil, nil, nil}
}

func controllerConfigFromFile(path string) (*mcfgv1.ControllerConfig, error) {
data, err := os.ReadFile(path)
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions pkg/controller/template/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
mcfgclientset "github.com/openshift/client-go/machineconfiguration/clientset/versioned"
"github.com/openshift/client-go/machineconfiguration/clientset/versioned/scheme"
mcfginformersv1 "github.com/openshift/client-go/machineconfiguration/informers/externalversions/machineconfiguration/v1"
Expand Down Expand Up @@ -633,7 +634,7 @@ func (ctrl *Controller) syncControllerConfig(key string) error {
return ctrl.syncFailingStatus(cfg, err)
}

mcs, err := getMachineConfigsForControllerConfig(ctrl.templatesDir, cfg, clusterPullSecretRaw, apiServer)
mcs, err := getMachineConfigsForControllerConfig(ctrl.templatesDir, cfg, clusterPullSecretRaw, apiServer, nil)
if err != nil {
return ctrl.syncFailingStatus(cfg, err)
}
Expand All @@ -652,7 +653,7 @@ func (ctrl *Controller) syncControllerConfig(key string) error {
return ctrl.syncCompletedStatus(cfg)
}

func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.ControllerConfig, clusterPullSecretRaw []byte, apiServer *configv1.APIServer) ([]*mcfgv1.MachineConfig, error) {
func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.ControllerConfig, clusterPullSecretRaw []byte, apiServer *configv1.APIServer, iri *mcfgv1alpha1.InternalReleaseImage) ([]*mcfgv1.MachineConfig, error) {
buf := &bytes.Buffer{}
if err := json.Compact(buf, clusterPullSecretRaw); err != nil {
return nil, fmt.Errorf("couldn't compact pullsecret %q: %w", string(clusterPullSecretRaw), err)
Expand All @@ -663,6 +664,7 @@ func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.Co
PullSecret: string(buf.Bytes()),
TLSMinVersion: tlsMinVersion,
TLSCipherSuites: tlsCipherSuites,
InternalReleaseImage: iri,
}
mcs, err := generateTemplateMachineConfigs(rc, templatesDir)
if err != nil {
Expand All @@ -679,6 +681,6 @@ func getMachineConfigsForControllerConfig(templatesDir string, config *mcfgv1.Co
}

// RunBootstrap runs the tempate controller in boostrap mode.
func RunBootstrap(templatesDir string, config *mcfgv1.ControllerConfig, pullSecretRaw []byte, apiServer *configv1.APIServer) ([]*mcfgv1.MachineConfig, error) {
return getMachineConfigsForControllerConfig(templatesDir, config, pullSecretRaw, apiServer)
func RunBootstrap(templatesDir string, config *mcfgv1.ControllerConfig, pullSecretRaw []byte, apiServer *configv1.APIServer, iri *mcfgv1alpha1.InternalReleaseImage) ([]*mcfgv1.MachineConfig, error) {
return getMachineConfigsForControllerConfig(templatesDir, config, pullSecretRaw, apiServer, iri)
}
Loading