Skip to content

Comments

feat: multiple Patroni primaries alert#1282

Open
Deezzir wants to merge 3 commits intocanonical:16/edgefrom
Deezzir:patroni-multiple-primaries-16
Open

feat: multiple Patroni primaries alert#1282
Deezzir wants to merge 3 commits intocanonical:16/edgefrom
Deezzir:patroni-multiple-primaries-16

Conversation

@Deezzir
Copy link
Contributor

@Deezzir Deezzir commented Feb 17, 2026

Issue

There is no alert that would check for multiple leaders. This explicit alert will help detect a split-brain occurrence.

Solution

  1. PatroniMultipleLeaders - fires if multiple leaders are detected.
image
  1. PatroniPrimaryAndStandbyLeader -fires if the cluster has both primary and standby leaders at the same time

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

Closes: canonical/postgresql-operator#1151

Signed-off-by: Deezzir <yurii.kondrakov@canonical.com>
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.97%. Comparing base (f2aeb85) to head (732821c).

❌ Your project check has failed because the head coverage (68.97%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff            @@
##           16/edge    #1282   +/-   ##
========================================
  Coverage    68.97%   68.97%           
========================================
  Files           16       16           
  Lines         3816     3816           
  Branches       575      575           
========================================
  Hits          2632     2632           
  Misses         982      982           
  Partials       202      202           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

marceloneppel
marceloneppel previously approved these changes Feb 18, 2026
@marceloneppel
Copy link
Member

Thanks for the great contribution again, @Deezzir!

@marceloneppel marceloneppel requested review from a team, carlcsaposs-canonical, dragomirp, juju-charm-bot and taurus-forever and removed request for a team February 18, 2026 20:21
@Deezzir Deezzir marked this pull request as ready for review February 18, 2026 21:46
@Deezzir
Copy link
Contributor Author

Deezzir commented Feb 19, 2026

@carlcsaposs-canonical @marceloneppel, may I ask you to retrigger the CI so we can merge? Thanks!

Signed-off-by: Deezzir <yurii.kondrakov@canonical.com>
LABELS = {{ $labels }}

- alert: PatroniPrimaryAndStandbyLeader
expr: 'sum by (scope) (patroni_master) == 1 and sum by (scope) (patroni_standby_leader) == 1'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expr: 'sum by (scope) (patroni_master) == 1 and sum by (scope) (patroni_standby_leader) == 1'
expr: 'sum by (scope) (patroni_master) > 0 and sum by (scope) (patroni_standby_leader) > 0'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is okay to leave ==1, the case where we have multiple of each is already covered by another alert - PatroniMultipleLeaders, so it is safe to leave it that way.

Copy link
Member

Choose a reason for hiding this comment

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

Both approaches work for me. The PatroniPrimaryAndStandbyLeader alert is already a safety net for a scenario that shouldn't happen in practice (primary and standby leaders are roles from different cluster types, so they shouldn't coexist within the same scope). The cases where > 0 and == 1 differ are even more unlikely on top of that. I'm fine with keeping == 1 as-is.

@carlcsaposs-canonical carlcsaposs-canonical added the enhancement New feature, UI change, or workload upgrade label Feb 20, 2026
Signed-off-by: Deezzir <yurii.kondrakov@canonical.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants