For yum package manager only, sometimes VM gets rebooted in install updates job even though reboot is not required #210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
As per the function do_processes_require_restart in YumPackageManager.py, the output of "sudo yum ps" is parsed to check if there are any processes and if there is any then True is returned in the function do_processes_require_restart
There is issue in parsing logic.
Example logs when true is returned when it should return false:
DEBUG: - Output from package manager:
| Loaded plugins: enabled_repos_upload, package_upload, product-id, ps, search-
| : disabled-repos, subscription-manager
|
| This system is not registered with an entitlement server. You can use subscription-manager to register.
|
| pid proc CPU RSS State uptime
| ps
| Uploading Enabled Repositories Report
| Cannot upload enabled repos report, is this client registered?
VERBOSE: ==========================================================================
DEBUG: - Inapplicable line: Loaded plugins: enabled_repos_upload, package_upload, product-id, ps, search-
DEBUG: - Inapplicable line: : disabled-repos, subscription-manager
DEBUG: - Inapplicable line:
DEBUG: - Inapplicable line: This system is not registered with an entitlement server. You can use subscription-manager to register.
DEBUG: - Inapplicable line:
DEBUG: - Process list started: pid proc CPU RSS State uptime
DEBUG: - Inapplicable line: ps
DEBUG: - Inapplicable line: Uploading Enabled Repositories Report
DEBUG: - Applicable line: Cannot upload enabled repos report, is this client registered?
2023-06-24T12:09:52Z> - Processes requiring restart (1): [upload (Cannot), ]
DEBUG: - Reboot required debug flags (yum): False, True.
DEBUG: Setting reboot pending status. [RebootPendingStatus=True]
Following line is marked applicable but actually it is not for any process, it is error message line:
Cannot upload enabled repos report, is this client registered?
So, in this case reboot required is returned by the function but actually reboot is not required because above line is not for any process, it is error message.
Root Cause:
In parsing, it is checked if there are at least 7 strings in the line. If there are at least 7 strings then it is assumed as a process detail. But this line could be error line as per above example.
Fix:
Adding one more check that first string should be integer because first string should be Process ID and hence it should be integer.
Testing
(a) Testing done for case when first string of the line is integer because that is process detail.
(b) Testing done for scenario when there is no process line. Hence no reboot required.
Added sample output in the test type "SadPath" so that this scenario is covered in test case test_do_processes_require_restart in the file Test_YumPackageManager.py.