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

[MISC] Suppress oversee users in standby clusters #507

Merged
merged 7 commits into from
Jun 25, 2024

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Jun 24, 2024

Stop deleting managed users without a relation. This is necessary to keep all credentials working when there is a switchover to standby cluster.

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

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

Project coverage is 69.72%. Comparing base (165d04c) to head (1b589c8).

Files Patch % Lines
src/relations/postgresql_provider.py 60.00% 3 Missing and 1 partial ⚠️
src/relations/async_replication.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #507      +/-   ##
==========================================
- Coverage   69.78%   69.72%   -0.07%     
==========================================
  Files          11       11              
  Lines        2866     2870       +4     
  Branches      507      508       +1     
==========================================
+ Hits         2000     2001       +1     
- Misses        761      763       +2     
- Partials      105      106       +1     

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

@dragomirp dragomirp force-pushed the suppress-oversee-user branch from 187bb8e to 8e9d9ee Compare June 24, 2024 19:49
@dragomirp dragomirp force-pushed the suppress-oversee-user branch from 911a659 to ba1a260 Compare June 24, 2024 22:51
@dragomirp dragomirp force-pushed the suppress-oversee-user branch from fd8a477 to 9bafcf6 Compare June 25, 2024 02:03
@@ -481,7 +482,7 @@ def is_primary_cluster(self) -> bool:
return self.charm.app == self._get_primary_cluster()

def _on_async_relation_broken(self, _) -> None:
if "departing" in self.charm._peers.data[self.charm.unit]:
if not self.charm._peers or "departing" in self.charm._peers.data[self.charm.unit]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seen it fail in CI.

Comment on lines +231 to +243
@pytest.mark.group(1)
@markers.juju3
@pytest.mark.abort_on_fail
async def test_get_data_integrator_credentials(
ops_test: OpsTest,
):
unit = ops_test.model.applications[DATA_INTEGRATOR_APP_NAME].units[0]
action = await unit.run_action(action_name="get-credentials")
result = await action.wait()
global data_integrator_credentials
data_integrator_credentials = result.results


Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just gets the credentials from data integrator.

@@ -193,6 +193,7 @@ def _configure_standby_cluster(self, event: RelationChangedEvent) -> bool:
filename = f"{POSTGRESQL_DATA_PATH}-{str(datetime.now()).replace(' ', '-').replace(':', '-')}.tar.gz"
subprocess.check_call(f"tar -zcf {filename} {POSTGRESQL_DATA_PATH}".split())
logger.warning("Please review the backup file %s and handle its removal", filename)
self.charm.app_peer_data["suppress-oversee-users"] = "true"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Set a flag when a cluster is made a standby

Comment on lines +140 to +141
delete_user = "suppress-oversee-users" not in self.charm.app_peer_data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the cluster is or was a standby, it will stop deleting relation users.

@dragomirp
Copy link
Contributor Author

Currently there's no way to clear up the flag. Action to clear it up was moved to #509

@dragomirp dragomirp marked this pull request as ready for review June 25, 2024 12:05
Copy link
Member

@marceloneppel marceloneppel left a comment

Choose a reason for hiding this comment

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

It looks great! Thank you so much @dragomirp!

@dragomirp dragomirp merged commit 713f6e4 into main Jun 25, 2024
72 of 73 checks passed
@dragomirp dragomirp deleted the suppress-oversee-user branch June 25, 2024 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants