Skip to content

Conversation

feng-j678
Copy link
Contributor

@feng-j678 feng-j678 commented Feb 26, 2025

[x] feature 26928297
[x] Currently when security/critical package(s) installation is failed, the installation operation will mark as an error even after retry package is succeeded.
[x] new code changes for first time when security/critical package(s) installation failed, but after retry if all package(s) are installed as planned, mark installation operation to Warning and add details in error object that "all supposed package(s) are installed"

image ![image](https://github.com/user-attachments/assets/d5d60969-96de-4c15-9e70-d30642e61d8b)

High-level PR comments by @rane-rajasi were in this 'comments PR' - leaving link: #314 (this will be closed)

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.75%. Comparing base (cfdca4c) to head (cdacc2b).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
+ Coverage   93.73%   93.75%   +0.02%     
==========================================
  Files         103      103              
  Lines       17881    17961      +80     
==========================================
+ Hits        16760    16840      +80     
  Misses       1121     1121              
Flag Coverage Δ
python27 93.75% <100.00%> (+0.02%) ⬆️
python312 93.75% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@feng-j678 feng-j678 marked this pull request as ready for review February 26, 2025 22:39
@nikhim-um nikhim-um assigned nikhim-um and feng-j678 and unassigned nikhim-um and feng-j678 Feb 27, 2025
@nikhim-um nikhim-um self-requested a review February 27, 2025 07:04
@feng-j678 feng-j678 force-pushed the feature/pkg_failed_retry_set_status_warning branch from e6a78e3 to 1f757ef Compare February 27, 2025 07:12
@kjohn-msft
Copy link
Collaborator

Note left offline to clean up miscellaneous noisy line changes to make the PR easier to review.

Copy link
Collaborator

@kjohn-msft kjohn-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment history - please remove misc noisy lines (whitespace changes and non-functional changes) to make this easier to review.

Copy link
Contributor

@rane-rajasi rane-rajasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description of the current scenario and what this change is trying to achieve,

@kjohn-msft kjohn-msft added the feature New feature or request label Mar 14, 2025
Copy link
Contributor

@rane-rajasi rane-rajasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this PR commit: f9ae07e
as reference for what is expected out of this feature.

NOTE: The new UTs you've added are failing due to legacy code from your changes that weren't carried over to this one, please look into those.
I believe we can also avoid returning maintenance_window_exceeded from start_installation() but that would require a lot of existing code changes which again shouldn't happen in here.

@feng-j678 feng-j678 force-pushed the feature/pkg_failed_retry_set_status_warning branch from 8cc2f48 to 0a80cc6 Compare April 21, 2025 20:48
message = "All requested package(s) are installed. Any patch errors marked are from previous attempts."
self.composite_logger.log(message)
self.status_handler.add_error_to_status(message=message, error_code=Constants.PatchOperationErrorCodes.PACKAGES_RETRY_SUCCEEDED, current_operation_override_for_error=Constants.INSTALLATION)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is [current_operation_override_for_error=Constants.INSTALLATION] explicitly passed to status_handler.add_error_to_status()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because in coremain.py, we are invoking assessment logic and in assessment first line of code is set operation to assessment. I was trying to avoid making unnecessary code changes to minimize new regressions so i passed in a parm to override the operation then it will update the correct error json. since you raise this up, I've added a minor condition check in patchassessor.py to check for installation operation, so no overriding.

image
self.status_handler.set_current_operation(Constants.ASSESSMENT)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My other comment applies here as well: https://github.com/Azure/LinuxPatchExtension/pull/291/files#r2070283468.

set current_operation in mark_installation_completed_with_warning(). Try to use similar code as reference and always test the code for all scenarios when introducing a change in existing code.

Copy link
Contributor Author

@feng-j678 feng-j678 May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not rlly liking the idea setting operation back and forth when we can pass parameter(current_operation_override_for_error) in the function to correctly update the substatus error, if this is strongly against then we should remove that parameter

image

""" Check if patch installation status can be set to warning from failed. """
# type (bool, bool) -> bool
return not patch_installation_successful and not maintenance_window_exceeded and self.status_handler.are_all_requested_packages_installed()
# endregion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the end of this file? If so, make sure to leave 2 empty lines at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 empty lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why, but there are 2 empty lines
image

Copy link
Contributor

@rane-rajasi rane-rajasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments inline

@feng-j678 feng-j678 force-pushed the feature/pkg_failed_retry_set_status_warning branch from a243c5c to 2611f98 Compare April 29, 2025 22:06
self.status_handler.set_current_operation(Constants.ASSESSMENT)
# Prevent operation override during installation operation
if self.status_handler.get_current_operation() != Constants.INSTALLATION:
self.status_handler.set_current_operation(Constants.ASSESSMENT)
Copy link
Contributor

@rane-rajasi rane-rajasi May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary? This is a major breaking change, current operation needs to be set to whichever sub operation (i.e. assessment, installation, configure patching) is in progress for the code to be able to update the correct substatus

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment for what needs to change: https://github.com/Azure/LinuxPatchExtension/pull/291/files#r2070283468

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change is corrected

""" Marks Installation operation as warning by updating the status of PatchInstallationSummary as warning and patch metadata to be sent to healthstore.
This is set outside of start_installation function to a restriction in CRP, where installation substatus should be marked as warning only after the implicit (2nd) assessment operation
and all customer requested packages are installed. """

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer the function mark_installation_completed()

image

Incase you want to ensure PatchInstallationSummary substatus is updated by this function, you need to set current_operation to Installation here, instead of changing existing code in PatchAssessor.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is done


# Check installation status is WARNING
self.assertTrue(substatus_file_data[1]["name"] == Constants.PATCH_INSTALLATION_SUMMARY)
self.assertTrue(substatus_file_data[1]["status"].lower() == Constants.STATUS_WARNING.lower())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a Installed patches and/or pending patches assertion here if possible. i.e. say, Pending patch count == 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def should_patch_installation_status_be_set_to_warning(self, patch_installation_successful, maintenance_window_exceeded):
""" Check if patch installation status can be set to warning from failed. """
# type (bool, bool) -> bool
return not patch_installation_successful and not maintenance_window_exceeded and self.status_handler.are_all_requested_packages_installed()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjohn-msft I think we also need to check if reboot is pending here. We have an existing function mark_installation_completed() which also sets installation status to warning based on a few conditions, wondering if we should merge this one with that
image

Copy link
Contributor

@rane-rajasi rane-rajasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 open comments inline (2 from previous review) and 1 comment open for discussion

@kjohn-msft
Copy link
Collaborator

High-level PR comments by @rane-rajasi were in this 'comments PR' - leaving link: #314 (this will be closed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants