Skip to content

Commit

Permalink
utils: kata-manager: Allow installing kata from a given tarball
Browse files Browse the repository at this point in the history
With this change, we give the users the change to try kata-containers
with their own pre-built tarball.

This will become very useful in the CI context, as we won't be
downloading a specific version of kata-containers, but rather installing
whatever was built in previous steps of the CI pipeline.

Fixes: kata-containers#8438

Signed-off-by: Fabiano Fidêncio <[email protected]>
  • Loading branch information
fidencio committed Nov 14, 2023
1 parent fd9b6d6 commit 38d2edd
Showing 1 changed file with 43 additions and 26 deletions.
69 changes: 43 additions & 26 deletions utils/kata-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Options:
-f : Force installation (use with care).
-h : Show this help statement.
-k <version> : Specify Kata Containers version.
-K <tarball> : Specify local Kata Containers tarball to install (takes priority over '-k').
-l : List installed and available versions only, then exit (uses network).
-o : Only install Kata Containers.
-r : Don't cleanup on failure (retain files).
Expand Down Expand Up @@ -583,29 +584,36 @@ configure_containerd()
install_kata()
{
local requested_version="${1:-}"
local kata_tarball="${2:-}"

local project="$kata_project"

local version_desc="latest version"
[ -n "$requested_version" ] && version_desc="version $requested_version"

info "Downloading $project release ($version_desc)"

local results
results=$(github_download_package \
"$kata_releases_url" \
"$requested_version" \
"$project")

[ -z "$results" ] && die "Cannot download $project release file"

local version
version=$(echo "$results"|cut -d: -f1)

local file
file=$(echo "$results"|cut -d: -f2-)
local version=""
if [ -z "$kata_tarball" ]
then
local version_desc="latest version"
[ -n "$requested_version" ] && version_desc="version $requested_version"

info "Downloading $project release ($version_desc)"

local results
results=$(github_download_package \
"$kata_releases_url" \
"$requested_version" \
"$project")

[ -z "$results" ] && die "Cannot download $project release file"

version=$(echo "$results"|cut -d: -f1)

[ -z "$version" ] && die "Cannot determine $project resolved version"

local file
file=$(echo "$results"|cut -d: -f2-)
else
file="$kata_tarball"
fi

[ -z "$version" ] && die "Cannot determine $project resolved version"
[ -z "$file" ] && die "Cannot determine $project release file"

# Allow the containerd service to find the Kata shim and users to find
Expand All @@ -627,7 +635,12 @@ install_kata()

[ -n "$unexpected" ] && die "File '$file' contains unexpected paths: '$unexpected'"

info "Installing $project release $version from $file"
if [ -n "$kata_tarball" ]
then
info "Installing $project release from $file"
else
info "Installing $project release $version from $file"
fi

sudo tar -C / -xvf "${file}"

Expand Down Expand Up @@ -680,11 +693,12 @@ configure_kata()
handle_kata()
{
local version="${1:-}"
local tarball="${2:-}"

local enable_debug="${2:-}"
local enable_debug="${3:-}"
[ -z "$enable_debug" ] && die "no enable debug value"

install_kata "$version" "$enable_debug"
install_kata "$version" "$tarball" "$enable_debug"

configure_kata "$enable_debug"

Expand Down Expand Up @@ -838,10 +852,10 @@ handle_installation()
# These params can be blank
local kata_version="${7:-}"
local containerd_flavour="${8:-}"

local install_docker="${9:-}"
[ -z "$install_docker" ] && die "no install docker value"

local kata_tarball="${10:-}"
# The tool to be testing the installation with
local tool="ctr"

Expand All @@ -861,7 +875,7 @@ handle_installation()

setup "$cleanup" "$force" "$skip_containerd"

handle_kata "$kata_version" "$enable_debug"
handle_kata "$kata_version" "$kata_tarball" "$enable_debug"

[ "$skip_containerd" = "false" ] && \
handle_containerd \
Expand Down Expand Up @@ -957,8 +971,9 @@ handle_args()

local kata_version=""
local containerd_flavour="lts"
local kata_tarball=""

while getopts "c:dDfhk:lortT" opt "$@"
while getopts "c:dDfhk:K:lortT" opt "$@"
do
case "$opt" in
c) containerd_flavour="$OPTARG" ;;
Expand All @@ -967,6 +982,7 @@ handle_args()
f) force="true" ;;
h) usage; exit 0 ;;
k) kata_version="$OPTARG" ;;
K) kata_tarball="$OPTARG" ;;
l) list_versions='true' ;;
o) skip_containerd="true" ;;
r) cleanup="false" ;;
Expand Down Expand Up @@ -995,7 +1011,8 @@ handle_args()
"$only_run_test" \
"$kata_version" \
"$containerd_flavour" \
"$install_docker"
"$install_docker" \
"$kata_tarball"
}

main()
Expand Down

0 comments on commit 38d2edd

Please sign in to comment.