Skip to content

Commit

Permalink
Possible fix for #89 so it doesn't crash when trying to add a group m…
Browse files Browse the repository at this point in the history
…ember to replication panel
  • Loading branch information
charles-001 committed Dec 27, 2024
1 parent 43ea6db commit b2eeb8e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 39 deletions.
16 changes: 7 additions & 9 deletions dolphie/Dolphie.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def db_connect(self):
def configure_mysql_variables(self):
global_variables = self.global_variables

# Galera cluster check
self.galera_cluster = global_variables.get("wsrep_on") == "ON" or bool(
global_variables.get("wsrep_cluster_address")
)

self.host_distro, self.connection_source_alt = self.determine_distro_and_connection_source_alt(global_variables)

# For RDS and Azure, we will use the host specified to connect with since hostname isn't related to the endpoint
Expand All @@ -214,11 +219,6 @@ def configure_mysql_variables(self):
self.performance_schema_enabled = global_variables.get("performance_schema") == "ON"
self.use_performance_schema_for_processlist = self.performance_schema_enabled

# Galera cluster check
self.galera_cluster = global_variables.get("wsrep_on") == "ON" or bool(
global_variables.get("wsrep_cluster_address")
)

# Cluster type detection
cluster_type = self.group_replication_data.get("cluster_type")
if cluster_type == "ar":
Expand All @@ -236,14 +236,12 @@ def configure_mysql_variables(self):
def determine_distro_and_connection_source_alt(
self, global_variables: Dict[str, Union[int, str]]
) -> Tuple[str, ConnectionSource]:
version_comment = global_variables.get("version_comment", "").casefold()

is_percona = "percona" in global_variables.get("version_comment", "").casefold()
is_mariadb = any(variable.startswith("aria_") for variable in global_variables)
is_rds = "rdsdb" in self.global_variables.get("basedir", "").casefold()
is_aurora = self.global_variables.get("aurora_version")
is_azure = self.global_variables.get("aad_auth_only")
is_galera_cluster = "cluster" in version_comment
is_percona = "percona" in version_comment
is_galera_cluster = self.galera_cluster

# MariaDB
if is_mariadb:
Expand Down
72 changes: 42 additions & 30 deletions dolphie/Panels/Replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from rich.align import Align
from rich.style import Style
from rich.table import Table
from textual._node_list import DuplicateIds
from textual.containers import ScrollableContainer
from textual.widgets import Static

Expand Down Expand Up @@ -70,17 +71,20 @@ def create_clusterset_panel():
if clusterset_name in existing_clusterset_components:
existing_clusterset_components[clusterset_name].update(table)
else:
tab.clusterset_grid.mount(
ScrollableContainer(
Static(
table,
id=f"clusterset_{clusterset_name}_{tab.id}",
classes=f"clusterset_{tab.id}",
),
id=f"clusterset_container_{clusterset_name}_{tab.id}",
classes=f"clusterset_container_{tab.id} clusterset_container",
try:
tab.clusterset_grid.mount(
ScrollableContainer(
Static(
table,
id=f"clusterset_{clusterset_name}_{tab.id}",
classes=f"clusterset_{tab.id}",
),
id=f"clusterset_container_{clusterset_name}_{tab.id}",
classes=f"clusterset_container_{tab.id} clusterset_container",
)
)
)
except DuplicateIds:
tab.dolphie.app.notify(f"Failed to mount clusterset [highlight]{clusterset_name}", severity="error")

# Remove ClusterSets that no longer exist
for clusterset_name, container in existing_clusterset_components.items():
Expand Down Expand Up @@ -137,17 +141,20 @@ def create_group_replication_panel():
if member_id in existing_member_components:
existing_member_components[member_id].update(member_table)
else:
tab.group_replication_grid.mount(
ScrollableContainer(
Static(
member_table,
id=f"member_{member_id}_{tab.id}",
classes=f"member_{tab.id}",
),
id=f"member_container_{member_id}_{tab.id}",
classes=f"member_container_{tab.id} member_container",
try:
tab.group_replication_grid.mount(
ScrollableContainer(
Static(
member_table,
id=f"member_{member_id}_{tab.id}",
classes=f"member_{tab.id}",
),
id=f"member_container_{member_id}_{tab.id}",
classes=f"member_container_{tab.id} member_container",
)
)
)
except DuplicateIds:
tab.dolphie.app.notify(f"Failed to mount member [highlight]{member_info['host']}", severity="error")

# Remove members that no longer exist
for member_id, container in existing_member_components.items():
Expand Down Expand Up @@ -262,17 +269,22 @@ def create_replica_panel(tab: Tab):
if replica.row_key in existing_replica_components:
existing_replica_components[replica.row_key].update(replica.table)
else:
tab.replicas_grid.mount(
ScrollableContainer(
Static(
replica.table,
id=f"replica_{replica.row_key}_{tab.id}",
classes=f"replica_{tab.id}",
),
id=f"replica_container_{replica.row_key}_{tab.id}",
classes=f"replica_container_{tab.id} replica_container",
try:
tab.replicas_grid.mount(
ScrollableContainer(
Static(
replica.table,
id=f"replica_{replica.row_key}_{tab.id}",
classes=f"replica_{tab.id}",
),
id=f"replica_container_{replica.row_key}_{tab.id}",
classes=f"replica_container_{tab.id} replica_container",
)
)
except DuplicateIds:
tab.dolphie.app.notify(
f"Failed to mount replica [highlight]{replica.host}:{replica.port}", severity="error"
)
)

# Remove replicas that no longer exist
for replica_id, replica_container in existing_replica_components.items():
Expand Down

0 comments on commit b2eeb8e

Please sign in to comment.