Skip to content

Commit 2befa52

Browse files
committed
Drop dependency on requests library in send_build_notification.py
This is required because of: https://aws.amazon.com/blogs/developer/removing-the-vendored-version-of-requests-from-botocore/ Signed-off-by: Francesco De Martino <[email protected]>
1 parent 2acc368 commit 2befa52

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

cli/pcluster/resources/batch/custom_resources_code/send_build_notification.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
# limitations under the License.
1111
import json
1212
import os
13-
14-
from botocore.vendored import requests
13+
import time
14+
from http.client import HTTPSConnection
15+
from urllib.parse import urlsplit, urlunsplit
1516

1617

1718
def handler(event, context):
@@ -29,4 +30,19 @@ def handler(event, context):
2930
)
3031
print("Notification URL: %s" % notification_url)
3132
print("Notification data: %s" % data)
32-
requests.put(notification_url, data=data, headers={"Content-Type": ""})
33+
34+
split_url = urlsplit(notification_url)
35+
host = split_url.netloc
36+
url = urlunsplit(("", "", *split_url[2:]))
37+
while True:
38+
try:
39+
connection = HTTPSConnection(host)
40+
connection.request(
41+
method="PUT", url=url, body=data, headers={"Content-Type": "", "content-length": str(len(data))}
42+
)
43+
response = connection.getresponse()
44+
print("CloudFormation returned status code: {}".format(response.reason))
45+
break
46+
except Exception as e:
47+
print("Unexpected failure sending response to CloudFormation {}".format(e), exc_info=True)
48+
time.sleep(5)

0 commit comments

Comments
 (0)