Skip to content

Commit

Permalink
Tolerate restarts while waiting for job completion
Browse files Browse the repository at this point in the history
Details:

* Requests for job status will return ConnectionError while HMC
  is restarting. This will be ignored to tolerate HMC restarts
  that will happen while waiting for completion of a job.

Signed-off-by: Abhiram Santhosh <[email protected]>
  • Loading branch information
abhirams-1 authored and andy-maier committed Dec 15, 2023
1 parent a7300a5 commit f0428de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Released: not yet

**Enhancements:**

* Added support for tolerating HMC restarts while waiting for a job to complete.
Session.wait_for_completion() now retries in case of ConnectionError instead of
raising the error. (issue #1365)

**Cleanup:**

**Known issues:**
Expand Down
9 changes: 7 additions & 2 deletions zhmcclient/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,6 @@ def wait_for_completion(self, operation_timeout=None):
:exc:`~zhmcclient.ParseError`
:exc:`~zhmcclient.ClientAuthError`
:exc:`~zhmcclient.ServerAuthError`
:exc:`~zhmcclient.ConnectionError`
:exc:`~zhmcclient.OperationTimeout`: The timeout expired while
waiting for job completion.
"""
Expand All @@ -1785,7 +1784,13 @@ def wait_for_completion(self, operation_timeout=None):
start_time = time.time()

while True:
job_status, op_result_obj = self.check_for_completion()
try:
job_status, op_result_obj = self.check_for_completion()
except ConnectionError:
HMC_LOGGER.debug("Retrying after ConnectionError while waiting"
" for completion of job %s. This could be "
"because HMC is restarting.", self.uri)
job_status = None

# We give completion of status priority over strictly achieving
# the timeout, so we check status first. This may cause a longer
Expand Down

0 comments on commit f0428de

Please sign in to comment.