Skip to content

Commit

Permalink
Merge pull request kata-containers#502 from chavafg/topic/obs-fix
Browse files Browse the repository at this point in the history
CI: Build from sources if packages couldnt be installed
  • Loading branch information
Sebastien Boeuf authored Jul 17, 2018
2 parents b4a9ce6 + 62f19bf commit 805092a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 29 deletions.
20 changes: 13 additions & 7 deletions .ci/install_kata_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ trap cleanup EXIT

get_packaged_agent_version() {
version=$(ls "$IMG_PATH" | grep "$PACKAGED_IMAGE" | cut -d'_' -f4 | cut -d'.' -f1)
if [ -z "$version" ]; then
die "unknown agent version"
fi
echo "$version"
}

install_packaged_image() {
rc=0
if [ "$ID" == "ubuntu" ]; then
chronic sudo -E apt install -y "$PACKAGED_IMAGE"
chronic sudo -E apt install -y "$PACKAGED_IMAGE" || rc=1
elif [ "$ID" == "fedora" ]; then
chronic sudo -E dnf install -y "$PACKAGED_IMAGE"
chronic sudo -E dnf install -y "$PACKAGED_IMAGE" || rc=1
elif [ "$ID" == "centos" ]; then
chronic sudo -E yum install -y "$PACKAGED_IMAGE"
chronic sudo -E yum install -y "$PACKAGED_IMAGE" || rc=1
else
die "Linux distribution not supported"
fi

return "$rc"
}

update_agent() {
Expand Down Expand Up @@ -140,7 +140,13 @@ main() {
if [ x"${TEST_INITRD}" == x"yes" ]; then
build_image
else
install_packaged_image
# If installing packaged image from OBS fails,
# then build and install it from sources.
rc=0
install_packaged_image || rc=1
if [ "$rc" == "1" ]; then
build_image && exit
fi
packaged_version=$(get_packaged_agent_version)
if [ -z "$packaged_version" ]; then
build_image
Expand Down
27 changes: 15 additions & 12 deletions .ci/install_kata_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ get_packaged_kernel_version() {
kernel_version=$(sudo yum --showduplicate list $packaged_kernel | awk '/'$packaged_kernel'/ {print $2}' | cut -d'-' -f1)
fi

if [ -z "$kernel_version" ]; then
die "unknown kernel version"
else
echo "${kernel_version}"
fi

echo "${kernel_version}"
}

# download the linux kernel, first argument is the kernel version
Expand All @@ -72,6 +67,7 @@ download_kernel() {
# build the linux kernel, first argument is the kernel version
build_and_install_kernel() {
kernel_version=$1
download_kernel ${kernel_version}
pushd ${tmp_dir}
kernel_config_file=$(realpath ${repo_name}/kernel/configs/[${kernel_arch}]*_kata_${hypervisor}_* | tail -1)
kernel_patches=$(realpath ${repo_name}/kernel/patches/*)
Expand All @@ -90,18 +86,23 @@ build_and_install_kernel() {
sudo cp -a "$(realpath vmlinux)" "${kata_kernel_dir}/vmlinux.container"
popd
popd

cleanup
}

install_packaged_kernel(){
rc=0
if [ "$ID" == "ubuntu" ]; then
chronic sudo apt install -y "$packaged_kernel"
chronic sudo apt install -y "$packaged_kernel" || rc=1
elif [ "$ID" == "fedora" ]; then
chronic sudo dnf install -y "$packaged_kernel"
chronic sudo dnf install -y "$packaged_kernel" || rc=1
elif [ "$ID" == "centos" ]; then
chronic sudo yum install -y "$packaged_kernel"
chronic sudo yum install -y "$packaged_kernel" || rc=1
else
die "Unrecognized distro"
fi

return "$rc"
}

cleanup() {
Expand All @@ -115,11 +116,13 @@ main() {
current_kernel_version="${kernel_version}.${kata_config_version}"
packaged_kernel_version=$(get_packaged_kernel_version)
if [ "$packaged_kernel_version" == "$current_kernel_version" ] && [ "$kernel_arch" == "x86_64" ]; then
install_packaged_kernel
# If installing packaged kernel from OBS fails,
# then build and install it from sources.
install_packaged_kernel || \
build_and_install_kernel ${kernel_version}

else
download_kernel ${kernel_version}
build_and_install_kernel ${kernel_version}
cleanup
fi
}

Expand Down
23 changes: 13 additions & 10 deletions .ci/install_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ get_packaged_qemu_commit() {
| awk '/'$PACKAGED_QEMU'/ {print $2}' | cut -d'-' -f1 | cut -d'.' -f4)
fi

if [ -z "$qemu_commit" ]; then
die "unknown qemu commit"
else
echo "${qemu_commit}"
fi
echo "${qemu_commit}"
}

install_packaged_qemu() {
rc=0
# Timeout to download packages from OBS
limit=180
if [ "$ID" == "ubuntu" ]; then
chronic sudo apt install -y "$PACKAGED_QEMU"
chronic sudo apt install -y "$PACKAGED_QEMU" || rc=1
elif [ "$ID" == "fedora" ]; then
chronic sudo dnf install -y "$PACKAGED_QEMU"
chronic sudo dnf install -y "$PACKAGED_QEMU" || rc=1
elif [ "$ID" == "centos" ]; then
chronic sudo yum install -y "$PACKAGED_QEMU"
chronic sudo yum install -y "$PACKAGED_QEMU" || rc=1
else
die "Unrecognized distro"
fi

return "$rc"
}

build_and_install_qemu() {
Expand Down Expand Up @@ -84,15 +85,17 @@ main() {
packaged_qemu_commit=$(get_packaged_qemu_commit)
short_current_qemu_commit=${CURRENT_QEMU_COMMIT:0:10}
if [ "$packaged_qemu_commit" == "$short_current_qemu_commit" ]; then
install_packaged_qemu
# If installing packaged qemu from OBS fails,
# then build and install it from sources.
install_packaged_qemu || build_and_install_qemu
else
build_and_install_qemu
fi
elif [ "$QEMU_ARCH" == "aarch64" ]; then
packaged_qemu_version=$(get_packaged_qemu_version)
short_current_qemu_version=${CURRENT_QEMU_VERSION#*-}
if [ "$packaged_qemu_version" == "$short_current_qemu_version" ]; then
install_packaged_qemu
install_packaged_qemu || build_and_install_qemu
else
build_and_install_qemu
fi
Expand Down
3 changes: 3 additions & 0 deletions .ci/setup_env_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ if [ "$(arch)" == "x86_64" ]; then
echo "Install Kata Containers OBS repository"
obs_url="http://download.opensuse.org/repositories/home:/katacontainers:/release/CentOS_${VERSION_ID}/home:katacontainers:release.repo"
sudo -E VERSION_ID=$VERSION_ID yum-config-manager --add-repo "$obs_url"
repo_file="/etc/yum.repos.d/home\:katacontainers\:release.repo"
sudo bash -c "echo timeout=10 >> $repo_file"
sudo bash -c "echo retries=2 >> $repo_file"
fi

echo "Install cri-containerd dependencies"
Expand Down

0 comments on commit 805092a

Please sign in to comment.