salt
salt copied to clipboard
[master] 3rd salt con
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
-
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
, andPartialCredentialsError
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 usingcaplog
.
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
andPartialCredentialsError
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.
- [ ] Docs
- [ ] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
- [ ] Tests written/updated
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.