Skip to content

Commit 1f757ef

Browse files
committed
remove comments
1 parent 68421aa commit 1f757ef

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

src/core/src/core_logic/PatchInstaller.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ def __init__(self, env_layer, execution_config, composite_logger, telemetry_writ
5353

5454
self.stopwatch = Stopwatch(self.env_layer, self.telemetry_writer, self.composite_logger)
5555

56-
self.__org_expected_install_packages_list = None
57-
self.__org_expected_install_packages_version_list = None
5856
self.__enable_installation_warning_status = False
5957

6058
def start_installation(self, simulate=False):
@@ -128,9 +126,6 @@ def start_installation(self, simulate=False):
128126
overall_patch_installation_successful = bool(update_run_successful and not maintenance_window_exceeded)
129127
# NOTE: Not updating installation substatus at this point because we need to wait for the implicit/second assessment to complete first, as per CRP's instructions
130128

131-
# Reset expected packages and versions list:
132-
self.__reset_expected_packages_and_version_list()
133-
134129
return overall_patch_installation_successful
135130

136131
def write_installer_perf_logs(self, patch_operation_successful, installed_patch_count, retry_count, maintenance_window, maintenance_window_exceeded, task_status, error_msg):
@@ -260,10 +255,6 @@ def install_updates(self, maintenance_window, package_manager, simulate=False):
260255
self.status_handler.set_package_install_status(self.skipped_esm_packages, self.skipped_esm_package_versions, Constants.FAILED)
261256
self.composite_logger.log("\nList of packages to be updated: \n" + str(packages))
262257

263-
# Store the original list of packages and versions that were intended to be installed
264-
self.__org_expected_install_packages_list = list(packages)
265-
self.__org_expected_install_packages_version_list = list(package_versions)
266-
267258
sec_packages, sec_package_versions = self.package_manager.get_security_updates()
268259
self.telemetry_writer.write_event("Security packages out of the final package list: " + str(sec_packages), Constants.TelemetryEventLevel.Verbose)
269260
self.status_handler.set_package_install_status_classification(sec_packages, sec_package_versions, classification="Security")
@@ -844,23 +835,29 @@ def __log_progress_status(self, maintenance_window, installed_update_count):
844835
self.composite_logger.log(progress_status)
845836

846837
# region - Failed packages retry succeeded
847-
def __reset_expected_packages_and_version_list(self):
848-
self.__org_expected_install_packages_list = None
849-
self.__org_expected_install_packages_version_list = None
850-
851838
def __check_if_all_packages_installed(self):
852839
#type (none) -> bool
853-
""" Check if all supposed packages are installed """
840+
""" Check if all supposed security and critical packages are installed """
854841
# Get the list of installed packages
855842
installed_packages_list = self.status_handler.get_installation_packages_list()
856-
# Create a list to store uninstalled packages
857-
uninstalled_packages_list = [
858-
(pkg, ver) for pkg, ver in zip(self.__org_expected_install_packages_list, self.__org_expected_install_packages_version_list)
859-
if not any(installed_pkg['name'] == pkg and installed_pkg['version'] == ver and installed_pkg['patchInstallationState'] == Constants.INSTALLED for
860-
installed_pkg in installed_packages_list)
861-
]
862-
# Return True if all packages are installed, otherwise return False
863-
return len(uninstalled_packages_list) == 0
843+
print('what is installed_packages_list', installed_packages_list)
844+
# Get security and critical packages
845+
security_critical_packages = []
846+
for package in installed_packages_list:
847+
if 'classifications' in package and any(classification in ['Security', 'Critical'] for classification in package['classifications']):
848+
security_critical_packages.append(package)
849+
850+
# Return false there's no security/critical packages
851+
if len(security_critical_packages) == 0:
852+
return False
853+
854+
# Check if any security/critical package are not installed
855+
for package in security_critical_packages:
856+
if package['patchInstallationState'] != Constants.INSTALLED:
857+
return False
858+
859+
# All security/critical packages are installed
860+
return True
864861

865862
def __sent_metadata_health_store(self):
866863
self.composite_logger.log_debug("[PI] Reviewing final healthstore record write. [HealthStoreId={0}][MaintenanceRunId={1}]".format(str(self.execution_config.health_store_id), str(self.execution_config.maintenance_run_id)))

src/core/tests/Test_CoreMain.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,10 @@ def mock_os_path_exists(self, patch_to_validate):
5555

5656
def mock_batch_patching_with_packages(self, all_packages, all_package_versions, packages, package_versions, maintenance_window, package_manager):
5757
"""Mock batch_patching to simulate package installation failure, return some packages """
58-
# This simulates the first batch attempt failing, returning original packages unchanged
59-
# When the retry path kicks in, the package list should be processed and succeed there
6058
return packages, package_versions, 0, False
6159

6260
def mock_batch_patching_with_no_packages(self, all_packages, all_package_versions, packages, package_versions, maintenance_window, package_manager):
6361
"""Mock batch_patching to simulate package installation failure, return no packages"""
64-
# This simulates the first batch attempt failing, returning original packages unchanged
65-
# When the retry path kicks in, the package list should be processed and succeed there
6662
return [], [], 0, False
6763

6864
def test_operation_fail_for_non_autopatching_request(self):

0 commit comments

Comments
 (0)