-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MCO-2163: use machine-config-osimagestream to avoid hard-coding image tag names #10416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,13 +4,62 @@ set -euo pipefail | |
| # shellcheck source=release-image.sh.template | ||
| . /usr/local/bin/release-image.sh | ||
|
|
||
| # yuck... this is a good argument for renaming the node image to just `node` in both OCP and OKD | ||
| coreos_img={{.StreamTag}} | ||
| until COREOS_IMAGE=$(image_for ${coreos_img}); do | ||
| echo 'Failed to query release image; retrying...' | ||
| # Get the Machine Config Operator image from the release payload | ||
| until MCO_IMAGE=$(image_for 'machine-config-operator'); do | ||
| echo 'Failed to query MCO image from release; retrying...' | ||
| sleep 10 | ||
| done | ||
|
|
||
| # Create temporary directory for binary extraction | ||
| TEMP_DIR=$(mktemp -d) | ||
|
|
||
| MCO_CONTAINER_ID= | ||
|
|
||
| cleanup_mco() { | ||
| # Ensure that the MCO container is removed. | ||
| if [[ -n "${MCO_CONTAINER_ID}" ]]; then | ||
| podman container rm -f "${MCO_CONTAINER_ID}" >/dev/null 2>&1 || true | ||
| MCO_CONTAINER_ID= | ||
| fi | ||
|
|
||
| # Delete the MCO container image to conserve memory. | ||
| if [[ -n "${MCO_IMAGE}" ]]; then | ||
| podman image rm -f "${MCO_IMAGE}" >/dev/null 2>&1 || true | ||
| MCO_IMAGE= | ||
| fi | ||
|
|
||
| # Delete the tempdir. | ||
| if [[ -n "${TEMP_DIR}" ]]; then | ||
| rm -rf "${TEMP_DIR}" | ||
| TEMP_DIR= | ||
| fi | ||
| } | ||
| trap cleanup_mco EXIT | ||
|
|
||
| echo "Extracting machine-config-osimagestream binary to ${TEMP_DIR}" | ||
|
|
||
| MCO_CONTAINER_ID="$(podman create "${MCO_IMAGE}")" | ||
| # Extract the machine-config-osimagestream binary from the MCO image. This avoids having to munge podman args, paths, env vars, etc. | ||
| podman cp "${MCO_CONTAINER_ID}":/usr/bin/machine-config-osimagestream "${TEMP_DIR}/machine-config-osimagestream" | ||
|
|
||
| # Execute the binary to get the CoreOS image pullspec | ||
| # Note: Proxy environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) are | ||
| # automatically inherited from the environment if set via /etc/profile.d/proxy.sh | ||
| until COREOS_IMAGE=$("${TEMP_DIR}/machine-config-osimagestream" \ | ||
| get os-image-pullspec \ | ||
| --release-image "${RELEASE_IMAGE_DIGEST}" \ | ||
| --authfile /root/.docker/config.json \ | ||
| --per-host-certs /etc/containers/certs.d \ | ||
| --osimagestream-name '{{ .OSImageStream }}' \ | ||
| --trust-bundle /etc/pki/ca-trust/source/anchors \ | ||
| --registry-config /etc/containers/registries.conf); do | ||
|
Comment on lines
+51
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we rely on the defaults? (Just asking not a blocking question or ask for change)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #10406, I don't think we can rely on the defaults since |
||
| echo 'Failed to query for OS image pullspec; retrying...' | ||
| sleep 10 | ||
| done | ||
|
|
||
| # Clean up the MCO container, image, and temp dir now that we have the pullspec. | ||
| cleanup_mco | ||
|
|
||
| # need to use rpm-ostree here since `bootc status` doesn't work in the live ISO currently | ||
| # https://github.com/containers/bootc/issues/1043 | ||
| booted_version=$(rpm-ostree status --json | jq -r .deployments[0].version) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but note this adds another image we have to pull down here before we get to pivot. So I expect this to slightly affect bootstrapping time.
I guess this is pretty far along now, but wouldn't a cleaner design here be to put the
machine-config-osimagestreamhelper stuff in the CVO? It already has animagecommand (which is whatimage_foruses) that's very similar to what we need here. E.g. a new command likeosimage --stream {{ .OSImageStream }}which returns the pullspec of the right OS image.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree that the CVO would be a better long-term place for this to live. The bigger problem that we'll need to solve is that there is some common code for working with OSImageStreams that would need to live in both the CVO and the MCO. And ideally, we'd be able to find a home for that code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing a little golang package import can't solve I would think? :)