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

feat: Move WASM to components.json #4969

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
776c569
test our rework with no logic changes (kinda)
AlisonB319 Sep 12, 2024
f02e473
only download wasm once
AlisonB319 Sep 12, 2024
ce1fd94
use the right function
AlisonB319 Sep 12, 2024
0900019
try to perserve timesave
AlisonB319 Sep 13, 2024
80132e7
add something for the tester function
AlisonB319 Sep 13, 2024
9e84123
fix filepath var
AlisonB319 Sep 16, 2024
2f7e52a
general cleanup no logic changes
AlisonB319 Sep 16, 2024
9a2ec57
try switching things around
AlisonB319 Sep 16, 2024
9fd22fb
trying to figure out the URL
AlisonB319 Sep 17, 2024
271c341
Add debugging message
AlisonB319 Sep 17, 2024
f37888f
i don't think this will work with the array
AlisonB319 Sep 17, 2024
020609e
reworking all in cse_install file
AlisonB319 Sep 17, 2024
d260461
clean up functions bc why is it breaking
AlisonB319 Sep 17, 2024
13ce326
add retry to hopefully fix brokenness
AlisonB319 Sep 17, 2024
bae3f9f
small tweaks
AlisonB319 Sep 17, 2024
6fc3a56
merge master
AlisonB319 Sep 17, 2024
4c2dc8e
fix syntax problems
AlisonB319 Sep 17, 2024
6e144a9
fix function call name
AlisonB319 Sep 17, 2024
8385dd3
do pid checks
AlisonB319 Sep 17, 2024
05a88de
include curl output
AlisonB319 Sep 17, 2024
3a01366
add quotes
AlisonB319 Sep 17, 2024
c0064ef
add evaluatedUrl
AlisonB319 Sep 17, 2024
5b15b4e
more debugging
AlisonB319 Sep 17, 2024
ec54ed6
trying smt new
AlisonB319 Sep 17, 2024
cbbbdd3
trying smt new
AlisonB319 Sep 17, 2024
657ebd5
more debugging
AlisonB319 Sep 17, 2024
95bfcfa
unbound var
AlisonB319 Sep 18, 2024
4b46dd2
cleanup woo
AlisonB319 Sep 18, 2024
12564a2
fix loop
AlisonB319 Sep 18, 2024
4b9b9ea
look at the dir
AlisonB319 Sep 18, 2024
1cdd199
debugging with stop
AlisonB319 Sep 18, 2024
8df659f
more testing
AlisonB319 Sep 18, 2024
a90453e
go back to local var??
AlisonB319 Sep 18, 2024
1155c14
cleanup with the correct file path i hope
AlisonB319 Sep 18, 2024
1de539c
remove exit
AlisonB319 Sep 18, 2024
a300404
put in specific tests for wasm
AlisonB319 Sep 18, 2024
ed685a9
fix airgap e2e
AlisonB319 Sep 18, 2024
289431f
cleanup tests
AlisonB319 Sep 18, 2024
36b9505
include files in the err msg to output
AlisonB319 Sep 18, 2024
1b71288
rvt to 3
AlisonB319 Sep 18, 2024
29df8fd
correct version format
AlisonB319 Sep 18, 2024
0c24382
correct version format
AlisonB319 Sep 18, 2024
7df7d56
add vars
AlisonB319 Sep 18, 2024
d11f26a
remove first slash
AlisonB319 Sep 18, 2024
4800b90
whoops
AlisonB319 Sep 18, 2024
78c84f8
add continue statement
AlisonB319 Sep 18, 2024
f970ff8
modify testing
AlisonB319 Sep 18, 2024
4801f6f
fix e2e
AlisonB319 Sep 18, 2024
b0bc445
fix v
AlisonB319 Sep 18, 2024
8ec0df7
Merge branch 'master' into alburgess/wasm-compJson
AlisonB319 Sep 19, 2024
d546637
feat: move wasm to components.json
AlisonB319 Sep 19, 2024
8319b35
make some tweaks and update testing
AlisonB319 Sep 19, 2024
967d225
add locals
AlisonB319 Sep 19, 2024
ae86f2b
cleanup
AlisonB319 Sep 19, 2024
d6d15bd
Merge branch 'alburgess/wasm-comp2' into alburgess/wasm-compJson
AlisonB319 Sep 19, 2024
46049df
comment
AlisonB319 Sep 19, 2024
e549730
check the file
AlisonB319 Sep 19, 2024
ec3a251
add some testing for updating the binaries
AlisonB319 Sep 19, 2024
e40a0dc
add testing echos
AlisonB319 Sep 19, 2024
bb6ad61
add new comp.json
AlisonB319 Sep 19, 2024
c205bcc
make changes for spinkube
AlisonB319 Sep 19, 2024
84cbd15
remove .15 from wasm-shims
AlisonB319 Sep 19, 2024
df76975
testdata
AlisonB319 Sep 19, 2024
2062cf0
combine vars
AlisonB319 Sep 19, 2024
dcb3d30
add version v's
AlisonB319 Sep 19, 2024
e9724af
save
AlisonB319 Sep 19, 2024
6ff0dfc
save
AlisonB319 Sep 19, 2024
6deed37
re-work for spinkube
AlisonB319 Sep 19, 2024
b916071
fix if statement
AlisonB319 Sep 19, 2024
0503a75
handle the v
AlisonB319 Sep 19, 2024
8163b4d
Merge branch 'master' into alburgess/wasm-compJson
AlisonB319 Sep 19, 2024
459d41d
tweaks for debugging
AlisonB319 Sep 19, 2024
6f9fc5c
fixes
AlisonB319 Sep 19, 2024
e0f35db
fixes
AlisonB319 Sep 20, 2024
9c02cd2
fix var
AlisonB319 Sep 20, 2024
6d184ac
some tweeks and url fix
AlisonB319 Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pipelines/templates/.builder-release-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ steps:
-e PRIVATE_PACKAGES_URL="${PRIVATE_PACKAGES_URL}" \
-e AZURE_MSI_RESOURCE_STRING=${AZURE_MSI_RESOURCE_STRING} \
${CONTAINER_IMAGE} make -f packer.mk run-packer
retryCountOnTaskFailure: 3
retryCountOnTaskFailure: 1 # for debugging
displayName: Building VHD
- bash: |
OS_DISK_URI="$(cat packer-output | grep "OSDiskUri:" | cut -d " " -f 2)" && \
Expand Down
2 changes: 1 addition & 1 deletion parts/linux/cloud-init/artifacts/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@
}
},
{
"name": "containerd-wasm-spinkube",
"name": "spinkube",
"downloadLocation": "/usr/local/bin",
"downloadURIs": {
"default": {
Expand Down
155 changes: 88 additions & 67 deletions parts/linux/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ UBUNTU_OS_NAME="UBUNTU"
MARINER_OS_NAME="MARINER"
CPU_ARCH=""
declare -a WASMSHIMPIDS=()
declare -a SPINKUBEPIDS=()

setCPUArch() {
CPU_ARCH=$(getCPUArch)
Expand Down Expand Up @@ -200,96 +201,75 @@ downloadSecureTLSBootstrapKubeletExecPlugin() {
fi
}

wasmFilesExist() {
local containerd_wasm_filepath=${1}
local shim_version=${2}
local shims_to_download=${3}
local version_suffix=${4}

local binary_version="$(echo "${shim_version}" | tr . -)"
for shim in "${shims_to_download[@]}"; do
if [ ! -f "${containerd_wasm_filepath}/containerd-shim-${shim}-${binary_version}-${version_suffix}" ]; then
return 1 # file is missing
fi
done
return 0
}

# Install, download, update wasm must all be run from the same function call
# in order to ensure WASMSHIMPIDS persists correctly since in bash a new
# function call from install-dependnecies will create a new shell process.
installContainerdWasmShims(){
local download_location=${1}
PACKAGE_DOWNLOAD_URL=${2}
shift 2 # shift past the first 2 arguments to capture the list of versions
local package_versions=("$@")
local json_versions=("$@")

local shims_to_download=("spin" "slight")
local version_suffix="-v1"
local mcr_registry_path="deislabs/containerd-wasm-shims"
local shim_filename="containerd-wasm-shims-linux-${CPU_ARCH}.tar.gz"
if [ "$shim_version" == "0.15.1" ]; then
version_suffix="-v2"
shims_to_download=("spin")
mcr_registry_path="spinkube/containerd-shim-spin"
shim_filename="containerd-shim-spin-v2"
elif [ "$shim_version" == "0.8.0" ]; then
shims_to_download+=("wws")
fi

package_versions=()
for version in "${json_versions[@]}"; do
if version == "0.8.0"; then
shims_to_download+=("wws")
fi
package_versions+=("v$version")
done

for version in "${package_versions[@]}"; do
containerd_wasm_url=$(evalPackageDownloadURL ${PACKAGE_DOWNLOAD_URL})
downloadContainerdWasmShims $download_location $containerd_wasm_url $version $shims_to_download $version_suffix $mcr_registry_path $shim_filename
downloadContainerdWasmShims $download_location $containerd_wasm_url $version $shims_to_download
done
wait ${WASMSHIMPIDS[@]}
for version in "${package_versions[@]}"; do
updateContainerdWasmShimsPermissions $download_location $version $shims_to_download $version_suffix
updateContainerdWasmShimsPermissions $download_location $version $shims_to_download
done
}

wasmFilesExist() {
local containerd_wasm_filepath=${1}
local shim_version=${2}
local shims_to_download=${3}
local version_suffix=${4}

local binary_version="$(echo "${shim_version}" | tr . -)"
for shim in "${shims_to_download[@]}"; do
if [ ! -f "${containerd_wasm_filepath}/containerd-shim-${shim}-v${binary_version}-${version_suffix}" ]; then
return 1 # file is missing
fi
done
return 0
}

downloadContainerdWasmShims() {
local containerd_wasm_filepath=${1}
local containerd_wasm_url=${2}
local shim_version=${3}
local shims_to_download=${4}
local version_suffix=${5}
local mcr_registry_path=${6}
local shim_filename=${7}

local binary_version="$(echo "${shim_version}" | tr . -)" # replaces . with - == 1.2.3 -> 1-2-3

echo "containerd_wasm_filepath: $containerd_wasm_filepath, containerd_wasm_url: $containerd_wasm_url, shim_version: $shim_version, binary_version: $binary_version, shims_to_download: ${shims_to_download[@]}, version_suffix: $version_suffix, mcr_registry_path: $mcr_registry_path, shim_filename: $shim_filename"

if wasmFilesExist "$containerd_wasm_filepath" "$shim_version" "$shims_to_download" "$version_suffix"; then
if wasmFilesExist "$containerd_wasm_filepath" "$shim_version" "$shims_to_download" "-v1"; then
return
fi

# Oras download for WASM for Network Isolated Clusters
BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER:=}"
if [[ ! -z ${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER} ]]; then
local registry_url="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}/oss/binaries/${mcr_registry_path}:v${shim_version}-linux-${CPU_ARCH}"
local wasm_shims_tgz_tmp="${containerd_wasm_filepath}/${shim_filename}"

# if shim version is 0.15.1, the downloaded binary is already named correctly, so no need to extract
# if shim version is not 0.15.1, extract the shims and rename them to match the binary version
if [ "$shim_version" == "0.15.1" ]; then
retrycmd_get_binary_from_registry_with_oras 120 5 "${wasm_shims_tgz_tmp}" "${registry_url}" || exit $ERR_ORAS_PULL_CONTAINERD_WASM
mv "${containerd_wasm_filepath}/containerd-shim-spin-${version_suffix}" "${containerd_wasm_filepath}/containerd-shim-spin-v${binary_version}${version_suffix}"
else
retrycmd_get_tarball_from_registry_with_oras 120 5 "${wasm_shims_tgz_tmp}" "${registry_url}" || exit $ERR_ORAS_PULL_CONTAINERD_WASM
tar -zxf "$wasm_shims_tgz_tmp" -C "$containerd_wasm_filepath"
for shim in "${shims_to_download[@]}"; do
mv "${containerd_wasm_filepath}/containerd-shim-${shim}-v${shim_version}${version_suffix}" "${containerd_wasm_filepath}/containerd-shim-${shim}-v${binary_version}${version_suffix}"
done
fi
local registry_url="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}/oss/binaries/deislabs/containerd-wasm-shims:v${shim_version}-linux-${CPU_ARCH}"
AlisonB319 marked this conversation as resolved.
Show resolved Hide resolved
local wasm_shims_tgz_tmp=$containerd_wasm_filepath/containerd-wasm-shims-linux-${CPU_ARCH}.tar.gz

retrycmd_get_tarball_from_registry_with_oras 120 5 "${wasm_shims_tgz_tmp}" ${registry_url} || exit $ERR_ORAS_PULL_CONTAINERD_WASM
tar -zxf "$wasm_shims_tgz_tmp" -C $containerd_wasm_filepath
mv "$containerd_wasm_filepath/containerd-shim-*-v${shim_version}-v1" "$containerd_wasm_filepath/containerd-shim-*-${binary_version}-v1"
AlisonB319 marked this conversation as resolved.
Show resolved Hide resolved
rm -f "$wasm_shims_tgz_tmp"
return
fi

# install from acs-mirror
for shim in "${shims_to_download[@]}"; do
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-${shim}-v${binary_version}${version_suffix}" "$containerd_wasm_url/containerd-shim-${shim}-${version_suffix}" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT) &
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-${shim}-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-${shim}-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT) &
WASMSHIMPIDS+=($!)
done
}
Expand All @@ -298,25 +278,66 @@ updateContainerdWasmShimsPermissions() {
local containerd_wasm_filepath=${1}
local shim_version=${2}
local shims_to_download=${3}
local version_suffix=${4}

local binary_version="$(echo "${shim_version}" | tr . -)"

echo "Updating permissions containerd_wasm_filepath: $containerd_wasm_filepath, shim_version: $shim_version, binary_version: $binary_version, shims_to_download: ${shims_to_download[@]}, version_suffix: $version_suffix"
for shim in "${shims_to_download[@]}"; do
chmod 755 "$containerd_wasm_filepath/containerd-${shim}-spin-${binary_version}-v1"
done
}

installSpinKube(){
local download_location=${1}
PACKAGE_DOWNLOAD_URL=${2}
shift 2 # shift past the first 2 arguments to capture the list of versions
local json_versions=("$@")

package_versions=()
for version in "${json_versions[@]}"; do
package_versions+=("v$version")
done

for version in "${package_versions[@]}"; do
containerd_wasm_url=$(evalPackageDownloadURL ${PACKAGE_DOWNLOAD_URL})
downloadSpinKube $download_location $containerd_wasm_url $version
done
wait ${SPINKUBEPIDS[@]}
for version in "${package_versions[@]}"; do
updateSpinKubePermissions $download_location $version
done
}

downloadSpinKube(){
local containerd_wasm_filepath=${1}
local containerd_wasm_url=${2}
local shim_version=${3}
local binary_version="$(echo "${shim_version}" | tr . -)"

if [ "$shim_version" == "0.15.1" ]; then
echo "inside the 0.15.1: $shim_version"
chmod 755 "$containerd_wasm_filepath/containerd-shim-spin-v${binary_version}-${version_suffix}"
# spin shim v0.15.1 cannot be renamed: https://github.com/spinkube/containerd-shim-spin/issues/190
# so we rename the shim back to containerd-shim-spin-v2
mv "$containerd_wasm_filepath/containerd-shim-spin-v${binary_version}-${version_suffix}" "$containerd_wasm_filepath/containerd-shim-spin-${version_suffix}"
if wasmFilesExist "$containerd_wasm_filepath" "$shim_version" "spin" "-v2"; then
return
fi

for shim in "${shims_to_download[@]}"; do
echo "updating for shil: $shim ----> $containerd_wasm_filepath/containerd-shim-${shim}-v${binary_version}-${version_suffix}"
chmod 755 "$containerd_wasm_filepath/containerd-shim-${shim}-v${binary_version}-${version_suffix}"
done
BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER:=}"
if [[ ! -z ${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER} ]]; then
local registry_url="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}/oss/binaries/spinkube/containerd-shim-spin:${shim_version}-linux-${CPU_ARCH}"
local wasm_shims_tgz_tmp="${containerd_wasm_filepath}/containerd-shim-spin-v2"
retrycmd_get_binary_from_registry_with_oras 120 5 "${wasm_shims_tgz_tmp}" "${registry_url}" || exit $ERR_ORAS_PULL_CONTAINERD_WASM
mv "${containerd_wasm_filepath}/containerd-shim-spin-v2" "${containerd_wasm_filepath}/containerd-shim-spin-${binary_version}-v2"
AlisonB319 marked this conversation as resolved.
Show resolved Hide resolved
rm -f "$wasm_shims_tgz_tmp"
return
fi

retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v2" "$containerd_wasm_url/containerd-shim-spin-v2" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT) &
SPINKUBEPIDS+=($!)
}

updateSpinKubePermissions() {
local containerd_wasm_filepath=${1}
local shim_version=${2}
local shims_to_download=${3}
local binary_version="$(echo "${shim_version}" | tr . -)"

chmod 755 "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chmod 755 "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v2"
chmod 755 "$containerd_wasm_filepath/containerd-shim-spin-v2"

mv "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v2" "$containerd_wasm_filepath/containerd-shim-spin-v2"
AlisonB319 marked this conversation as resolved.
Show resolved Hide resolved
}

# TODO (alburgess) have oras version managed by dependant or Renovate
Expand Down
16 changes: 10 additions & 6 deletions parts/linux/cloud-init/artifacts/cse_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,18 @@ setupCNIDirs
logs_to_events "AKS.CSE.installNetworkPlugin" installNetworkPlugin

if [ "${IS_KRUSTLET}" == "true" ]; then
components_filepath="/opt/azure/components.json"
versions=$(jq -r '.Packages[] | select(.name == "containerd-wasm-shims") | .downloadURIs.default.current.versionsV2[].latestVersion' "$components_filepath")
downloadLocation=$(jq -r '.Packages[] | select(.name == "containerd-wasm-shims") | .downloadLocation' "$components_filepath")
downloadURL=$(jq -r '.Packages[] | select(.name == "containerd-wasm-shims") | .downloadURIs.default.current.downloadURL' "$components_filepath")
local components_filepath="/opt/azure/components.json"

logs_to_events "AKS.CSE.downloadKrustlet" installContainerdWasmShims "$downloadLocation" "$downloadURL" "$versions"
fi
local versionsWasm=$(jq -r '.Packages[] | select(.name == "containerd-wasm-shims") | .downloadURIs.default.current.versionsV2[].latestVersion' "$components_filepath")
local downloadLocationWasm=$(jq -r '.Packages[] | select(.name == "containerd-wasm-shims") | .downloadLocation' "$components_filepath")
local downloadURLWasm=$(jq -r '.Packages[] | select(.name == "containerd-wasm-shims") | .downloadURIs.default.current.downloadURL' "$components_filepath")
logs_to_events "AKS.CSE.downloadKrustlet" installContainerdWasmShims "$downloadLocationWasm" "$downloadURLWasm" "$versionsWasm"

local versionsSpinKube=$(jq -r '.Packages[] | select(.name == spinkube") | .downloadURIs.default.current.versionsV2[].latestVersion' "$components_filepath")
local downloadLocationSpinKube=$(jq -r '.Packages[] | select(.name == "spinkube) | .downloadLocation' "$components_filepath")
local downloadURLSpinKube=$(jq -r '.Packages[] | select(.name == "spinkube") | .downloadURIs.default.current.downloadURL' "$components_filepath")
logs_to_events "AKS.CSE.downloadKrustlet" installSpinKube "$downloadURSpinKube" "$downloadLocationSpinKube" "$versionsSpinKube"
fi

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ]; then
logs_to_events "AKS.CSE.downloadSecureTLSBootstrapKubeletExecPlugin" downloadSecureTLSBootstrapKubeletExecPlugin
Expand Down
Loading
Loading