Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: kata-manager: Allow installing kata from a given tarball #8439

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
fidencio marked this conversation as resolved.
Show resolved Hide resolved
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"

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