-
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
[MISC] Suppress oversee user action #509
Draft
dragomirp
wants to merge
7
commits into
main
Choose a base branch
from
suppress-oversee-user-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e9d9ee
Suppress oversee users in standby clusters
dragomirp ba1a260
Add suppression test
dragomirp d0d956a
Wait for model to idle
dragomirp 9bafcf6
Test fixes
dragomirp 66521ab
Fix test
dragomirp 842b6b2
Merge branch 'main' into suppress-oversee-user
dragomirp 6dded68
Merge branch 'main' into suppress-oversee-user-action
dragomirp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2023 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
from ops.testing import Harness | ||
|
||
from charm import PostgresqlOperatorCharm | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def harness(): | ||
"""Set up the test.""" | ||
harness = Harness(PostgresqlOperatorCharm) | ||
harness.begin() | ||
upgrade_relation_id = harness.add_relation("upgrade", "postgresql") | ||
peer_relation_id = harness.add_relation("database-peers", "postgresql") | ||
for rel_id in (upgrade_relation_id, peer_relation_id): | ||
harness.add_relation_unit(rel_id, "postgresql/1") | ||
with harness.hooks_disabled(): | ||
harness.update_relation_data(upgrade_relation_id, "postgresql/1", {"state": "idle"}) | ||
yield harness | ||
harness.cleanup() | ||
|
||
|
||
def test_on_reenable_oversee_users(harness): | ||
# Fail if unit is not leader | ||
event = Mock() | ||
|
||
harness.charm.async_replication._on_reenable_oversee_users(event) | ||
|
||
event.fail.assert_called_once_with("Unit is not leader") | ||
event.fail.reset_mock() | ||
|
||
# Fail if peer data is not set | ||
with harness.hooks_disabled(): | ||
harness.set_leader() | ||
|
||
harness.charm.async_replication._on_reenable_oversee_users(event) | ||
|
||
event.fail.assert_called_once_with("Oversee users is not suppressed") | ||
event.fail.reset_mock() | ||
|
||
with harness.hooks_disabled(): | ||
harness.charm._peers.data[harness.charm.app].update({"suppress-oversee-users": "true"}) | ||
|
||
harness.charm.async_replication._on_reenable_oversee_users(event) | ||
assert harness.charm._peers.data[harness.charm.app] == {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
any reason why it is not run as part of
promote-to-primary
action?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 original issue was the promoting the replica cluster deleted users for relations to the old primary cluster, since there were no relations for them in the new primary cluster. We can't know if the client charms got rerelated to the new primary cluster, so we can't know when it's safe to reenable that functionality without user input.