-
Notifications
You must be signed in to change notification settings - Fork 63
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
tests: General improvements to operator script #386
Merged
ldoktor
merged 1 commit into
confidential-containers:main
from
GabyCT:topic/fixoperatorscript
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ set -o nounset | |
set -o pipefail | ||
|
||
script_dir="$(dirname "$(readlink -f "$0")")" | ||
project_dir="$(readlink -f ${script_dir}/../..)" | ||
project_dir="$(readlink -f "${script_dir}"/../..)" | ||
|
||
source "${script_dir}/lib.sh" | ||
|
||
|
@@ -30,7 +30,8 @@ build_operator () { | |
# append the target to .gitconfig without checking the | ||
# existence of the target, | ||
# so it's better to check it before adding the target repo. | ||
local sd="$(git config --global --get safe.directory ${project_dir} || true)" | ||
local sd | ||
sd="$(git config --global --get safe.directory "${project_dir}" || true)" | ||
if [ "${sd}" == "" ]; then | ||
echo "::debug:: Add repo ${project_dir} to git's safe.directory" | ||
git config --global --add safe.directory "${project_dir}" | ||
|
@@ -66,14 +67,15 @@ build_pre_install_img() { | |
# | ||
handle_older_containerd() { | ||
command -v containerd >/dev/null || return | ||
local version=$(containerd -v | awk '{ print $3 }' | sed 's/^v//') | ||
local version | ||
version=$(containerd -v | awk '{ print $3 }' | sed 's/^v//') | ||
echo "::debug:: system's containerd version: $version" | ||
if [[ "$version" =~ ^1.6 || "$version" =~ ^1.5 ]]; then | ||
echo "::warning:: Old system's containerd ($version). Configuring the operator to install a newer one" | ||
pushd "$project_dir" >/dev/null | ||
for kfile in $(find config/ -name "kustomization.yaml" \ | ||
-exec grep -l INSTALL_OFFICIAL_CONTAINERD {} \;);do | ||
sed -i '/INSTALL_OFFICIAL_CONTAINERD/!b;n;s/false/true/;' $kfile | ||
sed -i '/INSTALL_OFFICIAL_CONTAINERD/!b;n;s/false/true/;' "$kfile" | ||
done | ||
popd >/dev/null | ||
fi | ||
|
@@ -101,12 +103,13 @@ install_operator() { | |
|
||
# Wait the operator controller to be running. | ||
local controller_pod="cc-operator-controller-manager" | ||
local cmd="kubectl get pods -n "$op_ns" --no-headers |" | ||
local cmd="kubectl get pods -n '$op_ns' --no-headers |" | ||
cmd+="egrep -q ${controller_pod}.*'\<Running\>'" | ||
if ! wait_for_process 120 10 "$cmd"; then | ||
echo "::error:: ${controller_pod} pod is not running" | ||
|
||
local pod_id="$(get_pods_regex $controller_pod $op_ns)" | ||
local pod_id | ||
pod_id="$(get_pods_regex "$controller_pod" "$op_ns")" | ||
echo "::debug:: Pod $pod_id" | ||
debug_pod "$pod_id" "$op_ns" | ||
|
||
|
@@ -132,12 +135,12 @@ install_ccruntime() { | |
local pod="" | ||
local cmd="" | ||
for pod in cc-operator-daemon-install cc-operator-pre-install-daemon; do | ||
cmd="kubectl get pods -n "$op_ns" --no-headers |" | ||
cmd="kubectl get pods -n '$op_ns' --no-headers |" | ||
cmd+="egrep -q ${pod}.*'\<Running\>'" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here... |
||
if ! wait_for_process 600 30 "$cmd"; then | ||
echo "::error:: $pod pod is not running" | ||
|
||
local pod_id="$(get_pods_regex $pod $op_ns)" | ||
local pod_id | ||
pod_id="$(get_pods_regex "$pod" "$op_ns")" | ||
echo "::debug:: Pod $pod_id" | ||
debug_pod "$pod_id" "$op_ns" | ||
|
||
|
@@ -224,7 +227,7 @@ start_local_registry() { | |
local registry_container="local-registry" | ||
|
||
if ! curl -s localhost:5000; then | ||
docker start local-registry >/dev/null | ||
docker start "$registry_container" >/dev/null | ||
local cnt=0 | ||
while ! curl -s localhost:5000 -o $cnt -lt 5; do | ||
sleep 1 | ||
|
@@ -247,8 +250,8 @@ uninstall_operator() { | |
cmd+="&& ! echo \$_OUT | grep -q -e cc-operator-controller-manager" | ||
if ! wait_for_process 180 30 "$cmd"; then | ||
echo "::error:: the controller manager is still running" | ||
|
||
local pod_id="$(get_pods_regex $pod $op_ns)" | ||
local pod_id | ||
pod_id="$(get_pods_regex "$pod" "$op_ns")" | ||
echo "::debug:: Pod $pod_id" | ||
debug_pod "$pod_id" "$op_ns" | ||
|
||
|
@@ -264,7 +267,8 @@ wait_for_stabilization() { | |
local count=0 | ||
while true; do | ||
local change=0 | ||
local pod_info=$(kubectl get pods -n "$op_ns" -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{range .status.containerStatuses[*]}{.name}{" "}{.restartCount}{"\n"}{end}{end}') | ||
local pod_info | ||
pod_info=$(kubectl get pods -n "$op_ns" -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{range .status.containerStatuses[*]}{.name}{" "}{.restartCount}{"\n"}{end}{end}') | ||
|
||
while read -r pod container restart_count; do | ||
if [ "${restart_counts[$pod-$container]--1}" != "$restart_count" ]; then | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this one is fine as it's a variable substitution, but ... (see below)