Commit f4484122 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Show message when job is waiting in queue or for locks



Jobs submitted via the standard command line utilities didn't give any
indication that anything is happening while they were waiting in the job
queue (e.g. due to other jobs using all worker threads) or acquiring
locks. This could be very confusing for people not familiar with Ganeti's
architecture. Now they'll show a message after the first WaitForJobChanges
timeout.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cb462b06
......@@ -1132,12 +1132,28 @@ def PollJob(job_id, cl=None, feedback_fn=None):
prev_job_info = None
prev_logmsg_serial = None
status = None
notified_queued = False
notified_waitlock = False
while True:
result = cl.WaitForJobChange(job_id, ["status"], prev_job_info,
prev_logmsg_serial)
result = cl.WaitForJobChangeOnce(job_id, ["status"], prev_job_info,
prev_logmsg_serial)
if not result:
# job not found, go away!
raise errors.JobLost("Job with id %s lost" % job_id)
elif result == constants.JOB_NOTCHANGED:
if status is not None and not callable(feedback_fn):
if status == constants.JOB_STATUS_QUEUED and not notified_queued:
ToStderr("Job %s is waiting in queue", job_id)
notified_queued = True
elif status == constants.JOB_STATUS_WAITLOCK and not notified_waitlock:
ToStderr("Job %s is trying to acquire all necessary locks", job_id)
notified_waitlock = True
# Wait again
continue
# Split result, a tuple of (field values, log entries)
(job_info, log_entries) = result
......
......@@ -372,12 +372,17 @@ class Client(object):
timeout = (DEF_RWTO - 1) / 2
return self.CallMethod(REQ_AUTOARCHIVE_JOBS, (age, timeout))
def WaitForJobChange(self, job_id, fields, prev_job_info, prev_log_serial):
def WaitForJobChangeOnce(self, job_id, fields,
prev_job_info, prev_log_serial):
timeout = (DEF_RWTO - 1) / 2
return self.CallMethod(REQ_WAIT_FOR_JOB_CHANGE,
(job_id, fields, prev_job_info,
prev_log_serial, timeout))
def WaitForJobChange(self, job_id, fields, prev_job_info, prev_log_serial):
while True:
result = self.CallMethod(REQ_WAIT_FOR_JOB_CHANGE,
(job_id, fields, prev_job_info,
prev_log_serial, timeout))
result = self.WaitForJobChangeOnce(job_id, fields,
prev_job_info, prev_log_serial)
if result != constants.JOB_NOTCHANGED:
break
return result
......@@ -402,6 +407,3 @@ class Client(object):
def QueryTags(self, kind, name):
return self.CallMethod(REQ_QUERY_TAGS, (kind, name))
# TODO: class Server(object)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment