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

[MISC] Define charm utility properties #842

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sinclert-canonical
Copy link
Contributor

This PR defines a set of charm properties to reduce the chance of introducing typos when checking for specific keys in the app / unit data-bags, as well as reduce the cognitive load of logical statements.

The new properties are:

  • is_cluster_restoring_backup.
  • is_cluster_restoring_to_time.
  • is_unit_departing
  • is_unit_stopped.

The existing properties, now used throughout the codebase are:

  • is_cluster_initialised.

@sinclert-canonical sinclert-canonical force-pushed the sinclert/charm-data-properties branch from 09dc015 to 99586b8 Compare January 30, 2025 11:27
@sinclert-canonical sinclert-canonical force-pushed the sinclert/charm-data-properties branch from 99586b8 to b339193 Compare January 30, 2025 11:43
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.

Project coverage is 75.63%. Comparing base (02fc431) to head (b339193).

Files with missing lines Patch % Lines
src/backups.py 33.33% 0 Missing and 2 partials ⚠️
src/charm.py 88.23% 0 Missing and 2 partials ⚠️
src/relations/async_replication.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #842      +/-   ##
==========================================
+ Coverage   75.53%   75.63%   +0.09%     
==========================================
  Files          12       12              
  Lines        3115     3127      +12     
  Branches      466      466              
==========================================
+ Hits         2353     2365      +12     
  Misses        621      621              
  Partials      141      141              

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

Comment on lines +512 to +516
if not (self.charm.is_unit_stopped or self._is_following_promoted_cluster()) or not all(
"stopped" in self.charm._peers.data[unit]
or self.charm._peers.data[unit].get("unit-promoted-cluster-counter")
== self._get_highest_promoted_cluster_counter_value()
for unit in {*self.charm._peers.units, self.charm.unit}
for unit in self.charm._peers.units
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Review these lines carefully. I think I preserved the original logic

Copy link
Member

Choose a reason for hiding this comment

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

I think so too.

@sinclert-canonical sinclert-canonical marked this pull request as ready for review January 30, 2025 11:44
Copy link
Member

@lucasgameiroborges lucasgameiroborges left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants