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

Commit

Permalink
Build.py improvement (#16976)
Browse files Browse the repository at this point in the history
* Add instance type info to output

* Add repro cmd to success branch of build.py
  • Loading branch information
larroy authored and apeforest committed Jan 16, 2020
1 parent a296dad commit 57b98de
Show file tree
Hide file tree
Showing 3 changed files with 8 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
1 change: 1 addition & 0 deletions ci/safe_docker_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def run(self, *args, **kwargs) -> int:
logging.info("Executed command for reproduction:\n\n%s\n", " ".join(sys.argv))
else:
logging.info("Container exited with success 👍")
logging.info("Executed command for reproduction:\n\n%s\n", " ".join(sys.argv))
except Exception as err:
logging.exception(err)
return 150
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 57b98de

Please sign in to comment.