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-6484] Add scope to promote to primary #850

Merged
merged 5 commits into from
Feb 19, 2025
Merged

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Feb 6, 2025

Update the promote-to-primary action to accept scope and promote units.

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

Attention: Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.45%. Comparing base (842aa47) to head (8ab236a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/charm.py 76.47% 2 Missing and 2 partials ⚠️
src/patroni.py 71.42% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

actions.yaml Outdated
params:
scope:
type: string
default: unit
Copy link
Contributor Author

@dragomirp dragomirp Feb 6, 2025

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.

Comment on lines +603 to +604
if not wait:
return
Copy link
Contributor Author

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}")
Copy link
Contributor Author

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")
Copy link
Contributor Author

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.

@dragomirp dragomirp marked this pull request as ready for review February 7, 2025 12:47
@dragomirp dragomirp requested review from a team, taurus-forever, marceloneppel and lucasgameiroborges and removed request for a team February 7, 2025 12:47
try:
self._patroni.switchover(self.unit.name, wait=False)
except SwitchoverFailedError:
event.fail("Switchover failed or timed out, check the logs for details")
Copy link
Contributor

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)

Copy link
Contributor

@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

@dragomirp dragomirp added the enhancement New feature, UI change, or workload upgrade label Feb 14, 2025
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.

LGTM to sync VM with K8s.
IMHO we should discuss promote-to-primary => promote-unit/cluster.

@dragomirp dragomirp merged commit c9f6554 into main Feb 19, 2025
96 checks passed
@dragomirp dragomirp deleted the dpe-6484-promote-scope branch February 19, 2025 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, UI change, or workload upgrade Libraries: Out of sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants