Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Fix Slack message formatting for ES health alert (#4345)

Madison Swain-Bowden352b71080efd
diff --git a/catalog/dags/elasticsearch_cluster/healthcheck_dag.py b/catalog/dags/elasticsearch_cluster/healthcheck_dag.py
index a980b1e95..5191a6c90 100644
--- a/catalog/dags/elasticsearch_cluster/healthcheck_dag.py
+++ b/catalog/dags/elasticsearch_cluster/healthcheck_dag.py
@@ -63,9 +63,9 @@ def _format_response_body(response_body: dict) -> str:
def _compose_red_status(env: Environment, response_body: dict) -> str:
message = f"""
- Elasticsearch {env} cluster status is **red**.
+ Elasticsearch {env} cluster status is *red*.
- This is a critical status change, **investigate ASAP**.
+ This is a critical status change, *investigate ASAP*.
{_format_response_body(response_body)}
"""
@@ -78,13 +78,13 @@ def _compose_unexpected_node_count(env: Environment, response_body: dict) -> str
master_node_count = node_count - data_node_count
message = f"""
- Elasticsearch {env} cluster node count is **{node_count}**.
+ Elasticsearch {env} cluster node count is *{node_count}*.
Expected {EXPECTED_NODE_COUNT} total nodes.
- Master nodes: **{master_node_count}** of expected {EXPECTED_MASTER_NODE_COUNT}
- Data nodes: **{data_node_count}** of expected {EXPECTED_DATA_NODE_COUNT}
+ Master nodes: *{master_node_count}* of expected {EXPECTED_MASTER_NODE_COUNT}
+ Data nodes: *{data_node_count}* of expected {EXPECTED_DATA_NODE_COUNT}
- This is a critical status change, **investigate ASAP**.
+ This is a critical status change, *investigate ASAP*.
If this is expected (e.g., during controlled node or cluster changes), acknowledge immediately with explanation.
{_format_response_body(response_body)}
@@ -95,7 +95,7 @@ def _compose_unexpected_node_count(env: Environment, response_body: dict) -> str
def _compose_yellow_cluster_health(env: Environment, response_body: dict) -> str:
message = f"""
- Elasticsearch {env} cluster health is **yellow**.
+ Elasticsearch {env} cluster health is *yellow*.
This does not mean something is necessarily wrong, but if this is not expected (e.g., data refresh) then investigate cluster health now.
diff --git a/catalog/tests/dags/elasticsearch_cluster/test_healthcheck_dag.py b/catalog/tests/dags/elasticsearch_cluster/test_healthcheck_dag.py
index aabdb203c..6950c9e6c 100644
--- a/catalog/tests/dags/elasticsearch_cluster/test_healthcheck_dag.py
+++ b/catalog/tests/dags/elasticsearch_cluster/test_healthcheck_dag.py
@@ -33,10 +33,10 @@ def _make_response_body(**kwargs):
def _missing_node_keys(master_nodes: int, data_nodes: int):
total_nodes = master_nodes + data_nodes
return (
- f"Elasticsearch {_TEST_ENV} cluster node count is **{total_nodes}**",
+ f"Elasticsearch {_TEST_ENV} cluster node count is *{total_nodes}*",
"Expected 6 total nodes.",
- f"Master nodes: **{master_nodes}** of expected 3",
- f"Data nodes: **{data_nodes}** of expected 3",
+ f"Master nodes: *{master_nodes}* of expected 3",
+ f"Data nodes: *{data_nodes}* of expected 3",
)
@@ -45,7 +45,7 @@ def _missing_node_keys(master_nodes: int, data_nodes: int):
(
pytest.param(
"alert",
- (f"Elasticsearch {_TEST_ENV} cluster status is **red**",),
+ (f"Elasticsearch {_TEST_ENV} cluster status is *red*",),
_make_response_body(status="red"),
id="red-status",
),
@@ -81,7 +81,7 @@ def _missing_node_keys(master_nodes: int, data_nodes: int):
),
pytest.param(
"notification",
- (f"Elasticsearch {_TEST_ENV} cluster health is **yellow**.",),
+ (f"Elasticsearch {_TEST_ENV} cluster health is *yellow*.",),
_make_response_body(
status="yellow",
),
@@ -127,4 +127,4 @@ def test_production_compose_notification_data_refresh_not_running():
)
assert message_type == "notification"
- assert "Elasticsearch production cluster health is **yellow**." in message
+ assert "Elasticsearch production cluster health is *yellow*." in message