Skip to content

Commit

Permalink
fix: persist kurl local host repos for rhel 9 (#4280)
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh authored Mar 27, 2023
1 parent cf7fbb9 commit 78b2b39
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
4 changes: 4 additions & 0 deletions addons/rook/template/testgrid/k8s-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
. /etc/os-release
case "$ID$VERSION_ID" in
centos9*|rhel9*|ol9*|rocky9*)
# install required host packages
yum install -y lvm2 conntrack-tools socat
# disable yum repos
find /etc/yum.repos.d/ -maxdepth 1 -name '*.repo' -exec mv "{}" "{}.bak" \;
yum clean metadata
;;
esac
postInstallScript: |
Expand Down
39 changes: 20 additions & 19 deletions scripts/common/host-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -251,32 +251,39 @@ function _yum_install_host_packages_el9() {
logStep "Installing host packages ${packages[*]}"

local fullpath=
fullpath="$(_yum_get_host_packages_path "${dir}" "${dir_prefix}")"
if ! test -n "$(shopt -s nullglob; echo "${fullpath}"/*.rpm)" ; then
fullpath="$(_yum_get_host_packages_path "$dir" "$dir_prefix")"
if ! test -n "$(shopt -s nullglob; echo "$fullpath"/*.rpm)" ; then
echo "Will not install host packages ${packages[*]}, no packages found."
return 0
fi
cat > /etc/yum.repos.d/kurl.local.repo <<EOF
[kurl.local]
name=kURL Local Repo
baseurl=file://${fullpath}

local repoprefix=
repoprefix="$(echo "${dir%"/"}" | awk -F'/' '{ print $(NF-1) "-" $NF }')"
if [ -n "$dir_prefix" ]; then
repoprefix="$repoprefix.${dir_prefix/#"/"}"
fi

local reponame="$repoprefix.kurl.local"
local repopath="/var/lib/kurl.repos/$repoprefix"

mkdir -p "/var/lib/kurl.repos"
rm -rf "$repopath"
cp -r "$fullpath" "$repopath"

cat > "/etc/yum.repos.d/$reponame.repo" <<EOF
[$reponame]
name=kURL $repoprefix Local Repo
baseurl=file://$repopath
enabled=1
gpgcheck=0
repo_gpgcheck=0
metadata_expire=1m
EOF
# We always use the same repo and we are kinda abusing yum here so we have to clear the cache.
yum clean expire-cache --disablerepo=* --enablerepo=kurl.local

if [[ "${packages[*]}" == *"containerd.io"* ]] ; then
yum install --allowerasing -y "${packages[@]}"
else
yum install -y "${packages[@]}"
fi
yum clean expire-cache --disablerepo=* --enablerepo=kurl.local
rm /etc/yum.repos.d/kurl.local.repo

reset_dnf_module_kurl_local

logSuccess "Host packages ${packages[*]} installed"
}
Expand Down Expand Up @@ -360,7 +367,6 @@ function preflights_require_host_packages() {
local distro=rhel-9

local fail=0
local did_clean_metadata=0

local dir=
for dir in addons/*/ packages/*/ ; do
Expand All @@ -383,11 +389,6 @@ function preflights_require_host_packages() {
fi
local dep=
while read -r dep ; do
if [ "$did_clean_metadata" != "1" ]; then
# clean metadata to ensure we can still resolve dependencies
yum clean metadata || true
did_clean_metadata=1
fi
if ! yum_is_host_package_installed_or_available "$dep" ; then
if [ "$fail" = "0" ]; then
echo ""
Expand Down
16 changes: 16 additions & 0 deletions testgrid/specs/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@
. /etc/os-release
case "$ID$VERSION_ID" in
centos9*|rhel9*|ol9*|rocky9*)
# install required host packages
yum install -y lvm2 conntrack-tools socat
# disable yum repos
find /etc/yum.repos.d/ -maxdepth 1 -name '*.repo' -exec mv "{}" "{}.bak" \;
yum clean metadata
;;
esac
- name: k8s122
Expand Down Expand Up @@ -148,7 +152,11 @@
. /etc/os-release
case "$ID$VERSION_ID" in
centos9*|rhel9*|ol9*|rocky9*)
# install required host packages
yum install -y lvm2 conntrack-tools socat
# disable yum repos
find /etc/yum.repos.d/ -maxdepth 1 -name '*.repo' -exec mv "{}" "{}.bak" \;
yum clean metadata
;;
esac
- name: minimal-124
Expand Down Expand Up @@ -289,7 +297,11 @@
. /etc/os-release
case "$ID$VERSION_ID" in
centos9*|rhel9*|ol9*|rocky9*)
# install required host packages
yum install -y lvm2 conntrack-tools socat
# disable yum repos
find /etc/yum.repos.d/ -maxdepth 1 -name '*.repo' -exec mv "{}" "{}.bak" \;
yum clean metadata
;;
esac
- name: "k8s_126x airgap"
Expand Down Expand Up @@ -317,7 +329,11 @@
. /etc/os-release
case "$ID$VERSION_ID" in
centos9*|rhel9*|ol9*|rocky9*)
# install required host packages
yum install -y lvm2 conntrack-tools socat
# disable yum repos
find /etc/yum.repos.d/ -maxdepth 1 -name '*.repo' -exec mv "{}" "{}.bak" \;
yum clean metadata
;;
esac
- name: "Migrate from Docker to Containerd and Kubernetes from 1.23 to 1.25 airgap"
Expand Down

0 comments on commit 78b2b39

Please sign in to comment.