Fail if traceroute doesn't work

If neither traceroute works, this is a host with broken networking and
doing anything else is a waste of time.

Change-Id: I042357c2d55596296ce2d570aa54433195a31b82
This commit is contained in:
Monty Taylor 2017-07-09 10:20:11 -05:00
parent 8b86f76ffd
commit 869d7f5744
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
2 changed files with 27 additions and 12 deletions

View File

@ -53,21 +53,29 @@ def main():
if image_manifest and os.path.exists(image_manifest):
ret['image_manifest'] = open(image_manifest, 'r').read()
if traceroute_host:
passed = False
try:
ret['traceroute'] = run_command(
ret['traceroute_v6'] = run_command(
'traceroute6 -n {host}'.format(host=traceroute_host))
passed = True
except subprocess.CalledProcessError:
try:
ret['traceroute'] = run_command(
'traceroute -n {host}'.format(host=traceroute_host))
except subprocess.CalledProcessError:
pass
pass
try:
ret['traceroute_v4'] = run_command(
'traceroute -n {host}'.format(host=traceroute_host))
passed = True
except subprocess.CalledProcessError:
pass
if not passed:
module.fail_json(
msg="No viable v4 or v6 route found to {traceroute_host}."
" The build node is assumed to be invalid.".format(
traceroute_host=traceroute_host))
for key, command in command_map.items():
try:
ret[key] = run_command(command)
except subprocess.CalledProcessError:
# TODO(mordred) Make some of these fail so that we get the equiv
# of "does this host work"
pass
module.exit_json(changed=False, _zuul_nolog_return=True, **ret)

View File

@ -34,9 +34,16 @@ Network neighbors
{{ zdi.network_neighbors }}
{% endif %}
{% if 'traceroute' in zdi %}
Route to Known Host
===================
{% if 'traceroute_v4' in zdi %}
Route to Known Host v4
======================
Known Host: {{ zuul_traceroute_host }}
{{ zdi.traceroute }}
{{ zdi.traceroute_v4 }}
{% endif %}
{% if 'traceroute_v6' in zdi %}
Route to Known Host v6
======================
Known Host: {{ zuul_traceroute_host }}
{{ zdi.traceroute_v6 }}
{% endif %}