Point ops to logs when cluster status is None
Do not report "None" as the cluster status, rather point operators to the logs to determine why this instance cannot access the cluster to obtain cluster status. Provide more information on the cluster's status in workgroup status. Change-Id: Ia6b9541e4827912d7a48c30a5eb17b2d87b611ae Closes-Bug: #1917337
This commit is contained in:
parent
3d1d93865c
commit
afad74831a
|
@ -1412,7 +1412,16 @@ class MySQLInnoDBClusterCharm(charms_openstack.charm.OpenStackCharm):
|
|||
|
||||
# Check the state of the cluster. nocache=True will get live info
|
||||
_cluster_status = self.get_cluster_status_summary(nocache=True)
|
||||
if not _cluster_status or "OK" not in _cluster_status:
|
||||
|
||||
# LP Bug #1917337
|
||||
if _cluster_status is None:
|
||||
ch_core.hookenv.status_set(
|
||||
"blocked",
|
||||
"Cluster is inaccessible from this instance. "
|
||||
"Please check logs for details.")
|
||||
return
|
||||
|
||||
if "OK" not in _cluster_status:
|
||||
ch_core.hookenv.status_set(
|
||||
"blocked",
|
||||
"MySQL InnoDB Cluster not healthy: {}"
|
||||
|
@ -1422,8 +1431,9 @@ class MySQLInnoDBClusterCharm(charms_openstack.charm.OpenStackCharm):
|
|||
# All is good. Report this instance's mode to workgroup status
|
||||
ch_core.hookenv.status_set(
|
||||
"active",
|
||||
"Unit is ready: Mode: {}"
|
||||
.format(self.get_cluster_instance_mode()))
|
||||
"Unit is ready: Mode: {}, {}"
|
||||
.format(self.get_cluster_instance_mode(),
|
||||
self.get_cluster_status_text()))
|
||||
|
||||
def check_mysql_connection(
|
||||
self, username=None, password=None, address=None):
|
||||
|
|
|
@ -1033,6 +1033,11 @@ class TestMySQLInnoDBClusterCharm(test_utils.PatchHelper):
|
|||
_conn_check.return_value = True
|
||||
_status = mock.MagicMock()
|
||||
_status.return_value = "OK"
|
||||
_status_mode = mock.MagicMock()
|
||||
_status_mode.return_value = "RO"
|
||||
_status_text = mock.MagicMock()
|
||||
_status_text.return_value = (
|
||||
"Cluster is ONLINE and can tolerate up to ONE failure.")
|
||||
self.patch_object(
|
||||
mysql_innodb_cluster.charms_openstack.charm.OpenStackCharm,
|
||||
"application_version")
|
||||
|
@ -1049,15 +1054,17 @@ class TestMySQLInnoDBClusterCharm(test_utils.PatchHelper):
|
|||
midbc.check_services_running = _check
|
||||
midbc.check_mysql_connection = _conn_check
|
||||
midbc.get_cluster_status_summary = _status
|
||||
midbc.get_cluster_status_text = _status
|
||||
midbc.get_cluster_instance_mode = _status
|
||||
midbc.get_cluster_status_text = _status_text
|
||||
midbc.get_cluster_instance_mode = _status_mode
|
||||
|
||||
midbc._assess_status()
|
||||
self.assertEqual(4, len(_check.mock_calls))
|
||||
_conn_check.assert_called_once_with()
|
||||
self.assertEqual(2, len(_status.mock_calls))
|
||||
_status.assert_called_once_with(nocache=True)
|
||||
self.status_set.assert_called_once_with(
|
||||
"active", "Unit is ready: Mode: OK")
|
||||
"active",
|
||||
"Unit is ready: Mode: RO, Cluster is ONLINE and can "
|
||||
"tolerate up to ONE failure.")
|
||||
|
||||
# First checks fail
|
||||
self.status_set.reset_mock()
|
||||
|
@ -1074,9 +1081,21 @@ class TestMySQLInnoDBClusterCharm(test_utils.PatchHelper):
|
|||
self.status_set.assert_called_once_with(
|
||||
"blocked", "MySQL is down on this instance")
|
||||
|
||||
# Cluster inaccessible from this unit
|
||||
self.status_set.reset_mock()
|
||||
_status.return_value = None
|
||||
_check.return_value = None, None
|
||||
_conn_check.return_value = True
|
||||
midbc._assess_status()
|
||||
self.status_set.assert_called_once_with(
|
||||
"blocked",
|
||||
"Cluster is inaccessible from this instance. "
|
||||
"Please check logs for details.")
|
||||
|
||||
# Cluster not healthy
|
||||
self.status_set.reset_mock()
|
||||
_status.return_value = "Cluster not healthy"
|
||||
_status.return_value = "Not Okay"
|
||||
_status_text.return_value = "Cluster not healthy"
|
||||
_check.return_value = None, None
|
||||
_conn_check.return_value = True
|
||||
midbc._assess_status()
|
||||
|
|
Loading…
Reference in New Issue