in azurelinuxagent/ga/exthandlers.py [0:0]
def wait_for_handler_completion(handler_i, wait_until, extension=None):
"""
Check the status of the extension being handled. Wait until it has a terminal state or times out.
:raises: Exception if it is not handled successfully.
"""
extension_name = handler_i.get_extension_full_name(extension)
# If the handler had no settings, we should not wait at all for handler to report status.
if extension is None:
logger.info("No settings found for {0}, not waiting for it's status".format(extension_name))
return
try:
ext_completed, status = False, None
# Keep polling for the extension status until it succeeds or times out
while datetime.datetime.utcnow() <= wait_until:
ext_completed, status = handler_i.is_ext_handling_complete(extension)
if ext_completed:
break
time.sleep(5)
except Exception as e:
msg = "Failed to wait for Handler completion due to unknown error. Marking the dependent extension as failed: {0}, {1}".format(
extension_name, textutil.format_exception(e))
raise Exception(msg)
# In case of timeout or terminal error state, we log it and raise
# Incase extension reported status at the last sec, we should prioritize reporting status over timeout
if not ext_completed and datetime.datetime.utcnow() > wait_until:
msg = "Dependent Extension {0} did not reach a terminal state within the allowed timeout. Last status was {1}".format(
extension_name, status)
raise Exception(msg)
if status != ExtensionStatusValue.success:
msg = "Dependent Extension {0} did not succeed. Status was {1}".format(extension_name, status)
raise Exception(msg)