Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
[CI] Add AMI id to instance info on builds (#17649)
Browse files Browse the repository at this point in the history
  • Loading branch information
larroy authored Feb 25, 2020
1 parent 12d9191 commit b7c1c8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions ci/build_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def main():
logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(format='%(asctime)-15s %(message)s')
logging.info("MXNet Windows build helper")
instance_info = ec2_instance_info()
if instance_info:
logging.info("EC2: %s", instance_info)

parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output",
Expand Down
19 changes: 10 additions & 9 deletions ci/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,19 @@ def under_ci() -> bool:

def ec2_instance_info() -> str:
import requests
urls = [
"http://instance-data/latest/meta-data/instance-type",
"http://instance-data/latest/meta-data/instance-id",
"http://instance-data/latest/meta-data/public-hostname",
"http://instance-data/latest/meta-data/ami-id"
]
if under_ci():
result = []
try:
r = requests.get("http://instance-data/latest/meta-data/instance-type")
if r.status_code == 200:
result.append(r.content.decode())
r = requests.get("http://instance-data/latest/meta-data/instance-id")
if r.status_code == 200:
result.append(r.content.decode())
r = requests.get("http://instance-data/latest/meta-data/public-hostname")
if r.status_code == 200:
result.append(r.content.decode())
for url in urls:
r = requests.get(url)
if r.status_code == 200:
result.append(r.content.decode())
return ' '.join(result)
except ConnectionError:
pass
Expand Down

0 comments on commit b7c1c8d

Please sign in to comment.