-
Notifications
You must be signed in to change notification settings - Fork 11
Feature: Set Installation Status to Warning when all expected packages are installed #291
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e6a78e3
to
1f757ef
Compare
Note left offline to clean up miscellaneous noisy line changes to make the PR easier to review. |
There was a problem hiding this 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.
There was a problem hiding this 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,
…into feature/pkg_failed_retry_set_status_warning
…/github.com/Azure/LinuxPatchExtension into feature/pkg_failed_retry_set_status_warning pull master changes
There was a problem hiding this 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.
…/github.com/Azure/LinuxPatchExtension into feature/pkg_failed_retry_set_status_warning pull master changes
8cc2f48
to
0a80cc6
Compare
…into feature/pkg_failed_retry_set_status_warning pull master changes.
…into feature/pkg_failed_retry_set_status_warning pull master changes.
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) | ||
|
There was a problem hiding this comment.
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()?
There was a problem hiding this comment.
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.
self.status_handler.set_current_operation(Constants.ASSESSMENT)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 empty lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments inline
…into feature/pkg_failed_retry_set_status_warning pull master changes
a243c5c
to
2611f98
Compare
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. """ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this 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
…into feature/pkg_failed_retry_set_status_warning pull master changes
High-level PR comments by @rane-rajasi were in this 'comments PR' - leaving link: #314 (this will be closed) |
[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"
High-level PR comments by @rane-rajasi were in this 'comments PR' - leaving link: #314 (this will be closed)