Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Fix airflow connections (#3805)
Staci Mullins1cf6c6ad555a
diff --git a/catalog/dags/common/slack.py b/catalog/dags/common/slack.pyindex 4365d003a..a671b96bb 100644--- a/catalog/dags/common/slack.py+++ b/catalog/dags/common/slack.py@@ -295,7 +295,7 @@ def should_send_message(# Exit early if this DAG is configured to skip Slack messagingif should_silence_message(text, username, dag_id, task_id):- log.info(f"Skipping Slack notification for {dag_id}::{task_id}.")+ log.info(f"Skipping silenced Slack notification for {dag_id}::{task_id}.")return False# Exit early if we aren't on production or if force alert is not set@@ -303,7 +303,15 @@ def should_send_message(force_message = Variable.get("SLACK_MESSAGE_OVERRIDE", default_var=False, deserialize_json=True)- return environment == "prod" or force_message+ if not (environment == "prod" or force_message):+ log.info(+ f"Skipping Slack notification for {dag_id}:{task_id} in"+ f" `{environment}` environment. To send the notification, enable"+ " the `SLACK_MESSAGE_OVERRIDE` variable."+ )+ return False++ return Truedef send_message(diff --git a/catalog/dags/elasticsearch_cluster/shared.py b/catalog/dags/elasticsearch_cluster/shared.pyindex ef53d0fad..02fcb315c 100644--- a/catalog/dags/elasticsearch_cluster/shared.py+++ b/catalog/dags/elasticsearch_cluster/shared.py@@ -8,4 +8,4 @@ from common.constants import Environment@taskdef get_es_host(environment: Environment) -> XComArg:conn = Connection.get_connection_from_secrets(f"elasticsearch_http_{environment}")- return conn.host+ return conn.get_uri()diff --git a/catalog/entrypoint.sh b/catalog/entrypoint.shindex 24d199d92..7e7eab937 100755--- a/catalog/entrypoint.sh+++ b/catalog/entrypoint.sh@@ -36,7 +36,7 @@ function header() {if [ "$1" == help ] || [ "$1" == --help ]; then help_text && exit 0; fisleep 0.1 # The $COLUMNS variable takes a moment to populate-# Reformat Airflow connections that use https+# Reformat Slack Airflow connectionsheader "MODIFYING ENVIRONMENT"# Loop through environment variables, relying on naming conventions.# Bash loops with pipes occur in a subprocess, so we need to do some special@@ -57,7 +57,8 @@ while read -r var_string; doecho " New Value: $new_value"# set the environment variableexport "$var_name"="$new_value"- # only include airflow connections with http somewhere in the string-done < <(env | grep "^AIRFLOW_CONN[A-Z_]\+=http.*$")++ # only include Slack airflow connections+done < <(env | grep "^AIRFLOW_CONN_SLACK*")exec /entrypoint "$@"