in azurelinuxagent/ga/exthandlers.py [0:0]
def handle_ext_handlers(self, goal_state_id):
if not self.ext_handlers:
logger.info("No extension handlers found, not processing anything.")
return
wait_until = datetime.datetime.utcnow() + datetime.timedelta(minutes=_DEFAULT_EXT_TIMEOUT_MINUTES)
all_extensions = self.__get_sorted_extensions_for_processing()
# Since all_extensions are sorted based on sort_key, the last element would be the maximum based on the sort_key
max_dep_level = self.__get_dependency_level(all_extensions[-1]) if any(all_extensions) else 0
depends_on_err_msg = None
extensions_enabled = conf.get_extensions_enabled()
for extension, ext_handler in all_extensions:
handler_i = ExtHandlerInstance(ext_handler, self.protocol, extension=extension)
# In case of extensions disabled, we skip processing extensions. But CRP is still waiting for some status
# back for the skipped extensions. In order to propagate the status back to CRP, we will report status back
# here with an error message.
if not extensions_enabled:
agent_conf_file_path = get_osutil().agent_conf_file_path
msg = "Extension will not be processed since extension processing is disabled. To enable extension " \
"processing, set Extensions.Enabled=y in '{0}'".format(agent_conf_file_path)
ext_full_name = handler_i.get_extension_full_name(extension)
logger.info('')
logger.info("{0}: {1}".format(ext_full_name, msg))
add_event(op=WALAEventOperation.ExtensionProcessing, message="{0}: {1}".format(ext_full_name, msg))
handler_i.set_handler_status(status=ExtHandlerStatusValue.not_ready, message=msg, code=-1)
handler_i.create_status_file_if_not_exist(extension,
status=ExtensionStatusValue.error,
code=-1,
operation=handler_i.operation,
message=msg)
continue
# In case of depends-on errors, we skip processing extensions if there was an error processing dependent extensions.
# But CRP is still waiting for some status back for the skipped extensions. In order to propagate the status back to CRP,
# we will report status back here with the relevant error message for each of the dependent extension.
if depends_on_err_msg is not None:
# For MC extensions, report the HandlerStatus as is and create a new placeholder per extension if doesnt exist
if handler_i.should_perform_multi_config_op(extension):
# Ensure some handler status exists for the Handler, if not, set it here
if handler_i.get_handler_status() is None:
handler_i.set_handler_status(message=depends_on_err_msg, code=-1)
handler_i.create_status_file_if_not_exist(extension, status=ExtensionStatusValue.error, code=-1,
operation=WALAEventOperation.ExtensionProcessing,
message=depends_on_err_msg)
# For SC extensions, overwrite the HandlerStatus with the relevant message
else:
handler_i.set_handler_status(message=depends_on_err_msg, code=-1)
continue
# Process extensions and get if it was successfully executed or not
extension_success = self.handle_ext_handler(handler_i, extension, goal_state_id)
dep_level = self.__get_dependency_level((extension, ext_handler))
if 0 <= dep_level < max_dep_level:
extension_full_name = handler_i.get_extension_full_name(extension)
try:
# Do no wait for extension status if the handler failed
if not extension_success:
raise Exception("Skipping processing of extensions since execution of dependent extension {0} failed".format(
extension_full_name))
# Wait for the extension installation until it is handled.
# This is done for the install and enable. Not for the uninstallation.
# If handled successfully, proceed with the current handler.
# Otherwise, skip the rest of the extension installation.
self.wait_for_handler_completion(handler_i, wait_until, extension=extension)
except Exception as error:
logger.warn(
"Dependent extension {0} failed or timed out, will skip processing the rest of the extensions".format(
extension_full_name))
depends_on_err_msg = ustr(error)
add_event(name=extension_full_name,
version=handler_i.ext_handler.version,
op=WALAEventOperation.ExtensionProcessing,
is_success=False,
message=depends_on_err_msg)