зеркало из https://github.com/Azure/azurehpc.git
Merge pull request #274 from Azure/improved_error_reporting
Improved error reporting for failed deployment
This commit is contained in:
Коммит
d8c9c1ccdd
|
@ -387,11 +387,27 @@ def _wait_for_deployment(resource_group, deploy_name):
|
|||
for line in error_message[1:]:
|
||||
print(f" {line}")
|
||||
if "details" in props["statusMessage"]["error"]:
|
||||
details_code = props["statusMessage"]["error"]["details"].get("code", "")
|
||||
details_message = textwrap.TextWrapper(width=60).wrap(text=props["statusMessage"]["error"]["details"].get("message", ""))
|
||||
print(f" Details : {details_code}")
|
||||
for line in details_message:
|
||||
print(f" {line}")
|
||||
def pretty_print(d, indent=0):
|
||||
def wrapped_print(indent, text, max_width=80):
|
||||
lines = textwrap.TextWrapper(width=max_width-indent).wrap(text=text)
|
||||
for line in lines:
|
||||
print(" "*indent + line)
|
||||
if isinstance(d, list):
|
||||
for value in d:
|
||||
pretty_print(value, indent)
|
||||
elif isinstance(d, dict):
|
||||
for key, value in d.items():
|
||||
if isinstance(value, dict):
|
||||
wrapped_print(indent, str(key))
|
||||
pretty_print(value, indent+4)
|
||||
elif isinstance(value, list):
|
||||
wrapped_print(indent, str(key))
|
||||
pretty_print(value, indent+4)
|
||||
else:
|
||||
wrapped_print(indent, f"{key}: {value}")
|
||||
else:
|
||||
wrapped_print(indent, str(d))
|
||||
pretty_print(props["statusMessage"]["error"]["details"], 13)
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ def deploy(resource_group, arm_template):
|
|||
"--name", deployname,
|
||||
"--no-wait"
|
||||
]
|
||||
log.debug(" ".join(cmd))
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if res.returncode != 0:
|
||||
log.error("invalid returncode"+_make_subprocess_error_string(res))
|
||||
|
|
Загрузка…
Ссылка в новой задаче