Skip to content

Commit 89b6eb2

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 2bd2bcc commit 89b6eb2

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

actions.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
get-cluster-status:
55
description: Get cluster status information
6+
params:
7+
extended:
8+
type: integer
9+
description: The extended attriute for cluster-status, the default value 0.
10+
possible values - 0, 1, 2, 3
611

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

lib/charms/mysql/v0/mysql.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ def _on_set_password(self, event: ActionEvent) -> None:
494494

495495
def _get_cluster_status(self, event: ActionEvent) -> None:
496496
"""Action used to retrieve the cluster status."""
497-
if status := self._mysql.get_cluster_status():
497+
extended = event.params.get("extended") or 0
498+
499+
if status := self._mysql.get_cluster_status(extended):
498500
event.set_results(
499501
{
500502
"success": True,
@@ -1422,7 +1424,7 @@ def is_instance_in_cluster(self, unit_label: str) -> bool:
14221424
stop=stop_after_attempt(3),
14231425
retry=retry_if_exception_type(TimeoutError),
14241426
)
1425-
def get_cluster_status(self, extended: Optional[bool] = False) -> Optional[dict]:
1427+
def get_cluster_status(self, extended: Optional[int] = 0) -> Optional[dict]:
14261428
"""Get the cluster status.
14271429
14281430
Executes script to retrieve cluster status.

src/upgrade.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _online_instances(status_dict: dict) -> int:
110110
if not item.get("instanceerrors", [])
111111
].count("online")
112112

113-
if cluster_status := self.charm._mysql.get_cluster_status(extended=True):
113+
if cluster_status := self.charm._mysql.get_cluster_status(extended=1):
114114
if _online_instances(cluster_status) < self.charm.app.planned_units():
115115
# case any not fully online unit is found
116116
raise ClusterNotReadyError(

tests/unit/test_mysql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ def test_get_cluster_status(self, _run_mysqlsh_script):
731731
(
732732
"shell.connect('clusteradmin:[email protected]')",
733733
"cluster = dba.get_cluster('test_cluster')",
734-
"print(cluster.status({'extended': False}))",
734+
"print(cluster.status({'extended': 0}))",
735735
)
736736
)
737737
_run_mysqlsh_script.assert_called_once_with(expected_commands, timeout=30)

0 commit comments

Comments
 (0)