Skip to content

Commit

Permalink
support host package checking on Ubuntu 2404 (#5345)
Browse files Browse the repository at this point in the history
* only check deps for current OS

* add kubernetes package deps
  • Loading branch information
laverya authored Aug 22, 2024
1 parent 68efecc commit b8efefe
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
2 changes: 2 additions & 0 deletions bin/save-manifest-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ pkgs_ol7=()
pkgs_amazon2023=()
deps_rhel9=()
deps_amazon2023=()
deps_ubuntu2404=()

while read -r line || [ -n "$line" ]; do
if [ -z "$line" ]; then
Expand Down Expand Up @@ -426,6 +427,7 @@ while read -r line || [ -n "$line" ]; do
apt)
mkdir -p "$OUT_DIR"/ubuntu-22.04 "$OUT_DIR"/ubuntu-20.04 "$OUT_DIR"/ubuntu-18.04 "$OUT_DIR"/ubuntu-16.04
package=$(echo "$line" | awk '{ print $2 }')
deps_ubuntu2404+=("$package")

docker rm -f ubuntu-2204-"$package" 2>/dev/null || true
docker run \
Expand Down
17 changes: 17 additions & 0 deletions bundles/k8s-ubuntu2404/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN mkdir -p /archives

ARG KUBERNETES_VERSION

# get the urls of the actual kubernetes packages
RUN apt-get --print-uris --yes install \
kubeadm=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep ^\' | cut -d\' -f2 > ~/raw_urls.txt
Expand All @@ -25,3 +26,19 @@ RUN apt-get --print-uris --yes install \

RUN cat ~/raw_urls.txt | grep 'pkgs.k8s.io' > ~/urls.txt
RUN cd /archives && cat ~/urls.txt | xargs -I {} -n 1 curl -L -O {}

# get the names of the packages that those depend on
RUN apt-cache depends kubeadm=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep Depends | \
grep -v kubeadm | \
grep -v '<' | \
grep -v 'cri-tools' | \
grep -v 'kubernetes-cni' | \
awk '{ print $2 }' > /archives/Deps
RUN apt-cache depends kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep Depends | \
grep -v kubeadm | \
grep -v '<' | \
grep -v 'cri-tools' | \
grep -v 'kubernetes-cni' | \
awk '{ print $2 }' >> /archives/Deps \
42 changes: 33 additions & 9 deletions scripts/common/host-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,41 @@ function preflights_require_host_packages() {
fi
seen+=("$dep")

if ! echo "$deps_file" | grep -q "rhel-9"; then
if ! echo "$deps_file" | grep -q "amazon-2023"; then
if ! echo "$deps_file" | grep -q "ubuntu-24.04"; then
# use rpm to check rhel/centos/ol/rocky/amzn and dpkg-query to check ubuntu
case "$LSB_DIST" in
centos|rhel|ol|rocky)
if ! echo "$deps_file" | grep -q "rhel-9"; then
continue
fi
fi
fi
if rpm -q "$dep" >/dev/null 2>&1 ; then
continue
fi
fail=1
if rpm -q "$dep" >/dev/null 2>&1 ; then
continue
fi
fail=1
;;
amzn)
if ! echo "$deps_file" | grep -q "amazon-2023"; then
continue
fi
if rpm -q "$dep" >/dev/null 2>&1 ; then
continue
fi
fail=1
;;
ubuntu)
if ! echo "$deps_file" | grep -q "ubuntu-24"; then
continue
fi
if dpkg-query -W -f='${Status}' "$dep" 2>/dev/null | grep -q "ok installed"; then
continue
fi
fail=1
;;
*)
logFail "Host package checks are not supported on ${LSB_DIST} ${DIST_MAJOR}"
fail=1
;;
esac

component=$(echo "$deps_file" | awk -F'/' '{print $3}')
if [ "$component" = "host" ]; then
logFail "Host package $dep is required"
Expand Down

0 comments on commit b8efefe

Please sign in to comment.