Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
This pull request enhances error handling and logging in the tools/utils/repo.py module. It also adds corresponding tests and updates the changelog.
Changes
Logging: Replaced print statements with logging using log for consistency. Utilized logger's built-in formatting capabilities.
Error Handling: Added specific exception handling for ClientError, NoCredentialsError, and PartialCredentialsError to improve error messaging and control flow.
Changelog: Updated CHANGELOG.md to document these improvements.
Tests: Created tests/test_repo.py to add tests for the logging functionality using caplog.
Detailed Changes
Logging Enhancements
Replaced print statements with log for better logging practices.
Used logger's formatting capabilities instead of explicit string formatting.
Error Handling Improvements
Added handling for ClientError to log specific S3-related issues.
Added handling for NoCredentialsError and PartialCredentialsError to log credential-related issues.
Added a generic exception handler to log unexpected errors.
Changelog Update
Documented the changes in CHANGELOG.md under the Unreleased section.
Tests
Created a new test file tests/test_repo.py.
Added tests to verify proper logging behavior using caplog.
Included tests for different exception scenarios to ensure robust error handling and logging.
Testing
Verified that the get_repo_json_file_contents function handles different exceptions correctly and logs appropriate messages.
Ensured that the changes do not affect the existing functionality.
Added Tests that use caplog to check that logging occurs as expected during different scenarios.
Additional Notes
These changes aim to improve the robustness and maintainability of the code, making it easier to debug and understand. The logging ensures that detailed information is available when issues arise, facilitating quicker resolution.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Summary
This pull request enhances error handling and logging in the
tools/utils/repo.py
module. It also adds corresponding tests and updates the changelog.Changes
log
for consistency. Utilized logger's built-in formatting capabilities.ClientError
,NoCredentialsError
, andPartialCredentialsError
to improve error messaging and control flow.CHANGELOG.md
to document these improvements.tests/test_repo.py
to add tests for the logging functionality usingcaplog
.Detailed Changes
Logging Enhancements
log
for better logging practices.Error Handling Improvements
ClientError
to log specific S3-related issues.NoCredentialsError
andPartialCredentialsError
to log credential-related issues.Changelog Update
CHANGELOG.md
under the Unreleased section.Tests
tests/test_repo.py
.caplog
.Testing
get_repo_json_file_contents
function handles different exceptions correctly and logs appropriate messages.caplog
to check that logging occurs as expected during different scenarios.Additional Notes
These changes aim to improve the robustness and maintainability of the code, making it easier to debug and understand. The logging ensures that detailed information is available when issues arise, facilitating quicker resolution.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes/No
Please review Salt's Contributing Guide for best practices, including the PR Guidelines.
See GitHub's page on GPG signing for more information about signing commits with GPG.