Skip to content

Commit 6048f87

Browse files
fix: handle curl exit code 000 in validate-kubelet-credentials.sh (#6201)
Co-authored-by: Cameron Meissner <cameronmeissner@gmail.com>
1 parent c3814e4 commit 6048f87

File tree

272 files changed

+2092
-271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

272 files changed

+2092
-271
lines changed

parts/linux/cloud-init/artifacts/cse_config.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,8 @@ EOF
662662
logs_to_events "AKS.CSE.ensureKubelet.installCredentialProvider" installCredentialProvider
663663
fi
664664

665-
systemctlEnableAndStart kubelet 30 || exit $ERR_KUBELET_START_FAIL
665+
# 4-minute timeout to give enough time to all of kubelet's ExecStartPre scripts before hitting their own respective timeouts
666+
systemctlEnableAndStart kubelet 240 || exit $ERR_KUBELET_START_FAIL
666667
}
667668

668669
ensureSnapshotUpdate() {

parts/linux/cloud-init/artifacts/validate-kubelet-credentials.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function validateBootstrapKubeconfig {
6060
exit 0
6161
fi
6262

63+
echo "will check credential validity against apiserver url: $apiserver_url"
64+
6365
local retry_count=0
6466
while true; do
6567
code=$(curl -sL \
@@ -71,16 +73,34 @@ function validateBootstrapKubeconfig {
7173
--cacert "$cacert" \
7274
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s")
7375

76+
curl_code=$?
77+
7478
if [ $code -ge 200 ] && [ $code -lt 400 ]; then
7579
echo "(retry=$retry_count) received valid HTTP status code from apiserver: $code"
7680
break
7781
fi
7882

83+
if [ $code -eq 000 ]; then
84+
echo "(retry=$retry_count) curl response code is $code, curl exited with code: $curl_code"
85+
echo "retrying once more to get a more detailed error response..."
86+
87+
curl -L \
88+
-m $RETRY_TIMEOUT_SECONDS \
89+
-H "Accept: application/json, */*" \
90+
-H "Authorization: Bearer ${bootstrap_token//\"/}" \
91+
--cacert "$cacert" \
92+
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s"
93+
94+
echo "proceeding to start kubelet..."
95+
exit 0
96+
fi
97+
7998
echo "(retry=$retry_count) received invalid HTTP status code from apiserver: $code"
8099

81100
retry_count=$(( $retry_count + 1 ))
82101
if [ $retry_count -eq $MAX_RETRIES ]; then
83102
echo "unable to validate bootstrap credentials after $retry_count attempts"
103+
echo "proceeding to start kubelet..."
84104
exit 0
85105
fi
86106

pkg/agent/testdata/AKSUbuntu1604+Containerd/CustomData

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu1604+Containerd/line315.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ function validateBootstrapKubeconfig {
5757
exit 0
5858
fi
5959

60+
echo "will check credential validity against apiserver url: $apiserver_url"
61+
6062
local retry_count=0
6163
while true; do
6264
code=$(curl -sL \
@@ -68,16 +70,34 @@ function validateBootstrapKubeconfig {
6870
--cacert "$cacert" \
6971
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s")
7072

73+
curl_code=$?
74+
7175
if [ $code -ge 200 ] && [ $code -lt 400 ]; then
7276
echo "(retry=$retry_count) received valid HTTP status code from apiserver: $code"
7377
break
7478
fi
7579

80+
if [ $code -eq 000 ]; then
81+
echo "(retry=$retry_count) curl response code is $code, curl exited with code: $curl_code"
82+
echo "retrying once more to get a more detailed error response..."
83+
84+
curl -L \
85+
-m $RETRY_TIMEOUT_SECONDS \
86+
-H "Accept: application/json, */*" \
87+
-H "Authorization: Bearer ${bootstrap_token//\"/}" \
88+
--cacert "$cacert" \
89+
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s"
90+
91+
echo "proceeding to start kubelet..."
92+
exit 0
93+
fi
94+
7695
echo "(retry=$retry_count) received invalid HTTP status code from apiserver: $code"
7796

7897
retry_count=$(( $retry_count + 1 ))
7998
if [ $retry_count -eq $MAX_RETRIES ]; then
8099
echo "unable to validate bootstrap credentials after $retry_count attempts"
100+
echo "proceeding to start kubelet..."
81101
exit 0
82102
fi
83103

pkg/agent/testdata/AKSUbuntu1604+Containerd/line70.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ EOF
627627
logs_to_events "AKS.CSE.ensureKubelet.installCredentialProvider" installCredentialProvider
628628
fi
629629

630-
systemctlEnableAndStart kubelet 30 || exit $ERR_KUBELET_START_FAIL
630+
systemctlEnableAndStart kubelet 240 || exit $ERR_KUBELET_START_FAIL
631631
}
632632

633633
ensureSnapshotUpdate() {

pkg/agent/testdata/AKSUbuntu1604+CustomKubeletConfig+CustomLinuxOSConfig/CustomData

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu1604+CustomKubeletConfig+CustomLinuxOSConfig/line315.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ function validateBootstrapKubeconfig {
5757
exit 0
5858
fi
5959

60+
echo "will check credential validity against apiserver url: $apiserver_url"
61+
6062
local retry_count=0
6163
while true; do
6264
code=$(curl -sL \
@@ -68,16 +70,34 @@ function validateBootstrapKubeconfig {
6870
--cacert "$cacert" \
6971
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s")
7072

73+
curl_code=$?
74+
7175
if [ $code -ge 200 ] && [ $code -lt 400 ]; then
7276
echo "(retry=$retry_count) received valid HTTP status code from apiserver: $code"
7377
break
7478
fi
7579

80+
if [ $code -eq 000 ]; then
81+
echo "(retry=$retry_count) curl response code is $code, curl exited with code: $curl_code"
82+
echo "retrying once more to get a more detailed error response..."
83+
84+
curl -L \
85+
-m $RETRY_TIMEOUT_SECONDS \
86+
-H "Accept: application/json, */*" \
87+
-H "Authorization: Bearer ${bootstrap_token//\"/}" \
88+
--cacert "$cacert" \
89+
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s"
90+
91+
echo "proceeding to start kubelet..."
92+
exit 0
93+
fi
94+
7695
echo "(retry=$retry_count) received invalid HTTP status code from apiserver: $code"
7796

7897
retry_count=$(( $retry_count + 1 ))
7998
if [ $retry_count -eq $MAX_RETRIES ]; then
8099
echo "unable to validate bootstrap credentials after $retry_count attempts"
100+
echo "proceeding to start kubelet..."
81101
exit 0
82102
fi
83103

pkg/agent/testdata/AKSUbuntu1604+CustomKubeletConfig+CustomLinuxOSConfig/line70.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ EOF
627627
logs_to_events "AKS.CSE.ensureKubelet.installCredentialProvider" installCredentialProvider
628628
fi
629629

630-
systemctlEnableAndStart kubelet 30 || exit $ERR_KUBELET_START_FAIL
630+
systemctlEnableAndStart kubelet 240 || exit $ERR_KUBELET_START_FAIL
631631
}
632632

633633
ensureSnapshotUpdate() {

pkg/agent/testdata/AKSUbuntu1604+CustomKubeletConfig+DynamicKubeletConfig/CustomData

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSUbuntu1604+CustomKubeletConfig+DynamicKubeletConfig/line315.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ function validateBootstrapKubeconfig {
5757
exit 0
5858
fi
5959

60+
echo "will check credential validity against apiserver url: $apiserver_url"
61+
6062
local retry_count=0
6163
while true; do
6264
code=$(curl -sL \
@@ -68,16 +70,34 @@ function validateBootstrapKubeconfig {
6870
--cacert "$cacert" \
6971
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s")
7072

73+
curl_code=$?
74+
7175
if [ $code -ge 200 ] && [ $code -lt 400 ]; then
7276
echo "(retry=$retry_count) received valid HTTP status code from apiserver: $code"
7377
break
7478
fi
7579

80+
if [ $code -eq 000 ]; then
81+
echo "(retry=$retry_count) curl response code is $code, curl exited with code: $curl_code"
82+
echo "retrying once more to get a more detailed error response..."
83+
84+
curl -L \
85+
-m $RETRY_TIMEOUT_SECONDS \
86+
-H "Accept: application/json, */*" \
87+
-H "Authorization: Bearer ${bootstrap_token//\"/}" \
88+
--cacert "$cacert" \
89+
"${apiserver_url}/version?timeout=${RETRY_TIMEOUT_SECONDS}s"
90+
91+
echo "proceeding to start kubelet..."
92+
exit 0
93+
fi
94+
7695
echo "(retry=$retry_count) received invalid HTTP status code from apiserver: $code"
7796

7897
retry_count=$(( $retry_count + 1 ))
7998
if [ $retry_count -eq $MAX_RETRIES ]; then
8099
echo "unable to validate bootstrap credentials after $retry_count attempts"
100+
echo "proceeding to start kubelet..."
81101
exit 0
82102
fi
83103

0 commit comments

Comments
 (0)