awslabs / ec2-spot-labs

Collection of tools and code examples to demonstrate best practices in using Amazon EC2 Spot Instances.
https://aws.amazon.com/ec2/spot/
Other
942 stars 319 forks source link

Breaking change in "spot-instance-termination-notice-handler" due to curl version #54

Open TheRealGoku opened 3 years ago

TheRealGoku commented 3 years ago

https://github.com/awslabs/ec2-spot-labs/blob/master/ecs-ec2-spot-fleet/ecs-ec2-spot-fleet.yaml#L442

[ec2-user@ip-172-31-7-218 ~]$ curl --version
curl 7.61.1 (x86_64-koji-linux-gnu) libcurl/7.61.1 OpenSSL/1.0.2k zlib/1.2.7 libidn2/2.3.0 libssh2/1.4.3 nghttp2/1.41.0
Release-Date: 2018-09-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy Metalink 
[ec2-user@ip-172-31-7-218 ~]$ [ -z $(curl -Isf http://169.254.169.254/latest/meta-data/spot/termination-time) ];
[ec2-user@ip-172-31-7-218 ~]$ 
[ec2-user@ip-172-31-7-218 ~]$ curl --version
curl 7.76.1 (x86_64-koji-linux-gnu) libcurl/7.76.1 OpenSSL/1.0.2k-fips zlib/1.2.7 libidn2/2.3.0 libssh2/1.4.3 nghttp2/1.41.0
Release-Date: 2021-04-14
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB SPNEGO SSL UnixSockets
[ec2-user@ip-172-31-7-218 ~]$ [ -z $(curl -Isf http://169.254.169.254/latest/meta-data/spot/termination-time) ];
-bash: [: too many arguments

If customer uses spot-instance-termination-notice-handler.sh script in their environment due the change curl version output format, the code will always execute else statement and thereby will keep all the on boarded registered container instances into draining state for lifetime despite whether the instance is on demand or spot

ruecarlo commented 3 years ago

You are completely right @TheRealGoku, this was a while back the way to add the Spot interruption notification handler. Things have changed. A while back ago (about 2 years ago) we added the right handling mechanism into the ECS-Optimized AMI image. Now just by adding the ECS_ENABLE_SPOT_INSTANCE_DRAINING variable and setting it to true as documented here you should be able to get the right design.

We will update and remove this entry. I'll close the issue once that this old example gets removed.

TheRealGoku commented 3 years ago

Thats true :)