Skip to content
Open
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
4 changes: 2 additions & 2 deletions Containerfile.helpers-ci
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-builder-multi-openshift-4.18 AS builder
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS builder
ENV GOCACHE="/go/.cache" \
GOMODCACHE="/go/pkg/mod"
WORKDIR /go/src/github.com/openshift/machine-config-operator
Expand All @@ -7,5 +7,5 @@ RUN --mount=type=cache,target=/go/.cache,z \
--mount=type=cache,target=/go/pkg/mod,z \
make install-helpers DESTDIR=/helpers

FROM registry.ci.openshift.org/ocp/builder:rhel-9-enterprise-base-multi-openshift-4.18 AS final
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9 AS final
COPY --from=builder /helpers/usr/bin /usr/bin
3 changes: 2 additions & 1 deletion Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ RUN --mount=type=cache,target=/var/cache/dnf,z \
# Create the build user which will be used for doing OS image builds. We
# use the username "build" and the uid 1000 since this matches what is in
# the official Buildah image.
useradd --uid 1000 build
# Conditional checks if "build" user does not exist before adding user.
if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi
# Copy the binaries *after* we install nmstate so we don't invalidate our cache for local builds.
COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9.tar /tmp/instroot-rhel9.tar
RUN cd / && tar xf /tmp/instroot-rhel9.tar && rm -f /tmp/instroot-rhel9.tar
Expand Down
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ PREFIX ?= /usr
GO111MODULE?=on
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

# Find all of the test OS image Containerfiles so they can be built.
CUSTOM_OS_TEST_IMAGE_DIR := $(E2E_ROOT_DIR)/custom-os-images
CUSTOM_OS_TEST_CONTAINERFILES := $(wildcard $(CUSTOM_OS_TEST_IMAGE_DIR)/Containerfile.*)
CUSTOM_OS_TEST_IMAGE_NAMES := $(patsubst $(CUSTOM_OS_TEST_IMAGE_DIR)/Containerfile.%,%,$(CUSTOM_OS_TEST_CONTAINERFILES))

# Copied from coreos-assembler
GOARCH := $(shell uname -m)
ifeq ($(GOARCH),x86_64)
Expand All @@ -30,7 +35,7 @@ GOTAGS = "containers_image_openpgp exclude_graphdriver_devicemapper exclude_grap

all: binaries

.PHONY: clean test test-unit test-e2e verify update update-amis install-tools
.PHONY: clean test test-unit test-e2e verify update update-amis install-tools custom-os-images

# Remove build artifaces
# Example:
Expand All @@ -57,6 +62,28 @@ _verify-e2e-%:
image:
hack/build-image

# Define a template rule to build a specific test image.
# Accepts the image name suffix (e.g., "rhel-coreos-9") as the
# sole argument.
#
# The images will be produced with the names like localhost/custom-os-image:rhel-coreos-9.
define custom_os_image_build_template =
.PHONY: custom-os-image-$(1)
custom-os-image-$(1):
podman build \
-f $(CUSTOM_OS_TEST_IMAGE_DIR)/Containerfile.$(1) \
-t localhost/custom-os-image:$(1) \
$(CUSTOM_OS_TEST_IMAGE_DIR)
endef

# Create a target for each detected test image (e.g., rhel-coreos-9).
$(foreach C, $(CUSTOM_OS_TEST_IMAGE_NAMES), $(eval $(call custom_os_image_build_template,$(C))))

# Target to build all detected custom OS test images. This is mostly for use by
# developers on their workstations since they must be explicitly declared in
# OpenShift CI.
custom-os-images: $(patsubst %,custom-os-image-%,$(CUSTOM_OS_TEST_IMAGE_NAMES))

# Run tests
test: test-unit test-e2e

Expand Down
14 changes: 14 additions & 0 deletions test/custom-os-images/Containerfile.rhel-coreos-10
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM registry.ci.openshift.org/ocp/4.21:rhel-coreos-10 AS base

FROM quay.io/centos/centos:stream10 AS epel
WORKDIR /etc/yum.repos.d
RUN dnf install -y --setopt=keepcache=True epel-release && \
sed -i 's/\$stream/10-stream/g' /etc/yum.repos.d/centos*.repo && \
sed -i 's/EPEL\-\$releasever_major/EPEL-10/g' /etc/yum.repos.d/epel*.repo && \
sed -i -E 's/\$\{releasever_minor\:\+\-z\}//g' /etc/yum.repos.d/epel*.repo

FROM base AS final
COPY --from=epel /etc/yum.repos.d /etc/yum.repos.d
COPY --from=epel /etc/pki/rpm-gpg/RPM-GPG-KEY-* /etc/pki/rpm-gpg/
RUN rpm-ostree install ripgrep yq && \
ostree container commit
12 changes: 12 additions & 0 deletions test/custom-os-images/Containerfile.rhel-coreos-9
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM registry.ci.openshift.org/ocp/4.21:rhel-coreos AS base

FROM quay.io/centos/centos:stream9 AS epel
WORKDIR /etc/yum.repos.d
RUN dnf install -y epel-release && \
sed -i 's/\$stream/9-stream/g' /etc/yum.repos.d/centos*.repo

FROM base AS final
COPY --from=epel /etc/yum.repos.d /etc/yum.repos.d
COPY --from=epel /etc/pki/rpm-gpg/RPM-GPG-KEY-* /etc/pki/rpm-gpg/
RUN rpm-ostree install ripgrep yq && \
ostree container commit
11 changes: 11 additions & 0 deletions test/custom-os-images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# custom-os-images

This directory contains two Containerfiles, `Containerfile.rhel-coreos-9` and
`Containerfile.rhel-coreos-10`, respectively. These images are intended for
testing Image Mode OpenShift and are intended to be built by the CI system and
injected into the e2e test suites. They're ephemeral since they'll be discarded
when the CI run is finished.

To make maintaining and debugging these images easier, there is a Makefile
target that can be used locally by developers to validate that the images build
without issue. Just run `make custom-os-images`.
3 changes: 1 addition & 2 deletions test/e2e-2of2/osimageurl_override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
// 6. Wait for the node to roll back.
// 7. Assert that the binaries are no longer present.
func TestOSImageURLOverride(t *testing.T) {
envVarName := "MCO_OS_IMAGE_URL"
envVarName := "MCO_OS_IMAGE_URL_RHEL_9"

osImageURL, ok := os.LookupEnv(envVarName)
if ok && osImageURL != "" {
Expand All @@ -37,7 +37,6 @@ func TestOSImageURLOverride(t *testing.T) {
node := helpers.GetRandomNode(t, cs, "worker")

binaries := []string{
"/usr/bin/tailscale",
"/usr/bin/rg",
"/usr/bin/yq",
}
Expand Down