Skip to content

Commit 1b100f7

Browse files
committed
control-plane-operator/controllers/hostedcontrolplane/v2/cvo: Consume include.release.openshift.io/hypershift-bootstrap annotation
The cluster-version operator has a complicated system for deciding whether a given release-image manifest should be managed in the current cluster [1,2]. Implementing that system here, or even using library-go and remembering to vendor-bump here, both seem like an annoying maintenance load. We could use the CVO's render command like the standalone installer [3,4], but that logic is fairly complicated because it needs to generate all the artifacts necessary for bootstrap MachineConfig rendering, or the production machine-config operator will complain about MachineConfigPools requesting rendered-... MachineConfig that don't exist. All we actually need out of the bootstrap container are the resources that the cluster-version operator needs to launch and run, which are labeled with the grep target since [5]. That avoids installing anything the cluster doesn't actually need here by mistake. Once the production CVO container starts, it will apply the remaining resources that the cluster actually needs. I'm also dropping the openshift-config and openshift-config-managed Namespace creation. They are from a30db71 (Refactor cluster-version-operator, 2024-11-18, openshift#5125), but that commit doesn't explain why they were added or hint at where they lived before (if anywhere). I would expect the cluster-version operator to be able to create those Namespaces from the release-image manifests when they are needed, as with other cluster resources. [1]: https://github.com/openshift/enhancements/blob/2b38513b8661632f08e64f4acc3b856e842f8669/dev-guide/cluster-version-operator/dev/operators.md#manifest-inclusion-annotations [2]: https://github.com/openshift/library-go/blob/ac826d10cb4081fe3034b027863c08953d95f602/pkg/manifest/manifest.go#L296-L376 [3]: https://github.com/openshift/installer/blob/a300d8c0e9d9d566a85740244a7da74d3d63e23c/data/data/bootstrap/files/usr/local/bin/bootkube.sh.template#L189-L216 [4]: https://github.com/openshift/cluster-version-operator/blob/eaf28f5165bde27435b0f0c9a69458677034a58d/pkg/payload/render.go [5]: openshift/cluster-version-operator#1352
1 parent 8eaac17 commit 1b100f7

2 files changed

Lines changed: 2 additions & 47 deletions

File tree

control-plane-operator/controllers/hostedcontrolplane/v2/assets/cluster-version-operator/deployment.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,9 @@ spec:
9191
cat > /tmp/clusterversion.json <<EOF
9292
${CLUSTER_VERSION_JSON}
9393
EOF
94-
oc get ns openshift-config &> /dev/null || oc create ns openshift-config
95-
oc get ns openshift-config-managed &> /dev/null || oc create ns openshift-config-managed
96-
oc apply -f /var/payload/manifests/0000_00_cluster-version-operator_01_clusterversions*
97-
oc apply -f /tmp/clusterversion.json
98-
while true; do
94+
while test -z "$(oc get -o jsonpath='{.status.history[0].version}' clusterversions.config.openshift.io version)"; do
9995
echo "Applying CVO bootstrap manifests..."
100-
if oc apply -f /var/payload/manifests; then
96+
if oc create -f $(grep -rl include.release.openshift.io/hypershift-bootstrap /var/payload/manifests); then
10197
echo "Bootstrap manifests applied successfully."
10298
break
10399
fi

control-plane-operator/controllers/hostedcontrolplane/v2/cvo/deployment.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -199,47 +199,6 @@ func preparePayloadScript(platformType hyperv1.PlatformType, oauthEnabled bool,
199199
fmt.Sprintf("cp -R /release-manifests %s/", payloadDir),
200200
)
201201

202-
// NOTE: We would need part of the manifest.Include logic (https://github.com/openshift/library-go/blob/0064ad7bd060b9fd52f7840972c1d3e72186d0f0/pkg/manifest/manifest.go#L190-L196)
203-
// to properly evaluate which CVO manifests to select based on featureset. In the absence of that logic, use simple filename filtering, which is not ideal
204-
// but better than nothing. Ideally, we filter based on the feature-set annotation in the manifests.
205-
switch featureSet {
206-
case configv1.Default, "":
207-
stmts = append(stmts,
208-
fmt.Sprintf("rm -f %s/manifests/*-CustomNoUpgrade*.yaml", payloadDir),
209-
fmt.Sprintf("rm -f %s/manifests/*-DevPreviewNoUpgrade*.yaml", payloadDir),
210-
fmt.Sprintf("rm -f %s/manifests/*-TechPreviewNoUpgrade*.yaml", payloadDir),
211-
fmt.Sprintf("rm -f %s/manifests/*-OKD*.yaml", payloadDir),
212-
)
213-
case configv1.CustomNoUpgrade:
214-
stmts = append(stmts,
215-
fmt.Sprintf("rm -f %s/manifests/*-Default*.yaml", payloadDir),
216-
fmt.Sprintf("rm -f %s/manifests/*-DevPreviewNoUpgrade*.yaml", payloadDir),
217-
fmt.Sprintf("rm -f %s/manifests/*-TechPreviewNoUpgrade*.yaml", payloadDir),
218-
fmt.Sprintf("rm -f %s/manifests/*-OKD*.yaml", payloadDir),
219-
)
220-
case configv1.DevPreviewNoUpgrade:
221-
stmts = append(stmts,
222-
fmt.Sprintf("rm -f %s/manifests/*-Default*.yaml", payloadDir),
223-
fmt.Sprintf("rm -f %s/manifests/*-CustomNoUpgrade*.yaml", payloadDir),
224-
fmt.Sprintf("rm -f %s/manifests/*-TechPreviewNoUpgrade*.yaml", payloadDir),
225-
fmt.Sprintf("rm -f %s/manifests/*-OKD*.yaml", payloadDir),
226-
)
227-
case configv1.TechPreviewNoUpgrade:
228-
stmts = append(stmts,
229-
fmt.Sprintf("rm -f %s/manifests/*-Default*.yaml", payloadDir),
230-
fmt.Sprintf("rm -f %s/manifests/*-CustomNoUpgrade*.yaml", payloadDir),
231-
fmt.Sprintf("rm -f %s/manifests/*-DevPreviewNoUpgrade*.yaml", payloadDir),
232-
fmt.Sprintf("rm -f %s/manifests/*-OKD*.yaml", payloadDir),
233-
)
234-
case configv1.OKD:
235-
stmts = append(stmts,
236-
fmt.Sprintf("rm -f %s/manifests/*-Default*.yaml", payloadDir),
237-
fmt.Sprintf("rm -f %s/manifests/*-CustomNoUpgrade*.yaml", payloadDir),
238-
fmt.Sprintf("rm -f %s/manifests/*-DevPreviewNoUpgrade*.yaml", payloadDir),
239-
fmt.Sprintf("rm -f %s/manifests/*-TechPreviewNoUpgrade*.yaml", payloadDir),
240-
)
241-
}
242-
243202
for _, manifest := range manifestsToOmit {
244203
if platformType == hyperv1.IBMCloudPlatform || platformType == hyperv1.PowerVSPlatform {
245204
if manifest == "0000_50_cluster-storage-operator_10_deployment-ibm-cloud-managed.yaml" || manifest == "0000_50_cluster-csi-snapshot-controller-operator_07_deployment-ibm-cloud-managed.yaml" {

0 commit comments

Comments
 (0)