Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ ENV GOCACHE="/go/rhel8/.cache"
ENV GOMODCACHE="/go/rhel8/pkg/mod"
RUN make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
# This performs the OS image rename process for OKD.
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9 AS manifests
ARG TAGS=""
COPY install /manifests
RUN if [ "${TAGS}" = "fcos" ]; then \
# comment out non-base/extensions image-references entirely for fcos
sed -i '/- name: rhel-coreos-/,+3 s/^/#/' /manifests/image-references && \
# also remove extensions from the osimageurl configmap (if we don't, oc won't rewrite it, and the placeholder value will survive and get used)
sed -i '/baseOSExtensionsContainerImage:/ s/^/#/' /manifests/0000_80_machine-config_05_osimageurl.yaml && \
# rewrite image names for fcos
sed -i 's/rhel-coreos/fedora-coreos/g' /manifests/*; \
elif [ "${TAGS}" = "scos" ]; then \
# rewrite image names for scos
sed -i 's/rhel-coreos/stream-coreos/g' /manifests/*; fi && \
dnf --setopt=keepcache=true -y install 'nmstate >= 2.2.10' && \
COPY hack/rename-os-images.sh /tmp/rename-os-images.sh
COPY hack/confirm-os-image-rename.sh /tmp/confirm-os-image-rename.sh
RUN /tmp/rename-os-images.sh /manifests && /tmp/confirm-os-image-rename.sh /manifests

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
ARG TAGS=""
COPY --from=manifests /manifests /manifests
RUN dnf --setopt=keepcache=true -y install 'nmstate >= 2.2.10' && \
if ! rpm -q util-linux; then dnf install --setopt=keepcache=true -y util-linux; fi && \
# We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
if ! rpm -q buildah; then dnf install --setopt=keepcache=true -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
Expand Down
22 changes: 10 additions & 12 deletions Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ ENV GOCACHE="/go/rhel8/.cache"
ENV GOMODCACHE="/go/rhel8/pkg/mod"
RUN make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
# This performs the OS image rename process for OKD.
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9 AS manifests
ARG TAGS=""
COPY install /manifests
RUN if [ "${TAGS}" = "fcos" ]; then \
# comment out non-base/extensions image-references entirely for fcos
sed -i '/- name: rhel-coreos-/,+3 s/^/#/' /manifests/image-references && \
# also remove extensions from the osimageurl configmap (if we don't, oc won't rewrite it, and the placeholder value will survive and get used)
sed -i '/baseOSExtensionsContainerImage:/ s/^/#/' /manifests/0000_80_machine-config_05_osimageurl.yaml && \
# rewrite image names for fcos
sed -i 's/rhel-coreos/fedora-coreos/g' /manifests/*; \
elif [ "${TAGS}" = "scos" ]; then \
# rewrite image names for scos
sed -i 's/rhel-coreos/stream-coreos/g' /manifests/*; fi && \
dnf --setopt=keepcache=true -y install 'nmstate >= 2.2.10' && \
COPY hack/rename-os-images.sh /tmp/rename-os-images.sh
COPY hack/confirm-os-image-rename.sh /tmp/confirm-os-image-rename.sh
RUN /tmp/rename-os-images.sh /manifests && /tmp/confirm-os-image-rename.sh /manifests

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
ARG TAGS=""
COPY --from=manifests /manifests /manifests
RUN dnf --setopt=keepcache=true -y install 'nmstate >= 2.2.10' && \
if ! rpm -q util-linux; then dnf install --setopt=keepcache=true -y util-linux; fi && \
# We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
if ! rpm -q buildah; then dnf install --setopt=keepcache=true -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
Expand Down
48 changes: 48 additions & 0 deletions hack/confirm-os-image-rename.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# This script acts as a guard for OS image renames in the install (/manifects)
# directory. Based upon the given tags, it searches the files within that
# directory in order to determine whether the correct OS image names are
# present or not. The script will return a non-zero exit code whenever an
# incorrect name is found or an expected name is not found.

target_dir="$1"

should_exist=()
should_not_exist=()

if [ "$TAGS" = "fcos" ]; then
should_not_exist=('rhel-coreos' 'rhel-coreos-extensions' 'rhel-coreos-10' 'rhel-coreos-10-extensions' 'baseOSExtensionsContainerImage')
should_exist+=('fedora-coreos')
fi

if [ "$TAGS" = "scos" ]; then
should_not_exist=('rhel-coreos' 'rhel-coreos-extensions' 'rhel-coreos-10' 'rhel-coreos-10-extensions' 'fedora-coreos')
should_exist=('stream-coreos' 'stream-coreos-extensions')
fi

if [ "$TAGS" != "scos" ] && [ "$TAGS" != "fcos" ]; then
should_exist=('rhel-coreos' 'rhel-coreos-extensions' 'rhel-coreos-10' 'rhel-coreos-10-extensions')
should_not_exist=('stream-coreos' 'stream-coreos-extensions' 'fedora-coreos')
fi

for item in "${should_not_exist[@]}"; do
output="$(grep -F -r "$item" "$target_dir")"
retval="$?"
if [ $retval -eq 0 ]; then
echo "Expected not to find OS image name '$item' in $target_dir:"
echo "$output"
exit "$retval"
fi
done

for item in "${should_exist[@]}"; do
output="$(grep -F -r "$item" "$target_dir")"
retval="$?"
if [ $retval -ne 0 ]; then
echo "Expected to find OS image name '$item' in $target_dir"
exit "$retval"
fi
done

echo "All OS image names are correct"
36 changes: 36 additions & 0 deletions hack/rename-os-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

# This script will rename the OS images within the install (/manifests)
# directory in response to the TAGS env var being set to either fcos or scos.
# If TAGS is empty or set to any other value, this script will no-op.

set -euo

target_dir="${1:-"/manifests"}"
TAGS="${TAGS:-}"

imagerefs="$target_dir/image-references"
osimageurls="$target_dir/0000_80_machine-config_05_osimageurl.yaml"

if [ "${TAGS}" = "fcos" ]; then
# Remove non-base/extensions image-references entirely for fcos. This regex
# will match rhel-coreos-extensions, rhel-coreos-10, and
# rhel-coreos-10-extensions. rhel-coreos is left alone since we need to
# replace it instead of removing it.
sed -i "/- name: rhel-coreos-.*$/,+3d" "$imagerefs"

# Remove extensions from the osimageurl configmap (if we don't, oc won't
# rewrite it, and the placeholder value will survive and get used)
sed -i "/baseOSExtensionsContainerImage:/d" "$osimageurls"

# Rename rhel-coreos to fedora-coreos for fcos
sed -i 's/rhel-coreos/fedora-coreos/g' "$imagerefs" "$osimageurls"
elif [ "${TAGS}" = "scos" ]; then
# Remove RHEL10 entirely for scos
sed -i "/- name: rhel-coreos-10.*$/,+3d" "$imagerefs"

# Rename rhel-coreos to stream-coreos for scos
sed -i 's/rhel-coreos/stream-coreos/g' "$imagerefs" "$osimageurls"
else
echo "'fcos' or 'scos' tags not set, skipping OS image renames"
fi
8 changes: 8 additions & 0 deletions install/image-references
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ spec:
from:
kind: DockerImage
name: placeholder.url.oc.will.replace.this.org/placeholdernamespace:rhel-coreos-extensions
- name: rhel-coreos-10
from:
kind: DockerImage
name: placeholder.url.oc.will.replace.this.org/placeholdernamespace:rhel10-coreos
- name: rhel-coreos-10-extensions
from:
kind: DockerImage
name: placeholder.url.oc.will.replace.this.org/placeholdernamespace:rhel10-coreos-extensions
- name: keepalived-ipfailover
from:
kind: DockerImage
Expand Down