Skip to content

Commit 43188b4

Browse files
committed
Add extended attribute to get-cluster-status
This changes from the default boolean that was being used internally to what mysql expects. The values between 0 and 3 are valid.
1 parent 13f06ad commit 43188b4

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

actions.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ get-cluster-status:
99
default: False
1010
description: Whether to fetch the cluster or cluster-set status.
1111
Possible values are False (default) or True.
12+
extended:
13+
type: integer
14+
default: 0
15+
description: The extended attribute for cluster-status, the default value 0.
16+
Possible values are 0, 1, 2, 3
1217

1318
get-password:
1419
description: Fetch the system user's password, which is used by charm.

lib/charms/mysql/v0/mysql.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def wait_until_mysql_connection(self) -> None:
127127
# Increment this major API version when introducing breaking changes
128128
LIBAPI = 0
129129

130-
LIBPATCH = 93
130+
LIBPATCH = 94
131131

132132
UNIT_TEARDOWN_LOCKNAME = "unit-teardown"
133133
UNIT_ADD_LOCKNAME = "unit-add"
@@ -597,9 +597,14 @@ def _on_set_password(self, event: ActionEvent) -> None:
597597

598598
def _get_cluster_status(self, event: ActionEvent) -> None:
599599
"""Action used to retrieve the cluster status."""
600+
extended = event.params.get("extended", 0)
601+
if not 0 <= extended < 4:
602+
event.fail("Extended parameter outside valid range")
603+
return
604+
600605
if event.params.get("cluster-set"):
601606
logger.debug("Getting cluster set status")
602-
status = self._mysql.get_cluster_set_status(extended=0)
607+
status = self._mysql.get_cluster_set_status(extended=extended)
603608
else:
604609
logger.debug("Getting cluster status")
605610
status = self._mysql.get_cluster_status()
@@ -2378,7 +2383,7 @@ def instance_belongs_to_cluster(self, unit_label: str) -> bool:
23782383
retry=retry_if_exception_type(TimeoutError),
23792384
)
23802385
def get_cluster_status(
2381-
self, from_instance: str | None = None, extended: bool | None = False
2386+
self, from_instance: str | None = None, extended: int | None = 0
23822387
) -> dict | None:
23832388
"""Get the cluster status dictionary."""
23842389
options = {"extended": extended}

src/upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _online_instances(status_dict: dict) -> int:
115115
if not item.get("instanceerrors", [])
116116
].count("online")
117117

118-
if cluster_status := self.charm._mysql.get_cluster_status(extended=True):
118+
if cluster_status := self.charm._mysql.get_cluster_status(extended=1):
119119
if _online_instances(cluster_status) < self.charm.app.planned_units():
120120
# case any not fully online unit is found
121121
raise ClusterNotReadyError(

tests/unit/test_mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ def test_get_cluster_status(self, _run_mysqlsh_script):
10331033
self.mysql.get_cluster_status()
10341034
expected_commands = "\n".join((
10351035
"cluster = dba.get_cluster('test_cluster')",
1036-
"print(cluster.status({'extended': False}))",
1036+
"print(cluster.status({'extended': 0}))",
10371037
))
10381038
_run_mysqlsh_script.assert_called_once_with(
10391039
expected_commands,

0 commit comments

Comments
 (0)