Skip to content

Conversation

@GAURAVRAMRAKHYANI
Copy link
Contributor

@GAURAVRAMRAKHYANI GAURAVRAMRAKHYANI commented Feb 10, 2023

Currently Azure Update Management installs one package (along with packages it depends on) at a time using a package manager command. This takes longer time in comparison to installing multiple packages (along with packages they are dependent on) using a package manager command. So, to improve performance, multiple packages can be installed in a batch which takes lesser time than installing the packages one by one sequentially.

In this PR, the code changes are done to install packages in batches. Initially batch size is kept as 3 so 3 packages are installed in a batch (along with packages they are dependent on). In case there are any failures in installing packages in batches, the failed packages are getting installed sequentially as per the existing method of installing packages. Initially batch size is kept as 3 which can be changed later based on the observations on telemetry data and customer feedback.

Code changes done:
Product and test code changes are completed, only review is pending.

Manual testings completed:
(a) Tested that the installation of all the patches is successful.

(b) Tested with total number of available patches to install is greater than batch size (patches will be installed in multiple batches) and total number of patches to install is less than batch size (patches will be installed in single batch).

(c) The portal shows correct status of the patches.

(d) Test with different classification and packages to include and exclude. Check if status of packages is shown correctly in the portal.

(e) If remaining time is not available in maintenance window to install updates in batch, then do not proceed with installing the remaining batches. The remaining packages should be attempted to install sequentially. If there is not enough time available to install packages sequentially then the installation process is stopped at that time. Also, check if status is marked correctly for non-attempted packages.

(f) Tested install updates job for all the three package managers: Apt, Yum and Zypper.

(g) Verified that after batch patching is done, the get available updates is returning the list of updates available and they are getting installed as part of sequential patching.

Done code changes for Aptitude package manager and did manual testing.

Code changes for Yum and Zipper is pending should be completed by next week.
Adding unit tests is pending.

Also, due to signature change of the method install_update_and_dependencies, there are some tests failing. I will work on those tests once we confirm the signature of the method.

Using Stopwatch implementation in this PR. The implementation of Stopwatch is in the PR #161 which is going to be merged soon.
@codecov
Copy link

codecov bot commented Feb 10, 2023

Codecov Report

Merging #171 (a3291f1) into master (f67a65a) will increase coverage by 0.50%.
The diff coverage is 99.83%.

@@            Coverage Diff             @@
##           master     #171      +/-   ##
==========================================
+ Coverage   89.28%   89.78%   +0.50%     
==========================================
  Files          90       90              
  Lines       13426    13937     +511     
==========================================
+ Hits        11987    12514     +527     
+ Misses       1439     1423      -16     
Flag Coverage Δ
python27 88.73% <99.83%> (+0.77%) ⬆️
python39 89.67% <99.83%> (+0.51%) ⬆️

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

Impacted Files Coverage Δ
src/core/src/package_managers/PackageManager.py 79.09% <96.15%> (-0.22%) ⬇️
src/core/src/bootstrap/Constants.py 98.56% <100.00%> (+<0.01%) ⬆️
src/core/src/bootstrap/EnvLayer.py 72.29% <100.00%> (+0.21%) ⬆️
src/core/src/core_logic/MaintenanceWindow.py 87.69% <100.00%> (+0.39%) ⬆️
src/core/src/core_logic/PatchInstaller.py 95.58% <100.00%> (+8.66%) ⬆️
src/core/src/core_logic/Stopwatch.py 100.00% <100.00%> (ø)
...ore/src/package_managers/AptitudePackageManager.py 84.93% <100.00%> (+0.58%) ⬆️
src/core/src/package_managers/YumPackageManager.py 83.13% <100.00%> (+0.40%) ⬆️
.../core/src/package_managers/ZypperPackageManager.py 87.52% <100.00%> (+0.26%) ⬆️
src/core/tests/Test_AptitudePackageManager.py 99.41% <100.00%> (ø)
... and 6 more

... and 1 file with indirect coverage changes

@rane-rajasi
Copy link
Contributor

rane-rajasi commented Feb 14, 2023

Will review this iteration by 2/15 PST

…ests are succeeding now with these changes.

(a) updated function name is_packages_install_time_available to is_package_install_time_available

(b) Made reboot_manager mandatory in the function is_packages_install_time_available

(c) Created a function install_update_and_dependencies_and_get_status
…o install packages in batch then do not stop the complete process of installing patches. The reamaining packages can be installed sequentially and there is already check for maintenance window cutoff time when installing packages sequentially so that the installation is stopped when there is not enough remaining time in maintenance window for installing package.

Tested this scenario.

(b) After batch patching, there is call get_remaining_packages_to_install. The time to execute get_remaining_packages_to_install should not be counted in time taken by nistalling packages in batches. Hence, stopping the stopwatch before calling get_remaining_packages_to_install and writing batch installation details in the telemetry after the call get_remaining_packages_to_install so that we also get the remaining packages to install in the telemetry.
Tested this scenario.
@rane-rajasi
Copy link
Contributor

Code changes done: (a) Implemented installing patches in batches. In a batch, multiple patches are installed which takes lesser time than installing the patches individually.

(b) If there are any patches remaining after installing patches in batches, the existing method of patching is used to install the patches. This could happen due to some failures in installing patches in batches or new patches are available in the brief time when patching in batches.

(c) Completed common code changes and code changes specific to Aptitude package manager.

(d) Completed manual testing for Aptitude package manager.

Code changes pending: (a) Code changes specific to Yum and Zypper package manager. It should be done by end of next week.

(b) Add unit tests.

(c) Some of the existing unit tests are failing due to change of the signature of the method install_update_and_dependencies. I will work on those tests once we confirm the signature of the method.

(d) Many existing tests are failing due to using Stopwatch whose implementation is not yet merged in this branch. Will merge it once the PR #161 which contains implementation for Stopwatch is approved.

Manual testing: (a) Tested that the installation of all the patches is successful.

(b) Tested with total number of available patches to install is greater than batch size (patches will be installed in multiple batches) and total number of patches to install is less than batch size (patches will be installed in single batch).

(c) The portal shows correct status of the patches.

Some of the scenarios pending for manual testing are following: (a) Failure of some patch installation in parallel patching. Check if we are retrying it later during using existing method of patching. Also check if patch is not installed in retry also then correct status is shown in portal.

(b) If there are some patches which were failed to installed during batch patching then test if they are getting installed when existing method of patching is used after batch patching.

(c) Test with different classification and packages to include and exclude. Check if status of packages is shown correctly in the portal.

(d) If remaining time is not available in maintenance window then do not proceed with installing the remaining batches. Also, check if status is marked correctly for non-attempted packages.

Update the main comment/PR description with items completed vs pending and changes to implementation details, if any

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.

Comments inline. Need to do a second pass on the PatchInstaller because of degree of changes and overall risk.

SathishMSFT
SathishMSFT previously approved these changes May 10, 2023
(a) Addressing PR comments
(b) Adding some comments in the code.
@kjohn-msft
Copy link
Collaborator

kjohn-msft commented May 14, 2023

@GAURAVRAMRAKHYANI please get latest, and get sign-offs on Monday from @SathishMSFT and @nikhim-um if the code is all done (if all Rajasi's comments are addressed). @rane-rajasi please plan on reviewing this daily and focus on removing regression risk. @rane-rajasi you may make any code-organization comments you are/were planning to leave out of this PR and DIY if deemed absolutely necessary to avoid turn-around loops here.

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.

There's only one comment pending resolution, everything else looks good. Have tagged you in that open comment and also resolved all of my earlier feedbacks to make it easier to access the open one. Please take a look at it

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.

Relaxed bar to ensure PR merge. One item must be addressed prior to deployment.

@kjohn-msft kjohn-msft merged commit 1629d6a into master May 18, 2023
@kjohn-msft kjohn-msft deleted the garamrak-BatchPatching branch May 18, 2023 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants