diff options
author | showard <showard@592f7852-d20e-0410-864c-8624ca9c26a4> | 2010-01-22 21:10:16 +0000 |
---|---|---|
committer | showard <showard@592f7852-d20e-0410-864c-8624ca9c26a4> | 2010-01-22 21:10:16 +0000 |
commit | 1db21ab845fa67d909c8dedb44036ea30f6250f1 (patch) | |
tree | b0448a53777269943420f34c50830c77d8a60bf0 | |
parent | ed82d371495f259b4caac5ad963c53e1af7732bf (diff) |
Rearrange the why isn't my job running logic so that it checks all of
the preconditions first before looking at the Ready state of the
machines.
Also have it list all reasons the job is not running rather
than only the first reason and dying. That way when someone uses it
they don't think "oh, its just that, let me fix that" only to have it
not work and have to rerun it again later to see the next reason.
Signed-off-by: Gregory Smith <gps@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@4160 592f7852-d20e-0410-864c-8624ca9c26a4
-rwxr-xr-x | cli/contrib/why_isnt_my_job_running.py | 109 |
1 files changed, 58 insertions, 51 deletions
diff --git a/cli/contrib/why_isnt_my_job_running.py b/cli/contrib/why_isnt_my_job_running.py index d7176174..5b477e7f 100755 --- a/cli/contrib/why_isnt_my_job_running.py +++ b/cli/contrib/why_isnt_my_job_running.py @@ -215,6 +215,9 @@ if not hosts: sys.exit(1) host = hosts[0] +# Boolean to track our findings. We want to list all reasons it won't run, +# not just the first. +job_will_run = True entries_for_this_host = [entry for entry in queue_entries if entry['host'] @@ -242,22 +245,40 @@ else: sys.exit(0) is_metahost = True -# host ready? -if host['status'] != 'Ready': - if host['status'] == 'Pending': - active = proxy.run('get_host_queue_entries', - host=host['id'], active=True) - if not active: - print ('Host %s seems to be in "Pending" state incorrectly; please ' - 'report this to the Autotest team' % hostname) - sys.exit(1) - print 'Host not in "Ready" status (status="%s")' % host['status'] - sys.exit(0) +# meets atomic group requirements? +host_labels = proxy.run('get_labels', name__in=list(host_label_names)) +host_atomic_group_labels = [label for label in host_labels + if label['atomic_group']] +host_atomic_group_name = None +if host_atomic_group_labels: + atomic_groups = set() + for label in host_atomic_group_labels: + atomic_groups.add(label['atomic_group']['name']) + if len(atomic_groups) != 1: + print 'Host has more than one atomic group!' + print list(atomic_groups) + sys.exit(1) + host_atomic_group_label = host_atomic_group_labels[0] + host_atomic_group_name = host_atomic_group_label['atomic_group']['name'] + +job_atomic_groups = set(entry['atomic_group'] for entry in queue_entries) +assert len(job_atomic_groups) == 1, 'Job has more than one atomic group value!' +job_atomic_group = job_atomic_groups.pop() # might be None +job_atomic_group_name = None +if job_atomic_group: + job_atomic_group_name = job_atomic_group['name'] + +if host_atomic_group_name != job_atomic_group_name: + print ('Job is for atomic group %s, but host is in atomic group %s ' + '(label %s)' % + (job_atomic_group_name, host_atomic_group_name, + host_atomic_group_label['name'])) + job_will_run = False # host locked? if host['locked']: print 'Host is locked by', host['locked_by'], 'no jobs will schedule on it.' - sys.exit(0) + job_will_run = False # acl accessible? accessible = proxy.run('get_hosts', hostname=hostname, @@ -268,9 +289,9 @@ if not accessible: owner_acls = ', '.join(group['name'] for group in proxy.run('get_acl_groups', users__login=owner)) print 'Host not ACL-accessible to job owner', owner - print 'Host ACLs:', host_acls - print 'Owner Acls:', owner_acls - sys.exit(0) + print ' Host ACLs:', host_acls + print ' Owner Acls:', owner_acls + job_will_run = False # meets dependencies? job_deps_list = job['dependencies'].split(',') @@ -281,7 +302,7 @@ unmet = job_deps - host_label_names if unmet: print ("Host labels (%s) don't satisfy job dependencies: %s" % (', '.join(host_label_names), ', '.join(unmet))) - sys.exit(0) + job_will_run = False # at this point, if the job is for an unassigned atomic group, things are too # complicated to proceed @@ -293,36 +314,6 @@ if unassigned_atomic_group_entries: "can't give you any definite answers. Sorry.") sys.exit(1) -# meets atomic group requirements? -host_labels = proxy.run('get_labels', name__in=list(host_label_names)) -host_atomic_group_labels = [label for label in host_labels - if label['atomic_group']] -host_atomic_group_name = None -if host_atomic_group_labels: - atomic_groups = set() - for label in host_atomic_group_labels: - atomic_groups.add(label['atomic_group']['name']) - if len(atomic_groups) != 1: - print 'Host has more than one atomic group!' - print list(atomic_groups) - sys.exit(1) - host_atomic_group_label = host_atomic_group_labels[0] - host_atomic_group_name = host_atomic_group_label['atomic_group']['name'] - -job_atomic_groups = set(entry['atomic_group'] for entry in queue_entries) -assert len(job_atomic_groups) == 1, 'Job has more than one atomic group value!' -job_atomic_group = job_atomic_groups.pop() # might be None -job_atomic_group_name = None -if job_atomic_group: - job_atomic_group_name = job_atomic_group['name'] - -if host_atomic_group_name != job_atomic_group_name: - print ('Job is for atomic group %s, but host is in atomic group %s ' - '(label %s)' % - (job_atomic_group_name, host_atomic_group_name, - host_atomic_group_label['name'])) - sys.exit(0) - # meets only_if_needed labels? if is_metahost: metahost_names = set(entry['meta_host'] @@ -334,9 +325,25 @@ if is_metahost: if unmet_exclusive_label: print ('Host contains "only if needed" label %s, unused by job ' 'dependencies and metahosts' % label['name']) - sys.exit(0) + job_will_run = False -print ("Job %s should run on host %s; if you've already waited about ten " - "minutes or longer, it's probably a server issue or a bug." % - (job_id, hostname)) -sys.exit(1) +# host ready? +if host['status'] != 'Ready': + if host['status'] == 'Pending': + active = proxy.run('get_host_queue_entries', + host=host['id'], active=True) + if not active: + print ('Host %s seems to be in "Pending" state incorrectly; please ' + 'report this to the Autotest team' % hostname) + sys.exit(1) + print 'Host not in "Ready" status (status="%s")' % host['status'] + job_will_run = False + +if job_will_run: + print ("Job %s should run on host %s; if you've already waited about ten " + "minutes or longer, it's probably a server issue or a bug." % + (job_id, hostname)) + sys.exit(1) +else: + print "All of the reasons this job is not running are listed above." + sys.exit(0) |