From b30b2718a520fc8c8196ac4225bbc4aa7b1a2fb2 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 7 Oct 2026 13:47:43 -0300 Subject: [PATCH] fix(xcat-core): go-xcat case cannot enable CodeReady Builder on RHEL On a RHEL node, Red Hat Subscription Management owns the CodeReady Builder repository, so dnf config-manager cannot enable it by the crb or powertools id. The case also had no check on that command, so the failure showed up later as a go-xcat dependency error. enable_crb.sh now enables codeready-builder-for-rhel---rpms through subscription-manager when RHSM lists it. Otherwise it enables crb, or powertools on EL8, through dnf. go_xcat_devel_from_repo checks rc==0 on the command. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/autotest/testcase/go_xcat/case3 | 3 ++- .../autotest/testcase/go_xcat/enable_crb.sh | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/go_xcat/case3 b/xCAT-test/autotest/testcase/go_xcat/case3 index 92f7bfa66e..f0ef55df84 100644 --- a/xCAT-test/autotest/testcase/go_xcat/case3 +++ b/xCAT-test/autotest/testcase/go_xcat/case3 @@ -25,8 +25,9 @@ cmd:if xdsh $$CN "grep \"Red Hat\|Rocky\|Alma\" /etc/*release >/dev/null"; then cmd:if xdsh $$CN "grep \"Red Hat\|Rocky\|Alma\" /etc/*release >/dev/null"; then xdsh $$CN 'rpm -q epel-release || dnf -y install epel-release || dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm'; fi check:rc==0 -#go-xcat requires CodeReady Builder, named crb on EL9 and later and PowerTools on EL8. +#go-xcat requires CodeReady Builder. cmd:if xdsh $$CN "grep \"Red Hat\|Rocky\|Alma\" /etc/*release >/dev/null"; then xdsh $$CN -e /opt/xcat/share/xcat/tools/autotest/testcase/go_xcat/enable_crb.sh; fi +check:rc==0 #Install additional packages on Ubuntu cmd:if xdsh $$CN "grep \"Ubuntu\" /etc/*release >/dev/null"; then xdsh $$CN "DEBIAN_FRONTEND=noninteractive apt-get install -y gnupg"; fi diff --git a/xCAT-test/autotest/testcase/go_xcat/enable_crb.sh b/xCAT-test/autotest/testcase/go_xcat/enable_crb.sh index c80bff2cf1..f5671b47f9 100755 --- a/xCAT-test/autotest/testcase/go_xcat/enable_crb.sh +++ b/xCAT-test/autotest/testcase/go_xcat/enable_crb.sh @@ -4,9 +4,23 @@ enable_crb() { - dnf config-manager --set-enabled crb || - dnf config-manager --set-enabled powertools || - dnf config-manager setopt crb.enabled=1 + local major arch rhsm_repo dnf_repo + + major=$(rpm -E %rhel) + arch=$(uname -m) + + # On RHEL, RHSM owns the repository and dnf config-manager cannot enable it. + rhsm_repo="codeready-builder-for-rhel-${major}-${arch}-rpms" + if subscription-manager repos --list 2>/dev/null | + grep -Eq "^Repo ID:[[:space:]]+${rhsm_repo}[[:space:]]*\$"; then + subscription-manager repos --enable "$rhsm_repo" + return + fi + + dnf_repo=crb + [ "$major" = 8 ] && dnf_repo=powertools + dnf config-manager --set-enabled "$dnf_repo" || + dnf config-manager setopt "${dnf_repo}.enabled=1" } if [ "${BASH_SOURCE[0]}" = "$0" ]; then