Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ get-cluster-status:
default: False
description: Whether to fetch the cluster or cluster-set status.
Possible values are False (default) or True.
extended:
type: integer
default: 0
description: The extended attribute for cluster-status, the default value 0.
Possible values are 0, 1, 2, 3

get-password:
description: Fetch the system user's password, which is used by charm.
Expand Down
11 changes: 8 additions & 3 deletions lib/charms/mysql/v0/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def wait_until_mysql_connection(self) -> None:
# Increment this major API version when introducing breaking changes
LIBAPI = 0

LIBPATCH = 93
LIBPATCH = 94

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

def _get_cluster_status(self, event: ActionEvent) -> None:
"""Action used to retrieve the cluster status."""
extended = event.params.get("extended", 0)
if not 0 <= extended < 4:
event.fail("Extended parameter outside valid range")
return

if event.params.get("cluster-set"):
logger.debug("Getting cluster set status")
status = self._mysql.get_cluster_set_status(extended=0)
status = self._mysql.get_cluster_set_status(extended=extended)
else:
logger.debug("Getting cluster status")
status = self._mysql.get_cluster_status()
Expand Down Expand Up @@ -2378,7 +2383,7 @@ def instance_belongs_to_cluster(self, unit_label: str) -> bool:
retry=retry_if_exception_type(TimeoutError),
)
def get_cluster_status(
self, from_instance: str | None = None, extended: bool | None = False
self, from_instance: str | None = None, extended: int | None = 0
) -> dict | None:
"""Get the cluster status dictionary."""
options = {"extended": extended}
Expand Down
2 changes: 1 addition & 1 deletion src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _online_instances(status_dict: dict) -> int:
if not item.get("instanceerrors", [])
].count("online")

if cluster_status := self.charm._mysql.get_cluster_status(extended=True):
if cluster_status := self.charm._mysql.get_cluster_status(extended=1):
if _online_instances(cluster_status) < self.charm.app.planned_units():
# case any not fully online unit is found
raise ClusterNotReadyError(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ def test_get_cluster_status(self, _run_mysqlsh_script):
self.mysql.get_cluster_status()
expected_commands = "\n".join((
"cluster = dba.get_cluster('test_cluster')",
"print(cluster.status({'extended': False}))",
"print(cluster.status({'extended': 0}))",
))
_run_mysqlsh_script.assert_called_once_with(
expected_commands,
Expand Down
Loading