Skip to content

Commit fdf20d4

Browse files
authored
Bug fixes: in ConfigurePatching error reporting and disabling auto updates in yum via packagekit (#98)
* Fixing bugs in Configure Patching error reporting and disable auto updates for PackageKit in YUM * Addresing PR feedback
1 parent 759bd8d commit fdf20d4

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/core/src/core_logic/ConfigurePatchingProcessor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def __try_set_patch_mode(self):
7373

7474
self.current_auto_os_patch_state = self.package_manager.get_current_auto_os_patch_state()
7575

76-
if self.current_auto_os_patch_state == Constants.AutomaticOSPatchStates.UNKNOWN:
76+
if self.execution_config.patch_mode == Constants.PatchModes.AUTOMATIC_BY_PLATFORM and self.current_auto_os_patch_state == Constants.AutomaticOSPatchStates.UNKNOWN:
7777
# NOTE: only sending details in error objects for customer visibility on why patch state is unknown, overall configurepatching status will remain successful
78-
self.__report_consolidated_configure_patch_status(error="Extension attempted but could not disable some of the auto OS update service. Please check if the auto OS services are configured correctly")
78+
self.__report_consolidated_configure_patch_status(error="Extension attempted but could not disable one or more automatic OS update services. Please check if the auto OS services are configured correctly")
7979
else:
8080
self.__report_consolidated_configure_patch_status()
8181

@@ -128,8 +128,6 @@ def __report_consolidated_configure_patch_status(self, status=Constants.STATUS_T
128128
error_msg = 'Error: ' + repr(error)
129129
self.composite_logger.log_error(error_msg)
130130
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.DEFAULT_ERROR)
131-
if Constants.ERROR_ADDED_TO_STATUS not in repr(error):
132-
error.args = (error.args, "[{0}]".format(Constants.ERROR_ADDED_TO_STATUS))
133131

134132
# write consolidated status
135133
self.status_handler.set_configure_patching_substatus_json(status=status,

src/core/src/package_managers/YumPackageManager.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,19 +583,19 @@ def disable_auto_os_update_for_packagekit(self):
583583
#todo: uncomment after finding the correct value
584584
# self.update_os_patch_configuration_sub_setting(self.download_updates_identifier_text, "false", self.packagekit_config_pattern_match_text)
585585
self.update_os_patch_configuration_sub_setting(self.apply_updates_identifier_text, "false", self.packagekit_config_pattern_match_text)
586-
self.disable_auto_update_on_reboot(self.dnf_automatic_disable_on_reboot_cmd)
586+
self.disable_auto_update_on_reboot(self.packagekit_disable_on_reboot_cmd)
587587

588-
self.composite_logger.log("Successfully disabled auto OS updates using dnf-automatic")
588+
self.composite_logger.log("Successfully disabled auto OS updates using packagekit")
589589

590590
def is_service_set_to_enable_on_reboot(self, command):
591591
""" Checking if auto update is enable_on_reboot on the machine. An enable_on_reboot service will be activated (if currently inactive) on machine reboot """
592592
self.composite_logger.log_debug("Checking if auto update service is set to enable on reboot...")
593593
code, out = self.env_layer.run_command_output(command, False, False)
594594
self.composite_logger.log_debug(" - Code: " + str(code) + ", Output: \n|\t" + "\n|\t".join(out.splitlines()))
595595
if len(out.strip()) > 0 and code == 0 and 'enabled' in out:
596-
self.composite_logger.log_debug("Auto OS update will enable on reboot")
596+
self.composite_logger.log_debug("Auto OS update service will enable on reboot")
597597
return True
598-
self.composite_logger.log_debug("Auto OS update will NOT enable on reboot")
598+
self.composite_logger.log_debug("Auto OS update service will NOT enable on reboot")
599599
return False
600600

601601
def backup_image_default_patch_configuration_if_not_exists(self):
@@ -721,7 +721,6 @@ def __get_current_auto_os_updates_setting_on_machine(self):
721721

722722
# get install state
723723
if not self.is_auto_update_service_installed(self.install_check_cmd):
724-
self.composite_logger.log_debug("Auto OS service is not installed on the machine")
725724
return is_service_installed, enable_on_reboot_value, download_updates_value, apply_updates_value
726725

727726
is_service_installed = True
@@ -806,10 +805,10 @@ def is_auto_update_service_installed(self, install_check_cmd):
806805
code, out = self.env_layer.run_command_output(install_check_cmd, False, False)
807806
self.composite_logger.log_debug(" - Code: " + str(code) + ", Output: \n|\t" + "\n|\t".join(out.splitlines()))
808807
if len(out.strip()) > 0 and code == 0:
809-
self.composite_logger.log_debug("Auto OS update is installed on the machine")
808+
self.composite_logger.log_debug("Auto OS update service is installed on the machine")
810809
return True
811810
else:
812-
self.composite_logger.log_debug("Auto OS update is NOT installed on the machine")
811+
self.composite_logger.log_debug("Auto OS update service is NOT installed on the machine")
813812
return False
814813

815814
# endregion

0 commit comments

Comments
 (0)