Skip to content

Commit 3d52612

Browse files
committed
remove Linux 2 compatibility code
1 parent f7d9c0b commit 3d52612

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

config/plugin/spot_termination.sh

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,13 @@ OK=0
44
NONOK=1
55
UNKNOWN=2
66

7-
# Try to get IMDSv2 token (for AL2023)
87
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" \
98
-H "X-aws-ec2-metadata-token-ttl-seconds: 21600" \
109
--max-time 3 --silent --fail 2>/dev/null)
1110

12-
# Check spot termination notice
13-
if [ -n "$TOKEN" ]; then
14-
# Use IMDSv2 if token was obtained (AL2023)
15-
status_code=$(curl --max-time 3 --silent --output /dev/stderr --write-out "%{http_code}" \
16-
-H "X-aws-ec2-metadata-token: $TOKEN" \
17-
"http://169.254.169.254/latest/meta-data/spot/instance-action")
18-
else
19-
# Fall back to IMDSv1 (Linux 2)
20-
status_code=$(curl --max-time 3 --silent --output /dev/stderr --write-out "%{http_code}" \
21-
"http://169.254.169.254/latest/meta-data/spot/instance-action")
22-
fi
11+
status_code=$(curl --max-time 3 --silent --output /dev/stderr --write-out "%{http_code}" \
12+
-H "X-aws-ec2-metadata-token: $TOKEN" \
13+
"http://169.254.169.254/latest/meta-data/spot/instance-action")
2314

2415
if [ "${status_code}" -eq "404" ]; then
2516
exit $OK

0 commit comments

Comments
 (0)