Skip to content

Commit c1a1430

Browse files
authored
[improvement] Harden quick e2e Linode API curl checks with polling (#1068)
* Harden e2e Linode API polling checks * Fix object storage test key lookup bug * Align object storage bucket region path
1 parent de4d44a commit c1a1430

14 files changed

Lines changed: 736 additions & 248 deletions

File tree

e2e/linodecluster-controller/firewall-integration/chainsaw-test.yaml

Lines changed: 103 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,31 @@ spec:
4545
value: (to_string({"label":($firewall)}))
4646
content: |
4747
set -e
48-
curl -s \
49-
-H "Authorization: Bearer $LINODE_TOKEN" \
50-
-H "X-Filter: $FILTER" \
51-
-H "Content-Type: application/json" \
52-
"https://api.linode.com/v4/networking/firewalls"
48+
MAX_RETRIES=12
49+
RETRY_DELAY=5
50+
ATTEMPT=1
51+
52+
while true; do
53+
RESPONSE=$(curl -s \
54+
-H "Authorization: Bearer $LINODE_TOKEN" \
55+
-H "X-Filter: $FILTER" \
56+
-H "Content-Type: application/json" \
57+
"https://api.linode.com/v4beta/networking/firewalls")
58+
59+
if echo "$RESPONSE" | jq -e '.results == 1' >/dev/null; then
60+
break
61+
fi
62+
63+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
64+
echo "$RESPONSE"
65+
exit 1
66+
fi
67+
68+
ATTEMPT=$((ATTEMPT + 1))
69+
sleep "$RETRY_DELAY"
70+
done
5371
check:
5472
($error): ~
55-
(json_parse($stdout)):
56-
results: 1
5773
- name: Create Cluster resource
5874
try:
5975
- apply:
@@ -88,35 +104,40 @@ spec:
88104
value: (to_string({"label":($firewall)}))
89105
content: |
90106
set -e
91-
92-
# Check if nodebalancer exists and get its ID
93-
NB_RESPONSE=$(curl -s \
94-
-H "Authorization: Bearer $LINODE_TOKEN" \
95-
-H "X-Filter: $FILTER" \
96-
-H "Content-Type: application/json" \
97-
"https://$TARGET_API/$TARGET_API_VERSION/$URI")
98-
99-
NB_COUNT=$(echo $NB_RESPONSE | jq '.results | length')
100-
if [ "$NB_COUNT" -ne 1 ]; then
101-
echo "Nodebalancer not found or multiple found"
102-
exit 1
103-
fi
104-
105-
NB_ID=$(echo $NB_RESPONSE | jq -r '.data[0].id')
106-
107-
# Check if firewall is configured for the nodebalancer
108-
FW_RESPONSE=$(curl -s \
109-
-H "Authorization: Bearer $LINODE_TOKEN" \
110-
-H "X-Filter: $FIREWALL_LABEL" \
111-
-H "Content-Type: application/json" \
112-
"https://$TARGET_API/$TARGET_API_VERSION/$URI/$NB_ID/firewalls")
113-
114-
FW_COUNT=$(echo $FW_RESPONSE | jq '.results')
115-
if [ "$FW_COUNT" -eq 0 ]; then
116-
echo "No firewall found for the nodebalancer"
117-
exit 1
118-
fi
119-
107+
MAX_RETRIES=12
108+
RETRY_DELAY=5
109+
ATTEMPT=1
110+
111+
while true; do
112+
NB_RESPONSE=$(curl -s \
113+
-H "Authorization: Bearer $LINODE_TOKEN" \
114+
-H "X-Filter: $FILTER" \
115+
-H "Content-Type: application/json" \
116+
"https://$TARGET_API/$TARGET_API_VERSION/$URI")
117+
118+
if echo "$NB_RESPONSE" | jq -e '.results == 1' >/dev/null; then
119+
NB_ID=$(echo "$NB_RESPONSE" | jq -r '.data[0].id')
120+
FW_RESPONSE=$(curl -s \
121+
-H "Authorization: Bearer $LINODE_TOKEN" \
122+
-H "X-Filter: $FIREWALL_LABEL" \
123+
-H "Content-Type: application/json" \
124+
"https://$TARGET_API/$TARGET_API_VERSION/$URI/$NB_ID/firewalls")
125+
126+
if echo "$FW_RESPONSE" | jq -e '.results > 0' >/dev/null; then
127+
break
128+
fi
129+
fi
130+
131+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
132+
echo "$NB_RESPONSE"
133+
echo "${FW_RESPONSE:-}"
134+
exit 1
135+
fi
136+
137+
ATTEMPT=$((ATTEMPT + 1))
138+
sleep "$RETRY_DELAY"
139+
done
140+
120141
echo "Nodebalancer exists and has the correct firewall configuration"
121142
exit 0
122143
check:
@@ -144,15 +165,31 @@ spec:
144165
value: (to_string({"label":($firewall)}))
145166
content: |
146167
set -e
147-
curl -s \
148-
-H "Authorization: Bearer $LINODE_TOKEN" \
149-
-H "X-Filter: $FILTER" \
150-
-H "Content-Type: application/json" \
151-
"https://api.linode.com/v4/networking/firewalls"
168+
MAX_RETRIES=12
169+
RETRY_DELAY=5
170+
ATTEMPT=1
171+
172+
while true; do
173+
RESPONSE=$(curl -s \
174+
-H "Authorization: Bearer $LINODE_TOKEN" \
175+
-H "X-Filter: $FILTER" \
176+
-H "Content-Type: application/json" \
177+
"https://api.linode.com/v4beta/networking/firewalls")
178+
179+
if echo "$RESPONSE" | jq -e '.results == 0' >/dev/null; then
180+
break
181+
fi
182+
183+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
184+
echo "$RESPONSE"
185+
exit 1
186+
fi
187+
188+
ATTEMPT=$((ATTEMPT + 1))
189+
sleep "$RETRY_DELAY"
190+
done
152191
check:
153192
($error): ~
154-
(json_parse($stdout)):
155-
results: 0
156193
- name: Check if the nodebalancer is deleted
157194
try:
158195
- script:
@@ -167,13 +204,29 @@ spec:
167204
value: (to_string({"label":($nodebalancer)}))
168205
content: |
169206
set -e
170-
curl -s \
171-
-H "Authorization: Bearer $LINODE_TOKEN" \
172-
-H "X-Filter: $FILTER" \
173-
-H "Content-Type: application/json" \
174-
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
207+
MAX_RETRIES=12
208+
RETRY_DELAY=5
209+
ATTEMPT=1
210+
211+
while true; do
212+
RESPONSE=$(curl -s \
213+
-H "Authorization: Bearer $LINODE_TOKEN" \
214+
-H "X-Filter: $FILTER" \
215+
-H "Content-Type: application/json" \
216+
"https://$TARGET_API/$TARGET_API_VERSION/$URI")
217+
218+
if echo "$RESPONSE" | jq -e '.results == 0' >/dev/null; then
219+
break
220+
fi
221+
222+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
223+
echo "$RESPONSE"
224+
exit 1
225+
fi
226+
227+
ATTEMPT=$((ATTEMPT + 1))
228+
sleep "$RETRY_DELAY"
229+
done
175230
check:
176231
($error): ~
177-
(json_parse($stdout)):
178-
results: 0
179232

e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,31 @@ spec:
5757
value: (to_string({"label":($nodebalancer)}))
5858
content: |
5959
set -e
60-
curl -s \
61-
-H "Authorization: Bearer $LINODE_TOKEN" \
62-
-H "X-Filter: $FILTER" \
63-
-H "Content-Type: application/json" \
64-
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
60+
MAX_RETRIES=12
61+
RETRY_DELAY=5
62+
ATTEMPT=1
63+
64+
while true; do
65+
RESPONSE=$(curl -s \
66+
-H "Authorization: Bearer $LINODE_TOKEN" \
67+
-H "X-Filter: $FILTER" \
68+
-H "Content-Type: application/json" \
69+
"https://$TARGET_API/$TARGET_API_VERSION/$URI")
70+
71+
if echo "$RESPONSE" | jq -e '.results == 1' >/dev/null; then
72+
break
73+
fi
74+
75+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
76+
echo "$RESPONSE"
77+
exit 1
78+
fi
79+
80+
ATTEMPT=$((ATTEMPT + 1))
81+
sleep "$RETRY_DELAY"
82+
done
6583
check:
6684
($error): ~
67-
(json_parse($stdout)):
68-
results: 1
6985
- name: Delete Cluster resource
7086
try:
7187
- delete:
@@ -89,12 +105,28 @@ spec:
89105
value: (to_string({"label":($nodebalancer)}))
90106
content: |
91107
set -e
92-
curl -s \
93-
-H "Authorization: Bearer $LINODE_TOKEN" \
94-
-H "X-Filter: $FILTER" \
95-
-H "Content-Type: application/json" \
96-
"https://$TARGET_API/$TARGET_API_VERSION/$URI"
108+
MAX_RETRIES=12
109+
RETRY_DELAY=5
110+
ATTEMPT=1
111+
112+
while true; do
113+
RESPONSE=$(curl -s \
114+
-H "Authorization: Bearer $LINODE_TOKEN" \
115+
-H "X-Filter: $FILTER" \
116+
-H "Content-Type: application/json" \
117+
"https://$TARGET_API/$TARGET_API_VERSION/$URI")
118+
119+
if echo "$RESPONSE" | jq -e '.results == 0' >/dev/null; then
120+
break
121+
fi
122+
123+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
124+
echo "$RESPONSE"
125+
exit 1
126+
fi
127+
128+
ATTEMPT=$((ATTEMPT + 1))
129+
sleep "$RETRY_DELAY"
130+
done
97131
check:
98132
($error): ~
99-
(json_parse($stdout)):
100-
results: 0

e2e/linodefirewall-controller/linodefirewall-addressset/chainsaw-test.yaml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,31 @@ spec:
4646
value: (to_string({"label":($firewall)}))
4747
content: |
4848
set -e
49-
curl -s \
50-
-H "Authorization: Bearer $LINODE_TOKEN" \
51-
-H "X-Filter: $FILTER" \
52-
-H "Content-Type: application/json" \
53-
"https://api.linode.com/v4/networking/firewalls"
49+
MAX_RETRIES=12
50+
RETRY_DELAY=5
51+
ATTEMPT=1
52+
53+
while true; do
54+
RESPONSE=$(curl -s \
55+
-H "Authorization: Bearer $LINODE_TOKEN" \
56+
-H "X-Filter: $FILTER" \
57+
-H "Content-Type: application/json" \
58+
"https://api.linode.com/v4beta/networking/firewalls")
59+
60+
if echo "$RESPONSE" | jq -e '.results == 1' >/dev/null; then
61+
break
62+
fi
63+
64+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
65+
echo "$RESPONSE"
66+
exit 1
67+
fi
68+
69+
ATTEMPT=$((ATTEMPT + 1))
70+
sleep "$RETRY_DELAY"
71+
done
5472
check:
5573
($error): ~
56-
(json_parse($stdout)):
57-
results: 1
5874
- name: Delete Firewall and AddressSet
5975
try:
6076
- delete:
@@ -77,12 +93,28 @@ spec:
7793
value: (to_string({"label":($firewall)}))
7894
content: |
7995
set -e
80-
curl -s \
81-
-H "Authorization: Bearer $LINODE_TOKEN" \
82-
-H "X-Filter: $FILTER" \
83-
-H "Content-Type: application/json" \
84-
"https://api.linode.com/v4/networking/firewalls"
96+
MAX_RETRIES=12
97+
RETRY_DELAY=5
98+
ATTEMPT=1
99+
100+
while true; do
101+
RESPONSE=$(curl -s \
102+
-H "Authorization: Bearer $LINODE_TOKEN" \
103+
-H "X-Filter: $FILTER" \
104+
-H "Content-Type: application/json" \
105+
"https://api.linode.com/v4beta/networking/firewalls")
106+
107+
if echo "$RESPONSE" | jq -e '.results == 0' >/dev/null; then
108+
break
109+
fi
110+
111+
if [ "$ATTEMPT" -ge "$MAX_RETRIES" ]; then
112+
echo "$RESPONSE"
113+
exit 1
114+
fi
115+
116+
ATTEMPT=$((ATTEMPT + 1))
117+
sleep "$RETRY_DELAY"
118+
done
85119
check:
86120
($error): ~
87-
(json_parse($stdout)):
88-
results: 0

0 commit comments

Comments
 (0)