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

Commit

Permalink
Add instance type info to output
Browse files Browse the repository at this point in the history
  • Loading branch information
larroy committed Dec 26, 2019
1 parent 1fc2cd0 commit 1a12609
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ci/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ def load_docker_cache(tag, docker_registry) -> None:


def log_environment():
instance_id = ec2_instance_id_hostname()
if instance_id:
logging.info("EC2 Instance id: %s", instance_id)
instance_info = ec2_instance_info()
if instance_info:
logging.info("EC2: %s", instance_info)
pp = pprint.PrettyPrinter(indent=4)
logging.debug("Build environment: %s", pp.pformat(dict(os.environ)))

Expand Down
5 changes: 4 additions & 1 deletion ci/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,14 @@ def under_ci() -> bool:
return 'JOB_NAME' in os.environ


def ec2_instance_id_hostname() -> str:
def ec2_instance_info() -> str:
import requests
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())
Expand Down

0 comments on commit 1a12609

Please sign in to comment.