Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Differentiate between slack channels (#359)
Madison Swain-Bowden9555374b41fd
diff --git a/env.template b/env.templateindex 15d724cf5..81a730716 100644--- a/env.template+++ b/env.template@@ -45,9 +45,12 @@ AIRFLOW_CONN_AWS_DEFAULT=aws://test_key:test_secret@?region_name=us-east-1&host=# Change the following line in prod to use the appropriate DBAIRFLOW_CONN_POSTGRES_OPENLEDGER_UPSTREAM=postgres://deploy:deploy@postgres:5432/openledgerAIRFLOW_CONN_POSTGRES_OPENLEDGER_TESTING=postgres://deploy:deploy@postgres:5432/openledger-# Slack notification webhook connection info (this must be URL encoded, with a+# Slack webhook connection info (this must be URL encoded, with a# pre-pended https://, e.g. "https://https%3A%2F%2Fhooks.slack.com%2Fservices%2everythingelse")-AIRFLOW_CONN_SLACK=https://slack+# A distinction is made here between "notifications" and "alerts", the former being+# useful updates and the latter being alarms or actionable errors.+AIRFLOW_CONN_SLACK_NOTIFICATIONS=https://slack+AIRFLOW_CONN_SLACK_ALERTS=https://slackOPENLEDGER_CONN_ID=postgres_openledger_upstreamTEST_CONN_ID=postgres_openledger_testingdiff --git a/openverse_catalog/dags/common/slack.py b/openverse_catalog/dags/common/slack.pyindex c27fcc0e6..7491b5953 100644--- a/openverse_catalog/dags/common/slack.py+++ b/openverse_catalog/dags/common/slack.py@@ -52,7 +52,8 @@ from airflow.providers.http.hooks.http import HttpHookfrom requests import Response-SLACK_CONN_ID = "slack"+SLACK_NOTIFICATIONS_CONN_ID = "slack_notifications"+SLACK_ALERTS_CONN_ID = "slack_alerts"JsonDict = dict[str, Any]log = logging.getLogger(__name__)@@ -66,7 +67,7 @@ class SlackMessage:icon_emoji: str = ":airflow:",unfurl_links: bool = True,unfurl_media: bool = True,- http_conn_id: str = SLACK_CONN_ID,+ http_conn_id: str = SLACK_NOTIFICATIONS_CONN_ID,):self.http = HttpHook(method="POST", http_conn_id=http_conn_id)@@ -211,7 +212,7 @@ def send_message(username: str = "Airflow",icon_emoji: str = ":airflow:",markdown: bool = True,- http_conn_id: str = SLACK_CONN_ID,+ http_conn_id: str = SLACK_NOTIFICATIONS_CONN_ID,) -> None:"""Send a simple slack message, convenience message for short/simple messages."""s = SlackMessage(username, icon_emoji, http_conn_id=http_conn_id)@@ -225,7 +226,7 @@ def on_failure_callback(context: dict) -> None:Errors are only sent out in production and if a Slack connection is defined."""# Exit early if no slack connection exists- hook = HttpHook(http_conn_id=SLACK_CONN_ID)+ hook = HttpHook(http_conn_id=SLACK_ALERTS_CONN_ID)try:hook.get_conn()except AirflowNotFoundException: