Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LAD 4.0] Change User-Generated Errors to Return Non-Zero #1709

Open
wants to merge 3 commits into
base: release/lad4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions Diagnostic/Utils/misc_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ def log_and_report_failed_config_generation(self, ext_event_type, config_invalid
secrets in the protected settings. This is for logging to Geneva for diagnostic purposes.
:return: None
"""
config_invalid_log = "Invalid config settings given: " + config_invalid_reason + \
". Can't proceed, although this install/enable operation is reported as successful so " \
"the VM can complete successful startup."
self._logger_log(config_invalid_log)
self._status_reporter(ext_event_type, 'success', '0', config_invalid_log)
config_invalid_log = "Invalid config settings given: {0}".format(config_invalid_reason)
self._logger_error(config_invalid_log)
self._status_reporter(ext_event_type, 'error', '2', config_invalid_log)
self._waagent_event_adder(name=self._ext_name,
op=ext_event_type,
isSuccess=True, # Note this is True, because it is a user error.
isSuccess=False,
version=self._ext_ver,
message="Invalid handler settings encountered: {0}".format(redacted_handler_settings))

Expand All @@ -169,14 +167,12 @@ def log_and_report_invalid_mdsd_cfg(self, ext_event_type, config_validate_cmd_ms
:param mdsd_cfg_xml: Content of xmlCfg.xml to be sent to Geneva
:return: None
"""
message = "Problem(s) detected in generated mdsd configuration. Can't enable, although this install/enable " \
"operation is reported as successful so the VM can complete successful startup. Linux Diagnostic " \
"Extension will exit. Config validation message: {0}".format(config_validate_cmd_msg)
self._logger_log(message)
self._status_reporter(ext_event_type, 'success', '0', message)
message = "Problem(s) detected in generated mdsd configuration. Config validation message: {0}".format(config_validate_cmd_msg)
self._logger_error(message)
self._status_reporter(ext_event_type, 'error', '2', message)
self._waagent_event_adder(name=self._ext_name,
op=ext_event_type,
isSuccess=True, # Note this is True, because it is a user error.
isSuccess=False,
version=self._ext_ver,
message="Problem(s) detected in generated mdsd configuration: {0}".format(mdsd_cfg_xml))

Expand Down
9 changes: 4 additions & 5 deletions Diagnostic/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,12 @@ def check_for_supported_waagent_and_distro_version():
return False

if g_dist_config is None:
msg = ("LAD does not support distro/version ({0}); not installed. This extension install/enable operation is "
"still considered a success as it's an external error.").format(str(platform.dist()))
msg = ("LAD does not support distro/version ({0}); not installed.").format(str(platform.dist()))
hutil.log(msg)
hutil.do_status_report(g_ext_op_type, "success", '0', msg)
hutil.do_status_report(g_ext_op_type, 'error', '2', msg)
waagent.AddExtensionEvent(name=hutil.get_name(),
op=g_ext_op_type,
isSuccess=True,
isSuccess=False,
version=hutil.get_extension_version(),
message="Can't be installed on this OS " + str(platform.dist()))
return False
Expand Down Expand Up @@ -496,7 +495,7 @@ def start_mdsd(configurator):
g_mdsd_bin_path, xml_file, g_ext_dir)
config_validate_cmd_status, config_validate_cmd_msg = RunGetOutput(config_validate_cmd)
if config_validate_cmd_status is not 0:
# Invalid config. Log error and report success.
# Invalid config, return error.
aswatt marked this conversation as resolved.
Show resolved Hide resolved
g_lad_log_helper.log_and_report_invalid_mdsd_cfg(g_ext_op_type,
config_validate_cmd_msg, read_file_to_string(xml_file))
return
Expand Down