-
Notifications
You must be signed in to change notification settings - Fork 22
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-6484] Add scope to promote to primary #850
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #850 +/- ##
==========================================
- Coverage 75.48% 75.45% -0.03%
==========================================
Files 12 12
Lines 3157 3178 +21
Branches 471 475 +4
==========================================
+ Hits 2383 2398 +15
- Misses 632 635 +3
- Partials 142 145 +3 ☔ View full report in Codecov by Sentry. |
actions.yaml
Outdated
params: | ||
scope: | ||
type: string | ||
default: unit |
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.
Assuming default unit, based on proposal in DA139. Will set to the current status of DA139 after the stable release.
if not wait: | ||
return |
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.
When running the action we shouldn't wait for the switchover itself to happen.
@@ -597,8 +597,12 @@ def switchover(self, candidate: str | None = None) -> None: | |||
|
|||
# Check whether the switchover was unsuccessful. | |||
if r.status_code != 200: | |||
logger.warning(f"Switchover call failed with code {r.status_code} {r.text}") |
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.
Log Patroni's error code, the body should contain the reason.
def promote_primary_unit(self, event: ActionEvent) -> None: | ||
"""Handles promote to primary for unit scope.""" | ||
if event.params.get("force"): | ||
event.fail("Suprerfluous force flag with unit scope") |
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.
No RAFT, so no need to force.
try: | ||
self._patroni.switchover(self.unit.name, wait=False) | ||
except SwitchoverFailedError: | ||
event.fail("Switchover failed or timed out, check the logs for details") |
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.
If wait=False
, can this catched error be due to time out at all? (as implied by the error message)
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.
LGTM
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.
LGTM to sync VM with K8s.
IMHO we should discuss promote-to-primary => promote-unit/cluster.
Update the
promote-to-primary
action to accept scope and promote units.