diff --git a/packaging/rpm/microshift.spec b/packaging/rpm/microshift.spec index 9f4ac45989..e75c53649d 100644 --- a/packaging/rpm/microshift.spec +++ b/packaging/rpm/microshift.spec @@ -61,8 +61,8 @@ BuildRequires: systemd BuildRequires: golang # DO NOT REMOVE -Requires: cri-o >= 1.25 -Requires: cri-tools >= 1.25 +Requires: cri-o >= 1.30.0, cri-o < 1.31.0 +Requires: cri-tools >= 1.30.0, cri-tools < 1.31.0 Requires: iptables Requires: microshift-selinux = %{version} Requires: microshift-networking = %{version} @@ -474,6 +474,9 @@ fi # Use Git command to generate the log and replace the VERSION string # LANG=C git log --date="format:%a %b %d %Y" --pretty="tformat:* %cd %an <%ae> VERSION%n- %s%n" packaging/rpm/microshift.spec %changelog +* Wed Jun 19 2024 Patryk Matuszak 4.17.0 +- Fix CRI-O version to match Kubernetes version + * Wed Jun 12 2024 Pablo Acevedo Montserrat 4.16.0 - Explicitly configure crun as default crio runtime diff --git a/scripts/devenv-builder/configure-vm.sh b/scripts/devenv-builder/configure-vm.sh index ed8124be70..4e3e3d7861 100755 --- a/scripts/devenv-builder/configure-vm.sh +++ b/scripts/devenv-builder/configure-vm.sh @@ -167,37 +167,31 @@ if ${BUILD_AND_RUN}; then make srpm fi -if ${RHEL_SUBSCRIPTION}; then - # This version might not match the version under development because we need - # to pull in dependencies that are already released - LATEST_RHOCP_MINOR=$("${RHOCP_REPO}") -else - # Assume the current development version on non-RHEL OS - LATEST_RHOCP_MINOR=$(cut -d'.' -f2 "${MAKE_VERSION}") -fi -OCPVERSION="4.${LATEST_RHOCP_MINOR}" - if ${RHEL_SUBSCRIPTION}; then OSVERSION=$(awk -F: '{print $5}' /etc/system-release-cpe) sudo subscription-manager config --rhsm.manage_repos=1 - sudo subscription-manager repos \ - --enable "rhocp-${OCPVERSION}-for-rhel-${OSVERSION}-$(uname -m)-rpms" - - if ! ${RHEL_BETA_VERSION} ; then - sudo subscription-manager repos \ - --enable "fast-datapath-for-rhel-${OSVERSION}-$(uname -m)-rpms" - else - OCP_REPO_NAME="rhocp-${OCPVERSION}-for-rhel-${OSVERSION}-mirrorbeta-$(uname -i)-rpms" + RHOCP=$("${RHOCP_REPO}") + if [[ "${RHOCP}" =~ ^[0-9]{2} ]]; then + sudo subscription-manager repos --enable "rhocp-4.${RHOCP}-for-rhel-9-$(uname -m)-rpms" + elif [[ "${RHOCP}" =~ ^http ]]; then + url=$(echo "${RHOCP}" | cut -d, -f1) + ver=$(echo "${RHOCP}" | cut -d, -f2) + OCP_REPO_NAME="rhocp-4.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms" sudo tee "/etc/yum.repos.d/${OCP_REPO_NAME}.repo" >/dev/null <&/dev/null; then exit 1 fi -# Get minor version of currently checked out branch. -# It's based on values stored in Makefile.version.$ARCH.var. -make_version="${REPOROOT}/Makefile.version.$(uname -m).var" -if [ ! -f "${make_version}" ] ; then - # Attempt to locate the Makefile version file next to the current script. - # This is necessary when bootstrapping the development environment for the first time. - make_version=$(find "${SCRIPTDIR}" -maxdepth 1 -name "Makefile.version.$(uname -m).*.var" | tail -1) +if [[ "$#" -eq 1 ]]; then + current_minor="${1}" + stop="${current_minor}" +else + # Get minor version of currently checked out branch. + # It's based on values stored in Makefile.version.$ARCH.var. + make_version="${REPOROOT}/Makefile.version.$(uname -m).var" if [ ! -f "${make_version}" ] ; then - >&2 echo "Cannot find the Makefile.version.$(uname -m).var file" - exit 1 + # Attempt to locate the Makefile version file next to the current script. + # This is necessary when bootstrapping the development environment for the first time. + make_version=$(find "${SCRIPTDIR}" -maxdepth 1 -name "Makefile.version.$(uname -m).*.var" | tail -1) + if [ ! -f "${make_version}" ] ; then + >&2 echo "Cannot find the Makefile.version.$(uname -m).var file" + exit 1 + fi fi + current_minor=$(cut -d'.' -f2 "${make_version}") + stop=$(( current_minor - 3 )) fi -current_minor=$(cut -d'.' -f2 "${make_version}") -stop=$(( current_minor - 3 )) # Go through minor versions, starting from current_mirror counting down # to get latest available rhocp repository. @@ -42,11 +52,16 @@ stop=$(( current_minor - 3 )) # and then rhocp-4.14 (which will be returned from the script because it's usable). for ver in $(seq "${current_minor}" -1 "${stop}"); do repository="rhocp-4.${ver}-for-rhel-9-$(uname -m)-rpms" - if sudo dnf -v repository-packages "${repository}" info cri-o 1>&2; - then + if sudo dnf repository-packages "${repository}" info cri-o 1>&2; then echo "${ver}" exit 0 fi + + rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/dependencies/rpms/4.${ver}-el9-beta/" + if sudo dnf repository-packages --disablerepo '*' --repofrompath "this,${rhocp_beta_url}" this info cri-o 1>&2; then + echo "${rhocp_beta_url},${ver}" + exit 0 + fi done >&2 echo "Failed to get latest rhocp repository!" diff --git a/scripts/image-builder/build.sh b/scripts/image-builder/build.sh index 338556150a..784e8c907e 100755 --- a/scripts/image-builder/build.sh +++ b/scripts/image-builder/build.sh @@ -348,7 +348,17 @@ fi title "Loading package sources" -LATEST_RHOCP_MINOR=$("${ROOTDIR}/scripts/get-latest-rhocp-repo.sh") +RHOCP=$("${ROOTDIR}/scripts/get-latest-rhocp-repo.sh") +if [[ "${RHOCP}" =~ ^[0-9]{2} ]]; then + OCP_MINOR="${RHOCP}" + RHOCP_URL="https://cdn.redhat.com/content/dist/layered/rhel9/${BUILD_ARCH}/rhocp/4.${OCP_MINOR}/os" + RHOCP_GPG_RHSM="true" +elif [[ "${RHOCP}" =~ ^http ]]; then + RHOCP_URL=$(echo "${RHOCP}" | cut -d, -f1) + OCP_MINOR=$(echo "${RHOCP}" | cut -d, -f2) + RHOCP_GPG_RHSM="false" +fi + PACKAGE_SOURCES="microshift-local rhocp fast-datapath" if [ -n "${CUSTOM_RPM_FILES}" ] ; then PACKAGE_SOURCES+=" custom-rpms" @@ -357,7 +367,9 @@ fi for f in ${PACKAGE_SOURCES} ; do sed -e "s;REPLACE_IMAGE_BUILDER_DIR;${BUILDDIR};g" \ -e "s;REPLACE_BUILD_ARCH;${BUILD_ARCH};g" \ - -e "s;REPLACE_OCP_MINOR;${LATEST_RHOCP_MINOR};g" \ + -e "s;REPLACE_OCP_MINOR;${OCP_MINOR};g" \ + -e "s;REPLACE_RHOCP_URL;${RHOCP_URL};g" \ + -e "s;REPLACE_RHOCP_GPG_RHSM;${RHOCP_GPG_RHSM};g" \ "${SCRIPTDIR}/config/${f}.toml.template" \ > ${f}.toml sudo composer-cli sources delete ${f} 2>/dev/null || true diff --git a/scripts/image-builder/config/rhocp.toml.template b/scripts/image-builder/config/rhocp.toml.template index 8c25c98a66..9b55ad935d 100644 --- a/scripts/image-builder/config/rhocp.toml.template +++ b/scripts/image-builder/config/rhocp.toml.template @@ -1,8 +1,8 @@ id = "rhocp-4.REPLACE_OCP_MINOR" name = "Red Hat OpenShift Container Platform 4.REPLACE_OCP_MINOR for RHEL 9" type = "yum-baseurl" -url = "https://cdn.redhat.com/content/dist/layered/rhel9/REPLACE_BUILD_ARCH/rhocp/4.REPLACE_OCP_MINOR/os" -check_gpg = true +url = "REPLACE_RHOCP_URL" +check_gpg = REPLACE_RHOCP_GPG_RHSM check_ssl = true system = false -rhsm = true +rhsm = REPLACE_RHOCP_GPG_RHSM diff --git a/test/bin/build_images.sh b/test/bin/build_images.sh index 34730c457b..a8a199e7db 100755 --- a/test/bin/build_images.sh +++ b/test/bin/build_images.sh @@ -81,6 +81,8 @@ configure_package_sources() { export RHOCP_MINOR_Y export RHOCP_MINOR_Y1 export RHOCP_MINOR_Y2 + export RHOCP_MINOR_Y_BETA + export RHOCP_MINOR_Y1_BETA # Add our sources. It is OK to run these steps repeatedly, if the # details change they are updated in the service. @@ -578,7 +580,19 @@ do_group() { is_rhocp_available() { local -r ver="${1}" repository="rhocp-4.${ver}-for-rhel-9-$(uname -m)-rpms" - if sudo dnf -v repository-packages "${repository}" info cri-o 1>&2; then + if sudo dnf repository-packages "${repository}" info cri-o 1>&2; then + return 0 + fi + return 1 +} + +is_rhocp_beta_available() { + local -r ver="${1}" + url_amd="https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rpms/4.${ver}-el9-beta/" + url_arm="https://mirror.openshift.com/pub/openshift-v4/aarch64/dependencies/rpms/4.${ver}-el9-beta/" + # Use specific minor version RHOCP mirror only if both arches are available. + if sudo dnf repository-packages --disablerepo '*' --repofrompath "this,${url_arm}" this info cri-o 1>&2 && \ + sudo dnf repository-packages --disablerepo '*' --repofrompath "this,${url_amd}" this info cri-o 1>&2; then return 0 fi return 1 @@ -725,12 +739,19 @@ PREVIOUS_RELEASE_VERSION=$(echo "${previous_version_repo}" | cut -d, -f1) PREVIOUS_RELEASE_REPO=$(echo "${previous_version_repo}" | cut -d, -f2) RHOCP_MINOR_Y="" -RHOCP_MINOR_Y1="" +RHOCP_MINOR_Y_BETA="" if is_rhocp_available "${MINOR_VERSION}"; then RHOCP_MINOR_Y="${MINOR_VERSION}" +elif is_rhocp_beta_available "${MINOR_VERSION}"; then + RHOCP_MINOR_Y_BETA="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/dependencies/rpms/4.${MINOR_VERSION}-el9-beta/" fi + +RHOCP_MINOR_Y1="" +RHOCP_MINOR_Y1_BETA="" if is_rhocp_available "${PREVIOUS_MINOR_VERSION}"; then RHOCP_MINOR_Y1="${PREVIOUS_MINOR_VERSION}" +elif is_rhocp_beta_available "${PREVIOUS_MINOR_VERSION}"; then + RHOCP_MINOR_Y1_BETA="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/dependencies/rpms/4.${PREVIOUS_MINOR_VERSION}-el9-beta/" fi # For Y-2, there will always be a real repository, so we can always diff --git a/test/bin/pyutils/build_bootc_images.py b/test/bin/pyutils/build_bootc_images.py index de985be23d..504f44e1fd 100644 --- a/test/bin/pyutils/build_bootc_images.py +++ b/test/bin/pyutils/build_bootc_images.py @@ -91,6 +91,25 @@ def is_rhocp_available(ver): return False +def get_rhocp_beta_url_if_available(ver): + url_amd = f"https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rpms/4.{ver}-el9-beta/" + url_arm = f"https://mirror.openshift.com/pub/openshift-v4/aarch64/dependencies/rpms/4.{ver}-el9-beta/" + + try: + # Run the dnf command to check for cri-o in the specified repository + repo_info = common.run_command_in_shell(f"sudo dnf repository-packages --disablerepo '*' --repofrompath 'this,{url_amd}' this info cri-o") + common.print_msg(repo_info) + + repo_info = common.run_command_in_shell(f"sudo dnf repository-packages --disablerepo '*' --repofrompath 'this,{url_arm}' this info cri-o") + common.print_msg(repo_info) + + # Use specific minor version RHOCP mirror only if both arches are available. + architecture = platform.machine() + return f"https://mirror.openshift.com/pub/openshift-v4/{architecture}/dependencies/rpms/4.{ver}-el9-beta/" + except Exception: + return "" + + def set_rpm_version_info_vars(): global SOURCE_VERSION global MINOR_VERSION @@ -107,6 +126,8 @@ def set_rpm_version_info_vars(): global RHOCP_MINOR_Y2 global YMINUS2_RELEASE_VERSION global YMINUS2_RELEASE_REPO + global RHOCP_MINOR_Y_BETA + global RHOCP_MINOR_Y1_BETA release_info_rpm = find_latest_rpm(LOCAL_REPO) release_info_rpm_base = find_latest_rpm(BASE_REPO) @@ -132,11 +153,26 @@ def set_rpm_version_info_vars(): RHOCP_MINOR_Y = "" RHOCP_MINOR_Y1 = "" + if is_rhocp_available(MINOR_VERSION): RHOCP_MINOR_Y = MINOR_VERSION + if is_rhocp_available(PREVIOUS_MINOR_VERSION): RHOCP_MINOR_Y1 = PREVIOUS_MINOR_VERSION + # Check RHOCP mirror anyway, because centos9 tests are using them. + RHOCP_MINOR_Y_BETA = get_rhocp_beta_url_if_available(MINOR_VERSION) + RHOCP_MINOR_Y1_BETA = get_rhocp_beta_url_if_available(PREVIOUS_MINOR_VERSION) + + # Currently bootc tests only use current minor RHOCP. If they are unavailable, use previous minor RHOCP. + if RHOCP_MINOR_Y == "" and RHOCP_MINOR_Y1 != "": + RHOCP_MINOR_Y = RHOCP_MINOR_Y1 + elif RHOCP_MINOR_Y_BETA == "" and RHOCP_MINOR_Y1_BETA != "": + RHOCP_MINOR_Y_BETA = RHOCP_MINOR_Y1_BETA + + if RHOCP_MINOR_Y == "" and RHOCP_MINOR_Y_BETA == "": + raise Exception("Could not find a suitable RHOCP repository to enable") + # For Y-2, there will always be a real repository, so we can always # set the template variable for enabling that package source and use # the well-known name of that repo instead of figuring out the URL. @@ -152,7 +188,8 @@ def set_rpm_version_info_vars(): 'YMINUS2_MINOR_VERSION', 'FAKE_NEXT_MINOR_VERSION', 'SOURCE_VERSION_BASE', 'CURRENT_RELEASE_VERSION', 'CURRENT_RELEASE_REPO', 'PREVIOUS_RELEASE_VERSION', 'PREVIOUS_RELEASE_REPO', 'RHOCP_MINOR_Y', 'RHOCP_MINOR_Y1', - 'RHOCP_MINOR_Y2', 'YMINUS2_RELEASE_VERSION', 'YMINUS2_RELEASE_REPO' + 'RHOCP_MINOR_Y2', 'YMINUS2_RELEASE_VERSION', 'YMINUS2_RELEASE_REPO', + 'RHOCP_MINOR_Y_BETA', 'RHOCP_MINOR_Y1_BETA' ] for var in rpmver_globals_vars: value = globals().get(var) diff --git a/test/bin/scenario.sh b/test/bin/scenario.sh index 2eca4ac1de..8502ae7b29 100755 --- a/test/bin/scenario.sh +++ b/test/bin/scenario.sh @@ -227,7 +227,7 @@ prepare_kickstart() { sed -e "s|REPLACE_LVM_SYSROOT_SIZE|${LVM_SYSROOT_SIZE}|g" \ -e "s|REPLACE_OSTREE_SERVER_URL|${WEB_SERVER_URL}/repo|g" \ -e "s|REPLACE_RPM_SERVER_URL|${WEB_SERVER_URL}/rpm-repos|g" \ - -e "s|REPLACE_PREVIOUS_MINOR_VERSION|$(previous_minor_version)|g" \ + -e "s|REPLACE_MINOR_VERSION|$(current_minor_version)|g" \ -e "s|REPLACE_BOOT_COMMIT_REF|${boot_commit_ref}|g" \ -e "s|REPLACE_PULL_SECRET|${PULL_SECRET_CONTENT}|g" \ -e "s|REPLACE_HOST_NAME|${vm_hostname}|g" \ diff --git a/test/bootc-sources/microshift_repo_config.sh.template b/test/bootc-sources/microshift_repo_config.sh.template index 4e29651e8a..51518a23f9 100644 --- a/test/bootc-sources/microshift_repo_config.sh.template +++ b/test/bootc-sources/microshift_repo_config.sh.template @@ -37,7 +37,7 @@ config_centos9_repos() { cat > "${OCP_MIRROR_REPO_FILE}" < "${OCP_RHOCP_REPO_FILE}" < "/etc/yum.repos.d/${OCPREPO}.repo" <= 1.25.0` requirement, +# which happens to be crio >= 1.29 which no longer ships `crun` runtime definition. +# TODO: Re-enable when new MicroShift EC (with crun runtime definition in cri-o config) is produced. + # Sourced from cleanup_scenario.sh and uses functions defined there. start_commit=rhel-9.4-microshift-crel diff --git a/test/scenarios/el94-src@rpm-install.sh b/test/scenarios/el94-src@rpm-install.sh index 51e38eaf36..ade1d0fe7b 100644 --- a/test/scenarios/el94-src@rpm-install.sh +++ b/test/scenarios/el94-src@rpm-install.sh @@ -40,14 +40,44 @@ scenario_run_tests() { local -r source_reponame=$(basename "${LOCAL_REPO}") local -r source_repo_url="${WEB_SERVER_URL}/rpm-repos/${source_reponame}" local -r target_version=$(current_version) + local -r current_minor_version=$(current_minor_version) local -r previous_minor_version=$(previous_minor_version) local -r previous_version_repo=$(get_rel_version_repo "${previous_minor_version}") local -r previous_version_repo_url=$(echo "${previous_version_repo}" | cut -d, -f2) - # Enable the repositories with the dependencies using the most - # recent GA OCP version. This value is used to build the repo - # name, so should include the major and minor version number. - local -r dependency_version="4.$("${ROOTDIR}/scripts/get-latest-rhocp-repo.sh")" + # Enable the repositories with the dependencies. + + # RHOCP for current version might not exist yet. Then, just use whatever we can get for previous minor. + local -r rhocp_current=$("${ROOTDIR}/scripts/get-latest-rhocp-repo.sh" "${current_minor_version}" || true) + local -r rhocp_previous=$("${ROOTDIR}/scripts/get-latest-rhocp-repo.sh" "${previous_minor_version}") + for rhocp in "${rhocp_current}" "${rhocp_previous}"; do + if [[ ! "${rhocp}" ]]; then + # rhocp_current might be empty if the beta mirror is not up yet + continue + fi + + if [[ "${rhocp}" =~ ^[0-9]{2} ]]; then + run_command_on_vm host1 "sudo subscription-manager repos --enable rhocp-4.${rhocp}-for-rhel-9-\$(uname -m)-rpms" + elif [[ "${rhocp}" =~ ^http ]]; then + url=$(echo "${rhocp}" | cut -d, -f1) + ver=$(echo "${rhocp}" | cut -d, -f2) + OCP_REPO_NAME="rhocp-4.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms" + tmp_file=$(mktemp) + tee "${tmp_file}" >/dev/null <