Skip to content

Commit

Permalink
Bootstrap with force (#187)
Browse files Browse the repository at this point in the history
Instead of relying on the existence of old router user to cleanup router
from cluster metadata, force bootstrap so that the metadata does not
need to be cleaned up.

Fixes canonical/mysql-k8s-operator#345. The
issue was that the router charm would delete the user & router metadata,
but that only the user deletion would go through. Then, on the router
charm's next hook, the bootstrap failed because the metadata was not
cleaned up.

Additional context:
https://chat.canonical.com/canonical/pl/temrphcp3in5xqftkaxgowqtkr
  • Loading branch information
carlcsaposs-canonical authored Jan 10, 2024
1 parent 328194b commit d89b0f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,13 @@ def _router_id(self) -> str:
return f"{socket.getfqdn()}::system"

def _cleanup_after_upgrade_or_potential_container_restart(self) -> None:
"""Remove Router cluster metadata & user after upgrade or (potential) container restart.
"""Remove Router user after upgrade or (potential) container restart.
(On Kubernetes, storage is not persisted on container restart—MySQL Router's config file is
deleted. Therefore, MySQL Router needs to be bootstrapped again.)
"""
if user_info := self.shell.get_mysql_router_user_for_unit(self._charm.unit.name):
logger.debug("Cleaning up after upgrade or container restart")
self.shell.remove_router_from_cluster_metadata(user_info.router_id)
self.shell.delete_user(user_info.username)
logger.debug("Cleaned up after upgrade or container restart")

Expand All @@ -176,6 +175,7 @@ def _get_bootstrap_command(self, password: str) -> typing.List[str]:
+ ":"
+ self._connection_info.port,
"--strict",
"--force",
"--conf-set-option",
"http_server.bind_address=127.0.0.1",
"--conf-use-gr-notifications",
Expand Down

0 comments on commit d89b0f8

Please sign in to comment.