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-5827] Set all nodes to synchronous replicas #784

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

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Nov 21, 2024

Port of canonical/postgresql-operator#672

Adds logic to update the number of synchronous standbys and sets all replicas to sync.

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 61.11111% with 7 lines in your changes missing coverage. Please review.

Project coverage is 75.39%. Comparing base (d8f8226) to head (2d5ab35).

Files with missing lines Patch % Lines
src/charm.py 25.00% 6 Missing ⚠️
src/patroni.py 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #784      +/-   ##
==========================================
- Coverage   75.48%   75.39%   -0.10%     
==========================================
  Files          12       12              
  Lines        3121     3138      +17     
  Branches      475      478       +3     
==========================================
+ Hits         2356     2366      +10     
- Misses        622      628       +6     
- Partials      143      144       +1     

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

@dragomirp dragomirp marked this pull request as ready for review November 21, 2024 23:14
Comment on lines +513 to +528
async def get_leader(model: Model, application_name: str) -> str:
"""Get the standby leader name.

Args:
model: the model instance.
application_name: the name of the application to get the value for.

Returns:
the name of the standby leader.
"""
status = await model.get_status()
first_unit_ip = list(status["applications"][application_name]["units"].values())[0]["address"]
cluster = get_patroni_cluster(first_unit_ip)
for member in cluster["members"]:
if member["role"] == "leader":
return member["name"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

get_primary from the main helpers is not model aware.

Comment on lines -436 to -438
new_sync_standby = await get_sync_standby(first_model, DATABASE_APP_NAME)
logger.info(f"New sync-standby: {new_sync_standby}")
assert new_sync_standby != sync_standby, "Sync-standby is the same as before"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sync standby will not change, since all the replicas are sync standbys.

@dragomirp dragomirp requested review from a team, taurus-forever, marceloneppel and lucasgameiroborges and removed request for a team November 21, 2024 23:18
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.

The great job done! Thank you!

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.

4 participants