From f52fa42c032e68d0e7b72ecad1d602155448afbb Mon Sep 17 00:00:00 2001 From: John Kyros <79665180+jkyros@users.noreply.github.com> Date: Fri, 8 Jul 2022 18:48:38 -0500 Subject: [PATCH] Add `rhel-coreos` extensions in configmap, propogate to controllerconfig The extensions for our layered/bootable `rhel-coreos` images are no longer going to be contained within the image themselves. They will be a separate container. See: https://github.com/openshift/os/pull/763 This makes sure that, if present, the new extensions image gets pushed through to controllerconfig and is available when merging machineconfigs. --- ...machine-config-operator_05_osimageurl.yaml | 3 -- install/image-references | 4 --- lib/resourcemerge/machineconfig.go | 2 ++ manifests/controllerconfig.crd.yaml | 4 +++ .../v1/types.go | 3 ++ pkg/operator/bootstrap.go | 1 + pkg/operator/images.go | 2 ++ pkg/operator/sync.go | 36 ++++++++++++------- 8 files changed, 35 insertions(+), 20 deletions(-) diff --git a/install/0000_80_machine-config-operator_05_osimageurl.yaml b/install/0000_80_machine-config-operator_05_osimageurl.yaml index d1fe31e2a0..f0eb977480 100644 --- a/install/0000_80_machine-config-operator_05_osimageurl.yaml +++ b/install/0000_80_machine-config-operator_05_osimageurl.yaml @@ -9,9 +9,6 @@ metadata: include.release.openshift.io/single-node-developer: "true" data: releaseVersion: 0.0.1-snapshot - # This (will eventually) replace the below when https://github.com/openshift/enhancements/pull/1032 - # progresses towards the default. - baseOperatingSystemContainer: "registry.ci.openshift.org/openshift:rhel-coreos" # The OS payload used for 4.10 and below; more information in # https://github.com/openshift/machine-config-operator/blob/master/docs/OSUpgrades.md # (The original issue was https://github.com/openshift/machine-config-operator/issues/183 ) diff --git a/install/image-references b/install/image-references index 85605021b8..b186e81c1f 100644 --- a/install/image-references +++ b/install/image-references @@ -23,10 +23,6 @@ spec: from: kind: DockerImage name: registry.svc.ci.openshift.org/openshift:machine-os-content - - name: rhel-coreos - from: - kind: DockerImage - name: registry.ci.openshift.org/openshift:rhel-coreos - name: keepalived-ipfailover from: kind: DockerImage diff --git a/lib/resourcemerge/machineconfig.go b/lib/resourcemerge/machineconfig.go index 34ff0c12fe..c3aed344a1 100644 --- a/lib/resourcemerge/machineconfig.go +++ b/lib/resourcemerge/machineconfig.go @@ -72,6 +72,8 @@ func ensureControllerConfigSpec(modified *bool, existing *mcfgv1.ControllerConfi resourcemerge.SetStringIfSet(modified, &existing.Platform, required.Platform) resourcemerge.SetStringIfSet(modified, &existing.EtcdDiscoveryDomain, required.EtcdDiscoveryDomain) resourcemerge.SetStringIfSet(modified, &existing.OSImageURL, required.OSImageURL) + resourcemerge.SetStringIfSet(modified, &existing.BaseOperatingSystemContainer, required.BaseOperatingSystemContainer) + resourcemerge.SetStringIfSet(modified, &existing.BaseOperatingSystemExtensionsContainer, required.BaseOperatingSystemExtensionsContainer) resourcemerge.SetStringIfSet(modified, &existing.NetworkType, required.NetworkType) setBytesIfSet(modified, &existing.AdditionalTrustBundle, required.AdditionalTrustBundle) diff --git a/manifests/controllerconfig.crd.yaml b/manifests/controllerconfig.crd.yaml index 29cb49da3c..e323c05abb 100644 --- a/manifests/controllerconfig.crd.yaml +++ b/manifests/controllerconfig.crd.yaml @@ -922,6 +922,10 @@ spec: description: baseOperatingSystemContainer is the new format operating system update image. See https://github.com/openshift/enhancements/pull/1032 type: string + baseOperatingSystemExtensionsContainer: + description: baseOperatingSystemExtensionsContainer is the extensions container matching new format operating system update image. + See https://github.com/openshift/enhancements/pull/1032 + type: string platform: description: platform is deprecated, use Infra.Status.PlatformStatus.Type instead diff --git a/pkg/apis/machineconfiguration.openshift.io/v1/types.go b/pkg/apis/machineconfiguration.openshift.io/v1/types.go index 986bcaef68..183f310ad2 100644 --- a/pkg/apis/machineconfiguration.openshift.io/v1/types.go +++ b/pkg/apis/machineconfiguration.openshift.io/v1/types.go @@ -75,6 +75,9 @@ type ControllerConfigSpec struct { // BaseOperatingSystemContainer is the new-format container image for operating system updates. BaseOperatingSystemContainer string `json:"baseOperatingSystemContainer"` + // BaseOperatingSystemExtensionsContainer is the matching extensions container for the new-format container + BaseOperatingSystemExtensionsContainer string `json:"baseOperatingSystemExtensionsContainer"` + // OSImageURL is the old-format container image that contains the OS update payload. OSImageURL string `json:"osImageURL"` diff --git a/pkg/operator/bootstrap.go b/pkg/operator/bootstrap.go index eb7188c24d..d83cd6a586 100644 --- a/pkg/operator/bootstrap.go +++ b/pkg/operator/bootstrap.go @@ -140,6 +140,7 @@ func RenderBootstrap( spec.PullSecret = nil spec.OSImageURL = imgs.MachineOSContent spec.BaseOperatingSystemContainer = imgs.BaseOperatingSystemContainer + spec.BaseOperatingSystemExtensionsContainer = imgs.BaseOperatingSystemExtensionsContainer spec.ReleaseImage = releaseImage spec.Images = map[string]string{ templatectrl.MachineConfigOperatorKey: imgs.MachineConfigOperator, diff --git a/pkg/operator/images.go b/pkg/operator/images.go index f9790f7b42..33a997705b 100644 --- a/pkg/operator/images.go +++ b/pkg/operator/images.go @@ -19,6 +19,8 @@ type RenderConfigImages struct { MachineOSContent string `json:"machineOSContent"` // The new format image BaseOperatingSystemContainer string `json:"baseOperatingSystemContainer"` + // The matching extensions container for the new format image + BaseOperatingSystemExtensionsContainer string `json:"baseOperatingSystemExtensionsContainer"` // These have to be named differently from the ones in ControllerConfigImages // or we get errors about ambiguous selectors because both structs are // combined in the Images struct. diff --git a/pkg/operator/sync.go b/pkg/operator/sync.go index 680aa2da0b..fdedceacc9 100644 --- a/pkg/operator/sync.go +++ b/pkg/operator/sync.go @@ -255,12 +255,13 @@ func (optr *Operator) syncRenderConfig(_ *renderConfig) error { // sync up os image url // TODO: this should probably be part of the imgs - oscontainer, osimageurl, err := optr.getOsImageURLs(optr.namespace) + oscontainer, osextensionscontainer, osimageurl, err := optr.getOsImageURLs(optr.namespace) if err != nil { return err } imgs.MachineOSContent = osimageurl imgs.BaseOperatingSystemContainer = oscontainer + imgs.BaseOperatingSystemExtensionsContainer = osextensionscontainer // sync up the ControllerConfigSpec infra, network, proxy, dns, err := optr.getGlobalConfig() @@ -310,6 +311,7 @@ func (optr *Operator) syncRenderConfig(_ *renderConfig) error { spec.PullSecret = &corev1.ObjectReference{Namespace: "openshift-config", Name: "pull-secret"} spec.OSImageURL = imgs.MachineOSContent spec.BaseOperatingSystemContainer = imgs.BaseOperatingSystemContainer + spec.BaseOperatingSystemExtensionsContainer = imgs.BaseOperatingSystemExtensionsContainer spec.Images = map[string]string{ templatectrl.MachineConfigOperatorKey: imgs.MachineConfigOperator, @@ -690,7 +692,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(_ *renderConfig) error { _, hasRequiredPoolLabel := pool.Labels[requiredForUpgradeMachineConfigPoolLabelKey] if hasRequiredPoolLabel { - _, opURL, err := optr.getOsImageURLs(optr.namespace) + _, _, opURL, err := optr.getOsImageURLs(optr.namespace) if err != nil { glog.Errorf("Error getting configmap osImageURL: %q", err) return false, nil @@ -861,26 +863,34 @@ func (optr *Operator) waitForControllerConfigToBeCompleted(resource *mcfgv1.Cont return nil } -// getOsImageURLs returns (new type, old type) for operating system update images. -func (optr *Operator) getOsImageURLs(namespace string) (string, string, error) { +// getOsImageURLs returns (new type, new extensions, old type) for operating system update images. +func (optr *Operator) getOsImageURLs(namespace string) (string, string, string, error) { cm, err := optr.mcoCmLister.ConfigMaps(namespace).Get(osImageConfigMapName) if err != nil { - return "", "", err + return "", "", "", err } releaseVersion := cm.Data["releaseVersion"] optrVersion, _ := optr.vStore.Get("operator") if releaseVersion != optrVersion { - return "", "", fmt.Errorf("refusing to read osImageURL version %q, operator version %q", releaseVersion, optrVersion) + return "", "", "", fmt.Errorf("refusing to read osImageURL version %q, operator version %q", releaseVersion, optrVersion) } - newformat, ok := cm.Data["baseOperatingSystemContainer"] - if !ok { - return "", "", fmt.Errorf("Missing baseOperatingSystemContainer from configmap") + + newextensions, hasNewExtensions := cm.Data["baseOperatingSystemExtensionsContainer"] + + newformat, hasNewFormat := cm.Data["baseOperatingSystemContainer"] + + oldformat, hasOldFormat := cm.Data["osImageURL"] + + if hasNewFormat && !hasNewExtensions { + // TODO(jkyros): This is okay for now because it's not required, but someday this will be bad } - oldformat := cm.Data["osImageURL"] - if !ok { - return "", "", fmt.Errorf("Missing osImageURL from configmap") + + // If we don't have a new format image, and we can't fall back to the old one + if !hasOldFormat && !hasNewFormat { + return "", "", "", fmt.Errorf("Missing baseOperatingSystemContainer and osImageURL from configmap") } - return newformat, oldformat, nil + + return newformat, newextensions, oldformat, nil } func (optr *Operator) getCAsFromConfigMap(namespace, name, key string) ([]byte, error) {