Skip to content

Commit a517425

Browse files
committed
adds testing images for dual-stream image-mode
These images will be built by the CI system and injected into the e2e tests so that we can test image-mode on dual-stream.
1 parent 5c30302 commit a517425

File tree

6 files changed

+69
-4
lines changed

6 files changed

+69
-4
lines changed

Containerfile.helpers-ci

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-builder-multi-openshift-4.18 AS builder
1+
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS builder
22
ENV GOCACHE="/go/.cache" \
33
GOMODCACHE="/go/pkg/mod"
44
WORKDIR /go/src/github.com/openshift/machine-config-operator
@@ -7,5 +7,5 @@ RUN --mount=type=cache,target=/go/.cache,z \
77
--mount=type=cache,target=/go/pkg/mod,z \
88
make install-helpers DESTDIR=/helpers
99

10-
FROM registry.ci.openshift.org/ocp/builder:rhel-9-enterprise-base-multi-openshift-4.18 AS final
10+
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9 AS final
1111
COPY --from=builder /helpers/usr/bin /usr/bin

Dockerfile.rhel7

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ RUN --mount=type=cache,target=/var/cache/dnf,z \
4545
# Create the build user which will be used for doing OS image builds. We
4646
# use the username "build" and the uid 1000 since this matches what is in
4747
# the official Buildah image.
48-
useradd --uid 1000 build
48+
# Conditional checks if "build" user does not exist before adding user.
49+
if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi
4950
# Copy the binaries *after* we install nmstate so we don't invalidate our cache for local builds.
5051
COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9.tar /tmp/instroot-rhel9.tar
5152
RUN cd / && tar xf /tmp/instroot-rhel9.tar && rm -f /tmp/instroot-rhel9.tar

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ PREFIX ?= /usr
1010
GO111MODULE?=on
1111
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
1212

13+
# Find all of the test OS image Containerfiles so they can be built.
14+
CUSTOM_OS_TEST_IMAGE_DIR := $(E2E_ROOT_DIR)/custom-os-images
15+
CUSTOM_OS_TEST_CONTAINERFILES := $(wildcard $(CUSTOM_OS_TEST_IMAGE_DIR)/Containerfile.*)
16+
CUSTOM_OS_TEST_IMAGE_NAMES := $(patsubst $(CUSTOM_OS_TEST_IMAGE_DIR)/Containerfile.%,%,$(CUSTOM_OS_TEST_CONTAINERFILES))
17+
1318
# Copied from coreos-assembler
1419
GOARCH := $(shell uname -m)
1520
ifeq ($(GOARCH),x86_64)
@@ -30,7 +35,7 @@ GOTAGS = "containers_image_openpgp exclude_graphdriver_devicemapper exclude_grap
3035

3136
all: binaries
3237

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

3540
# Remove build artifaces
3641
# Example:
@@ -57,6 +62,28 @@ _verify-e2e-%:
5762
image:
5863
hack/build-image
5964

65+
# Define a template rule to build a specific test image.
66+
# Accepts the image name suffix (e.g., "rhel-coreos-9") as the
67+
# sole argument.
68+
#
69+
# The images will be produced with the names like localhost/custom-os-image:rhel-coreos-9.
70+
define custom_os_image_build_template =
71+
.PHONY: custom-os-image-$(1)
72+
custom-os-image-$(1):
73+
podman build \
74+
-f $(CUSTOM_OS_TEST_IMAGE_DIR)/Containerfile.$(1) \
75+
-t localhost/custom-os-image:$(1) \
76+
$(CUSTOM_OS_TEST_IMAGE_DIR)
77+
endef
78+
79+
# Create a target for each detected test image (e.g., rhel-coreos-9).
80+
$(foreach C, $(CUSTOM_OS_TEST_IMAGE_NAMES), $(eval $(call custom_os_image_build_template,$(C))))
81+
82+
# Target to build all detected custom OS test images. This is mostly for use by
83+
# developers on their workstations since they must be explicitly declared in
84+
# OpenShift CI.
85+
custom-os-images: $(patsubst %,custom-os-image-%,$(CUSTOM_OS_TEST_IMAGE_NAMES))
86+
6087
# Run tests
6188
test: test-unit test-e2e
6289

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM registry.ci.openshift.org/ocp/4.21:rhel-coreos-10 AS base
2+
3+
FROM quay.io/centos/centos:stream10 AS epel
4+
WORKDIR /etc/yum.repos.d
5+
RUN dnf install -y --setopt=keepcache=True epel-release && \
6+
curl -LO https://pkgs.tailscale.com/stable/rhel/10/tailscale.repo && \
7+
sed -i 's/\$stream/10-stream/g' /etc/yum.repos.d/centos*.repo && \
8+
sed -i 's/EPEL\-\$releasever_major/EPEL-10/g' /etc/yum.repos.d/epel*.repo && \
9+
sed -i -E 's/\$\{releasever_minor\:\+\-z\}//g' /etc/yum.repos.d/epel*.repo
10+
11+
FROM base AS final
12+
COPY --from=epel /etc/yum.repos.d /etc/yum.repos.d
13+
COPY --from=epel /etc/pki/rpm-gpg/RPM-GPG-KEY-* /etc/pki/rpm-gpg/
14+
RUN rpm-ostree install ripgrep yq tailscale && \
15+
ostree container commit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM registry.ci.openshift.org/ocp/4.21:rhel-coreos AS base
2+
3+
FROM quay.io/centos/centos:stream9 AS epel
4+
WORKDIR /etc/yum.repos.d
5+
RUN dnf install -y epel-release && \
6+
curl -LO https://pkgs.tailscale.com/stable/rhel/9/tailscale.repo && \
7+
sed -i 's/\$stream/9-stream/g' /etc/yum.repos.d/centos*.repo
8+
9+
FROM base AS final
10+
COPY --from=epel /etc/yum.repos.d /etc/yum.repos.d
11+
COPY --from=epel /etc/pki/rpm-gpg/RPM-GPG-KEY-* /etc/pki/rpm-gpg/
12+
RUN rpm-ostree install ripgrep yq tailscale && \
13+
ostree container commit

test/custom-os-images/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# custom-os-images
2+
3+
This directory contains two Containerfiles,
4+
`Containerfile.rhel-coreos-9` and
5+
`Containerfile.rhel-coreos-10`, respectively. These images are
6+
intended for testing Image Mode OpenShift and are built / managed by the CI
7+
system.
8+
9+
That said, there is a Makefile target, `make custom-os-test-images` that can be used locally by developers to validate that the images build without issue.

0 commit comments

Comments
 (0)