-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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. |
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"] |
There was a problem hiding this comment.
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.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
Port of canonical/postgresql-operator#672
Adds logic to update the number of synchronous standbys and sets all replicas to sync.