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

DPE-3688 fix KeyError when no ca-chain #403

Merged
merged 2 commits into from
Feb 28, 2024

Conversation

paulomach
Copy link
Contributor

Issue

backup fail due to dict key error

Solution

  • avoid KeyError when no ca chain
  • Increase coverage

Fixes #402

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 65.90%. Comparing base (30fffdd) to head (07c3ef3).

Files Patch % Lines
lib/charms/mysql/v0/s3_helpers.py 66.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #403      +/-   ##
==========================================
+ Coverage   65.34%   65.90%   +0.55%     
==========================================
  Files          17       17              
  Lines        3102     3103       +1     
  Branches      410      411       +1     
==========================================
+ Hits         2027     2045      +18     
+ Misses        948      929      -19     
- Partials      127      129       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tnx for tests!

@@ -86,7 +86,8 @@ def upload_content_to_s3(content: str, content_path: str, s3_parameters: Dict) -
)
return False
finally:
ca_file.close()
if ca_file:
ca_file.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we close right after ca_file.flush() ? Do you also want to close temp_file?
Anyway, this will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NamedTemporaryFile will be deleted once closed, hence closing it by the end.
The temp_file is used within a context manager (with), which closes it when exits the context

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should use with for ca_file as well

@@ -86,7 +86,8 @@ def upload_content_to_s3(content: str, content_path: str, s3_parameters: Dict) -
)
return False
finally:
ca_file.close()
if ca_file:
ca_file.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should use with for ca_file as well

@paulomach paulomach merged commit 8bf9fb3 into main Feb 28, 2024
40 of 41 checks passed
@paulomach paulomach deleted the fix/dpe-3688-fix-absent-dict-key branch February 28, 2024 15:31
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.

Backup test failing with backup-id not found
3 participants