handle error 401 explicitely since the task maybe completed before it is started being monitored
This commit is contained in:
+13
-2
@@ -52,6 +52,17 @@ class Tasks:
|
|||||||
else:
|
else:
|
||||||
logging.error(f'Task ID={task_identifier} failed. task state={ZertoTaskStates.get_name_by_value(state)}')
|
logging.error(f'Task ID={task_identifier} failed. task state={ZertoTaskStates.get_name_by_value(state)}')
|
||||||
raise Exception(f"Task failed: {task_info.get('CompleteReason', 'No reason provided')}")
|
raise Exception(f"Task failed: {task_info.get('CompleteReason', 'No reason provided')}")
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
logging.error(f"Request failed: {e}")
|
if e.response.status_code == 401:
|
||||||
|
# Task might be completed and no longer accessible
|
||||||
|
logging.info(f'Task ID={task_identifier} returned 401 - task may be completed and no longer accessible')
|
||||||
|
time.sleep(interval)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
logging.error(f"HTTP request failed: {e}")
|
||||||
|
time.sleep(interval)
|
||||||
|
continue
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
logging.info(f"Request failed: {e}")
|
||||||
|
time.sleep(interval)
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user