Skip to content

Commit e5705ff

Browse files
authored
clear up shellcheck warnings (#242)
* clear up shellcheck warnings * changes based on PR feedback * missed some spots
1 parent ef0eec0 commit e5705ff

25 files changed

+321
-257
lines changed

scripts/push-docker-images

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,21 @@ if [[ $MANIFEST == "true" ]]; then
6060
echo '{"experimental":"enabled"}' > $DOCKER_CLI_CONFIG
6161
echo "Created docker config file"
6262
fi
63-
cat <<< $(jq '.+{"experimental":"enabled"}' $DOCKER_CLI_CONFIG) > $DOCKER_CLI_CONFIG
63+
cat <<< "$(jq '.+{"experimental":"enabled"}' $DOCKER_CLI_CONFIG)" > $DOCKER_CLI_CONFIG
6464
echo "Enabled experimental CLI features to execute docker manifest commands"
6565
manifest_exists=$(docker manifest inspect $IMAGE_REPO:$VERSION > /dev/null ; echo $?)
6666
if [[ manifest_exists -eq 0 ]]; then
6767
echo "manifest already exists"
68-
EXISTING_IMAGES=($(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | "\(.platform.os)-\(.platform.architecture)"'))
68+
EXISTING_IMAGES=()
69+
while IFS='' read -r line; do
70+
EXISTING_IMAGES+=("$line");
71+
done < <(docker manifest inspect $IMAGE_REPO:$VERSION | jq -r '.manifests[] | "\(.platform.os)-\(.platform.architecture)"')
6972
# treat separate from PLATFORMS because existing images don't need to be tagged and pushed
7073
for os_arch in "${EXISTING_IMAGES[@]}"; do
7174
img_tag="$IMAGE_REPO:$VERSION-$os_arch"
72-
MANIFEST_IMAGES+=($img_tag)
75+
MANIFEST_IMAGES+=("$img_tag")
7376
done
74-
echo "images already in manifest: $MANIFEST_IMAGES"
77+
echo "images already in manifest: ${MANIFEST_IMAGES[*]}"
7578
fi
7679
fi
7780

@@ -88,7 +91,7 @@ for os_arch in "${PLATFORMS[@]}"; do
8891
docker tag $img_tag_w_platform $img_tag
8992
fi
9093
docker push $img_tag
91-
MANIFEST_IMAGES+=($img_tag)
94+
MANIFEST_IMAGES+=("$img_tag")
9295
done
9396

9497
if [[ $MANIFEST == "true" ]]; then

scripts/upload-resources-to-github

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ handle_errors_and_cleanup() {
5050

5151
if [[ ${#ASSET_IDS_UPLOADED[@]} -ne 0 ]]; then
5252
echo -e "\nCleaning up assets uploaded in the current execution of the script"
53-
for asset_id in $ASSET_IDS_UPLOADED; do
53+
for asset_id in "${ASSET_IDS_UPLOADED[@]}"; do
5454
echo "Deleting asset $asset_id"
5555
curl -X DELETE \
5656
-H "Authorization: token $GITHUB_TOKEN" \
@@ -63,17 +63,17 @@ handle_errors_and_cleanup() {
6363
gather_assets_to_upload() {
6464
local resources=()
6565
for binary in $BINARY_DIR/*; do
66-
resources+=($binary)
66+
resources+=("$binary")
6767
done
6868
if [ $BINARIES_ONLY != "true" ]; then
69-
resources+=($INDV_K8S_RESOURCES $AGG_RESOURCES_YAML)
69+
resources+=("$INDV_K8S_RESOURCES" "$AGG_RESOURCES_YAML")
7070
fi
7171
echo "${resources[@]}"
7272
}
7373

7474
# $1: absolute path to asset
7575
upload_asset() {
76-
resp=$(curl --write-out %{http_code} --silent \
76+
resp=$(curl --write-out '%{http_code}' --silent \
7777
-H "Authorization: token $GITHUB_TOKEN" \
7878
-H "Content-Type: $(file -b --mime-type $1)" \
7979
--data-binary @$1 \
@@ -85,7 +85,7 @@ upload_asset() {
8585
# HTTP success code expected - 201 Created
8686
if [[ $response_code -eq 201 ]]; then
8787
asset_id=$(echo $response_content | jq '.id')
88-
ASSET_IDS_UPLOADED+=($asset_id)
88+
ASSET_IDS_UPLOADED+=("$asset_id")
8989
echo "Created asset ID $asset_id successfully"
9090
else
9191
echo -e "❌ Upload failed with response code $response_code and message \n$response_content"

test/e2e/cordon-only-test

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ common_helm_args=()
2828
anth_helm_args=(
2929
upgrade
3030
--install
31-
$CLUSTER_NAME-anth
32-
$SCRIPTPATH/../../config/helm/aws-node-termination-handler/
31+
"$CLUSTER_NAME-anth"
32+
"$SCRIPTPATH/../../config/helm/aws-node-termination-handler/"
3333
--namespace kube-system
34-
--set instanceMetadataURL=${INSTANCE_METADATA_URL:-"http://$AEMM_URL:$IMDS_PORT"}
34+
--set instanceMetadataURL="${INSTANCE_METADATA_URL:-"http://$AEMM_URL:$IMDS_PORT"}"
3535
--set image.repository="$NODE_TERMINATION_HANDLER_DOCKER_REPO"
3636
--set image.tag="$NODE_TERMINATION_HANDLER_DOCKER_TAG"
3737
--set cordonOnly="true"
@@ -48,8 +48,8 @@ set +x
4848
aemm_helm_args=(
4949
upgrade
5050
--install
51-
$CLUSTER_NAME-aemm
52-
$AEMM_DL_URL
51+
"$CLUSTER_NAME-aemm"
52+
"$AEMM_DL_URL"
5353
--namespace default
5454
--set servicePort="$IMDS_PORT"
5555
)
@@ -63,8 +63,8 @@ set +x
6363
emtp_helm_args=(
6464
upgrade
6565
--install
66-
$CLUSTER_NAME-emtp
67-
$SCRIPTPATH/../../config/helm/webhook-test-proxy/
66+
"$CLUSTER_NAME-emtp"
67+
"$SCRIPTPATH/../../config/helm/webhook-test-proxy/"
6868
--namespace default
6969
--set webhookTestProxy.image.repository="$WEBHOOK_DOCKER_REPO"
7070
--set webhookTestProxy.image.tag="$WEBHOOK_DOCKER_TAG"
@@ -83,13 +83,14 @@ TAINT_CHECK_SLEEP=15
8383

8484
DEPLOYED=0
8585

86-
for i in `seq 1 10`; do
86+
for i in `seq 1 $TAINT_CHECK_CYCLES`; do
8787
if [[ $(kubectl get deployments regular-pod-test -o jsonpath='{.status.unavailableReplicas}') -eq 0 ]]; then
8888
echo "✅ Verified regular-pod-test pod was scheduled and started!"
8989
DEPLOYED=1
9090
break
9191
fi
92-
sleep 5
92+
echo "Setup Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
93+
sleep $TAINT_CHECK_SLEEP
9394
done
9495

9596
if [[ $DEPLOYED -eq 0 ]]; then
@@ -98,18 +99,19 @@ if [[ $DEPLOYED -eq 0 ]]; then
9899
fi
99100

100101
cordoned=0
101-
test_node=${TEST_NODE:-$CLUSTER_NAME-worker}
102+
test_node="${TEST_NODE:-$CLUSTER_NAME-worker}"
102103
for i in `seq 1 $TAINT_CHECK_CYCLES`; do
103-
if [[ $cordoned -eq 0 ]] && kubectl get nodes $test_node | grep SchedulingDisabled > /dev/null; then
104-
echo "✅ Verified the worker node was cordoned!"
105-
cordoned=1
106-
fi
107-
108-
if [[ $cordoned -eq 1 && $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 0 ]]; then
109-
echo "✅ Verified the regular-pod-test pod was NOT evicted!"
110-
echo "✅ Cordon Only Test Passed $CLUSTER_NAME! ✅"
111-
exit 0
112-
fi
104+
if [[ $cordoned -eq 0 ]] && kubectl get nodes $test_node | grep SchedulingDisabled > /dev/null; then
105+
echo "✅ Verified the worker node was cordoned!"
106+
cordoned=1
107+
fi
108+
109+
if [[ $cordoned -eq 1 && $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 0 ]]; then
110+
echo "✅ Verified the regular-pod-test pod was NOT evicted!"
111+
echo "✅ Cordon Only Test Passed $CLUSTER_NAME! ✅"
112+
exit 0
113+
fi
114+
echo "Assertion Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
113115
sleep $TAINT_CHECK_SLEEP
114116
done
115117

test/e2e/imds-v2-test

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ common_helm_args=()
2828
anth_helm_args=(
2929
upgrade
3030
--install
31-
$CLUSTER_NAME-anth
32-
$SCRIPTPATH/../../config/helm/aws-node-termination-handler/
31+
"$CLUSTER_NAME-anth"
32+
"$SCRIPTPATH/../../config/helm/aws-node-termination-handler/"
3333
--force
3434
--namespace kube-system
35-
--set instanceMetadataURL=${INSTANCE_METADATA_URL:-"http://$AEMM_URL:$IMDS_PORT"}
35+
--set instanceMetadataURL="${INSTANCE_METADATA_URL:-"http://$AEMM_URL:$IMDS_PORT"}"
3636
--set image.repository="$NODE_TERMINATION_HANDLER_DOCKER_REPO"
3737
--set image.tag="$NODE_TERMINATION_HANDLER_DOCKER_TAG"
3838
--set enableSpotInterruptionDraining="true"
@@ -50,8 +50,8 @@ set +x
5050
emtp_helm_args=(
5151
upgrade
5252
--install
53-
$CLUSTER_NAME-emtp
54-
$SCRIPTPATH/../../config/helm/webhook-test-proxy/
53+
"$CLUSTER_NAME-emtp"
54+
"$SCRIPTPATH/../../config/helm/webhook-test-proxy/"
5555
--wait
5656
--namespace default
5757
--set webhookTestProxy.image.repository="$WEBHOOK_DOCKER_REPO"
@@ -69,8 +69,8 @@ set +x
6969
aemm_helm_args=(
7070
upgrade
7171
--install
72-
$CLUSTER_NAME-aemm
73-
$AEMM_DL_URL
72+
"$CLUSTER_NAME-aemm"
73+
"$AEMM_DL_URL"
7474
--wait
7575
--namespace default
7676
--set aemm.imdsv2="true"
@@ -88,13 +88,14 @@ TAINT_CHECK_SLEEP=15
8888

8989
DEPLOYED=0
9090

91-
for i in `seq 1 10`; do
91+
for i in `seq 1 $TAINT_CHECK_CYCLES`; do
9292
if [[ $(kubectl get deployments regular-pod-test -o jsonpath='{.status.unavailableReplicas}') -eq 0 ]]; then
9393
echo "✅ Verified regular-pod-test pod was scheduled and started!"
9494
DEPLOYED=1
9595
break
9696
fi
97-
sleep 5
97+
echo "Setup Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
98+
sleep $TAINT_CHECK_SLEEP
9899
done
99100

100101
if [[ $DEPLOYED -eq 0 ]]; then
@@ -103,18 +104,19 @@ if [[ $DEPLOYED -eq 0 ]]; then
103104
fi
104105

105106
cordoned=0
106-
test_node=${TEST_NODE:-$CLUSTER_NAME-worker}
107+
test_node="${TEST_NODE:-$CLUSTER_NAME-worker}"
107108
for i in `seq 1 $TAINT_CHECK_CYCLES`; do
108-
if [[ $cordoned -eq 0 ]] && kubectl get nodes $test_node | grep SchedulingDisabled >/dev/null; then
109-
echo "✅ Verified the worker node was cordoned!"
110-
cordoned=1
111-
fi
112-
113-
if [[ $cordoned -eq 1 && $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 1 ]]; then
114-
echo "✅ Verified the regular-pod-test pod was evicted!"
115-
echo "✅ IMDSv2 Test Passed $CLUSTER_NAME! ✅"
116-
exit 0
117-
fi
109+
if [[ $cordoned -eq 0 ]] && kubectl get nodes $test_node | grep SchedulingDisabled >/dev/null; then
110+
echo "✅ Verified the worker node was cordoned!"
111+
cordoned=1
112+
fi
113+
114+
if [[ $cordoned -eq 1 && $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 1 ]]; then
115+
echo "✅ Verified the regular-pod-test pod was evicted!"
116+
echo "✅ IMDSv2 Test Passed $CLUSTER_NAME! ✅"
117+
exit 0
118+
fi
119+
echo "Assertion Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
118120
sleep $TAINT_CHECK_SLEEP
119121
done
120122

test/e2e/maintenance-event-cancellation-test

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ common_helm_args=()
2828
anth_helm_args=(
2929
upgrade
3030
--install
31-
$CLUSTER_NAME-anth
32-
$SCRIPTPATH/../../config/helm/aws-node-termination-handler/
31+
"$CLUSTER_NAME-anth"
32+
"$SCRIPTPATH/../../config/helm/aws-node-termination-handler/"
3333
--wait
3434
--namespace kube-system
35-
--set instanceMetadataURL=${INSTANCE_METADATA_URL:-"http://$AEMM_URL:$IMDS_PORT"}
35+
--set instanceMetadataURL="${INSTANCE_METADATA_URL:-"http://$AEMM_URL:$IMDS_PORT"}"
3636
--set image.repository="$NODE_TERMINATION_HANDLER_DOCKER_REPO"
3737
--set image.tag="$NODE_TERMINATION_HANDLER_DOCKER_TAG"
3838
--set enableSpotInterruptionDraining="true"
@@ -52,8 +52,8 @@ set +x
5252
emtp_helm_args=(
5353
upgrade
5454
--install
55-
$CLUSTER_NAME-emtp
56-
$SCRIPTPATH/../../config/helm/webhook-test-proxy/
55+
"$CLUSTER_NAME-emtp"
56+
"$SCRIPTPATH/../../config/helm/webhook-test-proxy/"
5757
--wait
5858
--namespace default
5959
--set webhookTestProxy.image.repository="$WEBHOOK_DOCKER_REPO"
@@ -71,14 +71,14 @@ set +x
7171
aemm_helm_args=(
7272
upgrade
7373
--install
74-
$CLUSTER_NAME-aemm
75-
$AEMM_DL_URL
74+
"$CLUSTER_NAME-aemm"
75+
"$AEMM_DL_URL"
7676
--wait
7777
--namespace default
7878
--set servicePort="$IMDS_PORT"
7979
--set 'tolerations[0].effect=NoSchedule'
8080
--set 'tolerations[0].operator=Exists'
81-
--set arguments={events}
81+
--set arguments='{events}'
8282
)
8383
[[ ${#common_helm_args[@]} -gt 0 ]] &&
8484
aemm_helm_args+=("${common_helm_args[@]}")
@@ -92,13 +92,14 @@ TAINT_CHECK_SLEEP=15
9292

9393
DEPLOYED=0
9494

95-
for i in `seq 1 10`; do
95+
for i in `seq 1 $TAINT_CHECK_CYCLES`; do
9696
if [[ $(kubectl get deployments regular-pod-test -o jsonpath='{.status.unavailableReplicas}') -eq 0 ]]; then
9797
echo "✅ Verified regular-pod-test pod was scheduled and started!"
9898
DEPLOYED=1
9999
break
100100
fi
101-
sleep 5
101+
echo "Setup Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
102+
sleep $TAINT_CHECK_SLEEP
102103
done
103104

104105
if [[ $DEPLOYED -eq 0 ]]; then
@@ -109,7 +110,7 @@ fi
109110
cordoned=0
110111
tainted=0
111112
evicted=0
112-
test_node=${TEST_NODE:-$CLUSTER_NAME-worker}
113+
test_node="${TEST_NODE:-$CLUSTER_NAME-worker}"
113114
for i in `seq 1 $TAINT_CHECK_CYCLES`; do
114115
if [[ $cordoned -eq 0 ]] && kubectl get nodes $test_node --no-headers | grep SchedulingDisabled >/dev/null; then
115116
echo "✅ Verified the worker node was cordoned!"
@@ -126,6 +127,7 @@ for i in `seq 1 $TAINT_CHECK_CYCLES`; do
126127
evicted=1
127128
break
128129
fi
130+
echo "Assertion Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
129131
sleep $TAINT_CHECK_SLEEP
130132
done
131133

@@ -143,15 +145,15 @@ fi
143145
aemm_helm_args=(
144146
upgrade
145147
--install
146-
$CLUSTER_NAME-aemm
147-
$AEMM_DL_URL
148+
"$CLUSTER_NAME-aemm"
149+
"$AEMM_DL_URL"
148150
--wait
149151
--namespace default
150152
--set servicePort="$IMDS_PORT"
151153
--set aemm.events.state="canceled"
152154
--set 'tolerations[0].effect=NoSchedule'
153155
--set 'tolerations[0].operator=Exists'
154-
--set arguments={events}
156+
--set arguments='{events}'
155157
)
156158
[[ ${#common_helm_args[@]} -gt 0 ]] &&
157159
aemm_helm_args+=("${common_helm_args[@]}")
@@ -163,8 +165,8 @@ set +x
163165
emtp_helm_args=(
164166
upgrade
165167
--install
166-
$CLUSTER_NAME-emtp
167-
$SCRIPTPATH/../../config/helm/webhook-test-proxy/
168+
"$CLUSTER_NAME-emtp"
169+
"$SCRIPTPATH/../../config/helm/webhook-test-proxy/"
168170
--wait
169171
--namespace default
170172
--set webhookTestProxy.image.repository="$WEBHOOK_DOCKER_REPO"
@@ -189,6 +191,7 @@ for i in `seq 1 $TAINT_CHECK_CYCLES`; do
189191
echo "✅ Test Maintenance Event Cancellation passed! $CLUSTER_NAME"
190192
exit 0
191193
fi
194+
echo "Assertion Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
192195
sleep $TAINT_CHECK_SLEEP
193196
done
194197

0 commit comments

Comments
 (0)