diff --git a/control-plane-operator/controllers/hostedcontrolplane/cvo/reconcile.go b/control-plane-operator/controllers/hostedcontrolplane/cvo/reconcile.go index e080fcd3ba..db144d9376 100644 --- a/control-plane-operator/controllers/hostedcontrolplane/cvo/reconcile.go +++ b/control-plane-operator/controllers/hostedcontrolplane/cvo/reconcile.go @@ -2,6 +2,7 @@ package cvo import ( "fmt" + "k8s.io/apimachinery/pkg/util/sets" "path" "strings" @@ -304,18 +305,23 @@ func preparePayloadScript(platformType hyperv1.PlatformType, oauthEnabled bool) } func cvoBootstrapScript(clusterID string) string { - filtered := make([]string, 0) - for _, capability := range configv1.KnownClusterVersionCapabilities { - if capability != configv1.ClusterVersionCapabilityImageRegistry { - filtered = append(filtered, string(capability)) + enabledCaps := sets.New[configv1.ClusterVersionCapability]( + configv1.ClusterVersionCapabilitySets[configv1.ClusterVersionCapabilitySetCurrent]...) + enabledCaps = enabledCaps.Delete(configv1.ClusterVersionCapabilityImageRegistry) + + capabilities := strings.Builder{} + capList := enabledCaps.UnsortedList() + for i, capability := range capList { + capabilities.WriteString(string(capability)) + if i != len(capList)-1 { + capabilities.WriteString(",") } } - capabilities := strings.Join(filtered, ", ") payloadDir := volumeMounts.Path(cvoContainerBootstrap().Name, cvoVolumePayload().Name) var scriptTemplate = `#!/bin/bash set -euo pipefail -cat > /tmp/clusterversion.yaml < /tmp/clusterversion.yaml <<-EOF apiVersion: config.openshift.io/v1 kind: ClusterVersion metadata: @@ -325,6 +331,7 @@ spec: baselineCapabilitySet: 'None' additionalEnabledCapabilities: [%s] clusterID: %s + EOF oc get ns openshift-config &> /dev/null || oc create ns openshift-config oc get ns openshift-config-managed &> /dev/null || oc create ns openshift-config-managed @@ -338,7 +345,7 @@ while true; do done oc get clusterversion/version &> /dev/null || oc create -f /tmp/clusterversion.yaml ` - return fmt.Sprintf(scriptTemplate, clusterID, capabilities, payloadDir) + return fmt.Sprintf(scriptTemplate, capabilities.String(), clusterID, payloadDir) } func buildCVOContainerMain(image, releaseImage, namespace string, updateService configv1.URL, enableCVOManagementClusterMetricsAccess bool) func(c *corev1.Container) {