Skip to content
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

[master] 3rd salt con #66636

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

madavarajK
Copy link

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, 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.

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.

Madavaraj17 added 3 commits June 12, 2024 09:03
…g entry

- Replace print statements with logging using log for consistency
- Add specific exception handling for ClientError, NoCredentialsError, and PartialCredentialsError
- Update the changelog to document the changes
- Create tests for logging using caplog to ensure proper logging behavior
@madavarajK madavarajK requested a review from a team as a code owner June 13, 2024 12:45
@madavarajK madavarajK requested a review from dwoz June 13, 2024 12:45
@salt-project-bot-prod-environment salt-project-bot-prod-environment bot changed the title 3rd salt con [master] 3rd salt con Jun 13, 2024
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.

None yet

2 participants