-
Notifications
You must be signed in to change notification settings - Fork 11
Bugfix: Apply SSL expired cmd fix to RHEL images only #317
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
Open
feng-j678
wants to merge
13
commits into
master
Choose a base branch
from
Bugfix/apply_microsoft_repo_cmd_to_rhel_os_only
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
175c2ac
add function to check image is rhel
feng-j678 be0ce8d
add check for rhel iamge to perform ssl fix
feng-j678 f6b5da8
remove unused log
feng-j678 cbc552e
Merge branch 'master' of https://github.com/Azure/LinuxPatchExtension…
feng-j678 f9d6860
add image details function and prints
feng-j678 199f1d1
add ut for good ssl cert fix
feng-j678 e44df80
add ut for ssl fix
feng-j678 eabe3c7
update test_rhel7/8_image_with_security_plugin tests
feng-j678 ddc3555
add ut for extract_linux_distribution_os_info
feng-j678 b488dfc
update files with extract_linux_distribution_os_info
feng-j678 86c349d
reset env_layer files and refactor unt
feng-j678 8a1d02e
restore test_envlayer and test_yumpackagemanager
feng-j678 55e1046
fix ut restore mock
feng-j678 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,6 @@ def __init__(self, env_layer, execution_config, composite_logger, telemetry_writ | |
"Error: Cannot retrieve repository metadata (repomd.xml) for repository": self.fix_ssl_certificate_issue, | ||
"Error: Failed to download metadata for repo": self.fix_ssl_certificate_issue} | ||
|
||
self.yum_update_client_package = "sudo yum update -y --disablerepo='*' --enablerepo='*microsoft*'" | ||
|
||
self.package_install_expected_avg_time_in_seconds = 90 # As per telemetry data, the average time to install package is around 90 seconds for yum. | ||
|
||
def refresh_repo(self): | ||
|
@@ -141,7 +139,6 @@ def get_security_updates(self): | |
|
||
if not self.__is_image_rhel8_or_higher(): | ||
self.install_yum_security_prerequisite() | ||
|
||
out = self.invoke_package_manager(self.yum_check_security) | ||
security_packages, security_package_versions = self.extract_packages_and_versions(out) | ||
|
||
|
@@ -175,16 +172,24 @@ def get_other_updates(self): | |
return other_packages, other_package_versions | ||
|
||
def __is_image_rhel8_or_higher(self): | ||
# type: () -> bool | ||
""" Check if image is RHEL8+ return true else false """ | ||
if self.env_layer.platform.linux_distribution() is not None: | ||
if self.env_layer.platform.linux_distribution is not None: | ||
Comment on lines
-179
to
+177
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
os_offer, os_version, os_code = self.env_layer.platform.linux_distribution() | ||
|
||
if "Red Hat Enterprise Linux" in os_offer and int(os_version.split('.')[0]) >= 8: | ||
self.composite_logger.log_debug("[YPM] RHEL version >= 8 detected. [DetectedVersion={0}]".format(str(os_version))) | ||
return True | ||
|
||
return False | ||
|
||
|
||
def __is_image_rhel(self): | ||
# type: () -> bool | ||
""" Check if image is RHEL return true else false """ | ||
if self.env_layer.platform.linux_distribution is not None: | ||
os_offer, os_version, os_code = self.env_layer.platform.linux_distribution() | ||
if "Red Hat Enterprise Linux" in os_offer: | ||
return True | ||
return False | ||
|
||
def set_max_patch_publish_date(self, max_patch_publish_date=str()): | ||
pass | ||
|
||
|
@@ -893,23 +898,32 @@ def check_known_issues_and_attempt_fix(self, output): | |
return False | ||
|
||
def fix_ssl_certificate_issue(self): | ||
command = self.yum_update_client_package | ||
self.composite_logger.log_debug("[Customer-environment-error] Updating client package to avoid errors from older certificates using command: [Command={0}]".format(str(command))) | ||
# type: () -> None | ||
""" Attempt to fix the SSL certificate issue by updating the client package """ | ||
if not self.__is_image_rhel(): | ||
error_msg = 'Customer environment error (expired SSL certs)' | ||
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.PACKAGE_MANAGER_FAILURE) | ||
raise Exception(error_msg, "[{0}]".format(Constants.ERROR_ADDED_TO_STATUS)) | ||
|
||
# Image is rhel, attempt to update the client package | ||
command = "sudo yum update -y --disablerepo='*' --enablerepo='*microsoft*'" | ||
self.composite_logger.log_debug("[YPM][Customer-environment-error] Updating client package to avoid errors from older certificates using command: [Command={0}]".format(str(command))) | ||
code, out = self.env_layer.run_command_output(command, False, False) | ||
|
||
if code != self.yum_exitcode_no_applicable_packages: | ||
error_msg = 'Customer environment error (expired SSL certs): [Command={0}][Code={1}]'.format(command,str(code)) | ||
error_msg = 'Customer environment error (expired SSL certs): [Command={0}][Code={1}]'.format(command, str(code)) | ||
self.composite_logger.log_error("{0}[Out={1}]".format(error_msg, out)) | ||
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.PACKAGE_MANAGER_FAILURE) | ||
raise Exception(error_msg, "[{0}]".format(Constants.ERROR_ADDED_TO_STATUS)) | ||
else: | ||
self.composite_logger.log_verbose("\n\n==[SUCCESS]===============================================================") | ||
self.composite_logger.log_debug("Client package update complete. [Code={0}][Out={1}]".format(str(code), out)) | ||
self.composite_logger.log_verbose("==========================================================================\n\n") | ||
|
||
def log_error_mitigation_failure(self, output, raise_on_exception=True): | ||
self.composite_logger.log_error("[YPM] Customer Environment Error: Unable to auto-mitigate known issue. Please investigate and address. [Out={0}]".format(output)) | ||
if raise_on_exception: | ||
error_msg = 'Customer environment error (Unable to auto-mitigate known issue): [Out={0}]'.format(output) | ||
error_msg = '[YMP] Customer environment error (Unable to auto-mitigate known issue): [Out={0}]'.format(output) | ||
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.PACKAGE_MANAGER_FAILURE) | ||
raise Exception(error_msg, "[{0}]".format(Constants.ERROR_ADDED_TO_STATUS)) | ||
# endregion | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Revert - avoid file touches that are not really changes