diff --git a/test/bin/common.sh b/test/bin/common.sh index 3a29c0cf58..d915f254c1 100644 --- a/test/bin/common.sh +++ b/test/bin/common.sh @@ -200,6 +200,10 @@ export MIRROR_REGISTRY_PORT=5000 MIRROR_REGISTRY_URL="${VM_BRIDGE_IP:-$(hostname)}:${MIRROR_REGISTRY_PORT}/microshift" export MIRROR_REGISTRY_URL +# File names containing credentials for the OpenShift mirror repositories +export OCP_MIRROR_USERNAME_FILE="${OCP_MIRROR_USERNAME_FILE:-"${HOME}/.ocp_mirror_username"}" +export OCP_MIRROR_PASSWORD_FILE="${OCP_MIRROR_PASSWORD_FILE:-"${HOME}/.ocp_mirror_password"}" + get_build_branch() { local -r ocp_ver="$(grep ^OCP_VERSION "${ROOTDIR}/Makefile.version.$(uname -m).var" | awk '{print $NF}' | awk -F. '{print $1"."$2}')" local -r cur_branch="$(git branch --show-current 2>/dev/null)" diff --git a/test/bin/pyutils/build_bootc_images.py b/test/bin/pyutils/build_bootc_images.py index b907c1088e..88428fda01 100644 --- a/test/bin/pyutils/build_bootc_images.py +++ b/test/bin/pyutils/build_bootc_images.py @@ -284,17 +284,31 @@ def should_skip(image, cached): # Note: # - The pull secret is necessary in some builds for pulling embedded # container images referenced in release-info RPMs + # - The OpenShift mirror repository credentials are optional and are used + # for accessing pre-release RHEL RPM repositories. # - The explicit push-to-mirror sets the 'latest' tag as all the build # layers are in the mirror due to 'cache-to' option build_args = [ "sudo", "podman", "build", "--authfile", PULL_SECRET, - "--secret", f"id=pullsecret,src={PULL_SECRET}", + "--secret", f"id=pullsecret,src={PULL_SECRET}" + ] + + ocp_mirror_ufile = common.get_env_var('OCP_MIRROR_USERNAME_FILE') + ocp_mirror_pfile = common.get_env_var('OCP_MIRROR_PASSWORD_FILE') + if common.file_has_valid_lines(ocp_mirror_ufile) and common.file_has_valid_lines(ocp_mirror_pfile): + common.print_msg(f"Using OpenShift mirror repository credentials from '{ocp_mirror_ufile}' and '{ocp_mirror_pfile}'") + build_args += [ + "--volume", f"{ocp_mirror_ufile}:/etc/dnf/vars/ocp_mirror_username:z", + "--volume", f"{ocp_mirror_pfile}:/etc/dnf/vars/ocp_mirror_password:z" + ] + build_args += [ "--cache-to", f"{MIRROR_REGISTRY}/{cf_outname}", "--cache-from", f"{MIRROR_REGISTRY}/{cf_outname}", "-t", cf_outname, "-f", cf_outfile, IMAGEDIR ] + start = time.time() common.retry_on_exception(3, common.run_command_in_shell, build_args, dry_run, logfile, logfile) common.record_junit(cf_path, "build-container", "OK", start) diff --git a/test/image-blueprints-bootc/layer1-base/group1/rhel98-test-agent.containerfile b/test/image-blueprints-bootc/layer1-base/group1/rhel98-test-agent.containerfile new file mode 100644 index 0000000000..b8e2e3b8da --- /dev/null +++ b/test/image-blueprints-bootc/layer1-base/group1/rhel98-test-agent.containerfile @@ -0,0 +1,27 @@ +FROM registry.stage.redhat.io/rhel9/rhel-bootc:9.8 + +# Build arguments +ARG USHIFT_RPM_REPO_NAME=microshift-local +ARG USHIFT_RPM_REPO_PATH=/tmp/$USHIFT_RPM_REPO_NAME + +# Configure the RPM repositories (no EUS in staging environment) +COPY --chmod=755 ./bootc-images/rpm-repo-config.sh /tmp/rpm-repo-config.sh +RUN /tmp/rpm-repo-config.sh && rm -f /tmp/rpm-repo-config.sh + +# Configure the RHEL mirror RPM repositories (for use in the staging environment) +ARG RHEL_MIRROR_REPO_NAME=rhel98-mirror.repo +ARG RHEL_MIRROR_REPO_PATH=/etc/yum.repos.d/$RHEL_MIRROR_REPO_NAME +COPY --chmod=644 ./bootc-images/$RHEL_MIRROR_REPO_NAME $RHEL_MIRROR_REPO_PATH + +# Copy the MicroShift repository contents +COPY ./rpm-repos/$USHIFT_RPM_REPO_NAME $USHIFT_RPM_REPO_PATH + +# Copy repository configuration +COPY ./bootc-images/$USHIFT_RPM_REPO_NAME.repo /etc/yum.repos.d/ + +# Install the test agent and cleanup +RUN dnf install -y microshift-test-agent && \ + systemctl enable microshift-test-agent && \ + rm -vf /etc/yum.repos.d/microshift-*.repo && \ + rm -rvf $USHIFT_RPM_REPO_PATH && \ + dnf clean all diff --git a/test/package-sources-bootc/rhel98-mirror.repo b/test/package-sources-bootc/rhel98-mirror.repo new file mode 100644 index 0000000000..677d73786e --- /dev/null +++ b/test/package-sources-bootc/rhel98-mirror.repo @@ -0,0 +1,19 @@ +[rhel-9.8-appstream] +name = rhel-9.8-appstream +baseurl = https://mirror2.openshift.com/enterprise/reposync/4.22{{ if eq .Env.UNAME_M "aarch64" }}_aarch64{{ end }}/rhel-98-appstream +enabled = 1 +sslverify = false +gpgcheck = 0 +username = $ocp_mirror_username +password = $ocp_mirror_password +skip_if_unavailable = false + +[rhel-9.8-baseos] +name = rhel-9.8-baseos +baseurl = https://mirror2.openshift.com/enterprise/reposync/4.22{{ if eq .Env.UNAME_M "aarch64" }}_aarch64{{ end }}/rhel-98-baseos +enabled = 1 +sslverify = false +gpgcheck = 0 +username = $ocp_mirror_username +password = $ocp_mirror_password +skip_if_unavailable = false