Skip to content

Conversation

@sinclert-canonical
Copy link
Contributor

@sinclert-canonical sinclert-canonical commented Dec 9, 2025

This PR removes a whole horizontal slice of the charm code, to rely on mysql-shell-client package.

Exceptions to this extraction are:

  • The creation of the MySQL Router roles (see code), as providing admin privileges to such roles is a bad pattern.
  • The creation of the MySQL Router user (see code), as its only consumer will be removed in MySQL 8.4.
  • The configuration of the charm system users (see code), as it is extremely specific to how we do things.

Highlights:

  • All hard-coded MySQL instance roles have been replaced by constants (when not comparing to existing data-bags).
  • All hard-coded MySQL instance states have been replaced by constants (when not comparing to existing data-bags).
  • Unified ways to count the number of cluster members in a given state (see previous method 1, method 2).
  • Unified ways to kill open connections (see previous method 1, method 2).
  • Removed lock_instance argument from add_instance_to_cluster charm lib function.
  • Removed lock_instance argument from remove_instance_to_cluster charm lib function.

Review strategy

Given the amount of changes proposed on this PR, I recommend reviewing commit by commit. When reaching 3d32f6f, please compared side-by-side:

@sinclert-canonical sinclert-canonical added the enhancement New feature, UI change, or workload upgrade label Dec 9, 2025
@github-actions github-actions bot added the Libraries: Out of sync The charm libs used are out-of-sync label Dec 9, 2025
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch 15 times, most recently from 770c1c2 to 045ea49 Compare December 16, 2025 13:24
@sinclert-canonical sinclert-canonical marked this pull request as ready for review December 16, 2025 16:52
Copy link
Contributor

@paulomach paulomach left a comment

Choose a reason for hiding this comment

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

Great work, I like the direction this is going.
out of a couple comments just one is a blocker (about admin port), otherise lgtm

@@ -723,12 +731,14 @@ def cluster_initialized(self) -> bool:
if not self.app_peer_data.get("cluster-name"):
return False

if self.unit_initialized():
return True

Copy link
Contributor

Choose a reason for hiding this comment

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

rebase on #729 merge

if host and ":" in host:
# strip port from address
host = host.split(":")[0]
def _build_cluster_tcp_executor(self, host: str, port: int = 3306) -> BaseExecutor:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use ADMIN_PORT for cluster executor?

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 real reason apart from: it has not been used for the clusteradmin user so far. Do you recall any reason why this was not the case? Maybe the cluster-admin user was not present on old versions of the charm? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

It was, but we were not doing much with it. In any case, we should use admin port, we don't want some cluster action to fail because we cannot connect to the a host

self.stop_mysql_exporter()
self.connect_mysql_exporter()

def _run_mysqlsh_script(
Copy link
Contributor

Choose a reason for hiding this comment

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

removal feels good :)

@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch 9 times, most recently from 6dc8195 to 8a51924 Compare December 19, 2025 12:13
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch 2 times, most recently from 7be5170 to f4c00a9 Compare December 19, 2025 15:41
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch from f4c00a9 to c443f86 Compare January 7, 2026 07:57
@sinclert-canonical sinclert-canonical marked this pull request as draft January 7, 2026 08:00
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch from 163237c to f56cff9 Compare January 8, 2026 11:32
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch from f56cff9 to 608ef38 Compare January 9, 2026 09:20
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch from 608ef38 to f529cf5 Compare January 9, 2026 09:27
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch from f529cf5 to 44c9dd5 Compare January 9, 2026 10:36
@sinclert-canonical sinclert-canonical force-pushed the sinclert/8916/mysql-shell-client branch from 44c9dd5 to 4f3d6e4 Compare January 9, 2026 14:41
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 The charm libs used are out-of-sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants