Skip to content

Commit

Permalink
Add rhel-coreos extensions in configmap, propogate to controllerconfig
Browse files Browse the repository at this point in the history
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: openshift/os#763

This makes sure that, if present, the new extensions image gets pushed
through to controllerconfig and is available when merging
machineconfigs.
jkyros committed Aug 15, 2022
1 parent 2b598af commit f52fa42
Showing 8 changed files with 35 additions and 20 deletions.
3 changes: 0 additions & 3 deletions install/0000_80_machine-config-operator_05_osimageurl.yaml
Original file line number Diff line number Diff line change
@@ -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 )
4 changes: 0 additions & 4 deletions install/image-references
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions lib/resourcemerge/machineconfig.go
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions manifests/controllerconfig.crd.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions pkg/apis/machineconfiguration.openshift.io/v1/types.go
Original file line number Diff line number Diff line change
@@ -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"`

1 change: 1 addition & 0 deletions pkg/operator/bootstrap.go
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 2 additions & 0 deletions pkg/operator/images.go
Original file line number Diff line number Diff line change
@@ -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.
36 changes: 23 additions & 13 deletions pkg/operator/sync.go
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit f52fa42

Please sign in to comment.