From a3203d29d9f35c9ba962dcd78d64e46c30a3ee13 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Sep 09 2021 10:40:56 +0000 Subject: Get rid of implicit message topic prefix Callers of simple_message_to_bus need to set and export MSGTOPIC_PREFIX explicitly. This decouples the fedora-messaging-utils and web-data-analysis roles. Additionally, don't assume /bin/sh is /bin/bash. Signed-off-by: Nils Philippsen --- diff --git a/roles/fedora-messaging-utils/files/simple_message_to_bus b/roles/fedora-messaging-utils/files/simple_message_to_bus index 7091968..2e8a17f 100644 --- a/roles/fedora-messaging-utils/files/simple_message_to_bus +++ b/roles/fedora-messaging-utils/files/simple_message_to_bus @@ -1,6 +1,10 @@ -#!/bin/sh -MSGTOPIC_PREFIX="${MSGTOPIC_PREFIX:-logging.stats}" -topic="${MSGTOPIC_PREFIX}.$1" +#!/bin/bash + +# To set a common prefix for all messages, do `export MSGTOPIC_PREFIX=...` in callers. +if [ -n "$MSGTOPIC_PREFIX" -a "${MSGTOPIC_PREFIX%.}" = "$MSGTOPIC_PREFIX" ]; then + MSGTOPIC_PREFIX="${MSGTOPIC_PREFIX}." +fi +topic="${MSGTOPIC_PREFIX}$1" shift sent_at="$(TZ=UTC date -Iseconds)" id="$(uuidgen -r)" diff --git a/roles/web-data-analysis/files/combineHttpLogs.sh b/roles/web-data-analysis/files/combineHttpLogs.sh index ee03b81..73d1f5d 100644 --- a/roles/web-data-analysis/files/combineHttpLogs.sh +++ b/roles/web-data-analysis/files/combineHttpLogs.sh @@ -19,6 +19,7 @@ # along with Fedora Project Infrastructure Ansible Repository. If # not, see . +export MSGTOPIC_PREFIX=logging.stats RUN_ID="$(uuidgen -r)" simple_message_to_bus combinehttplogs.start run_id="$RUN_ID" diff --git a/roles/web-data-analysis/files/condense-mirrorlogs.sh b/roles/web-data-analysis/files/condense-mirrorlogs.sh index ab78fcc..7d5f7dd 100644 --- a/roles/web-data-analysis/files/condense-mirrorlogs.sh +++ b/roles/web-data-analysis/files/condense-mirrorlogs.sh @@ -25,6 +25,8 @@ # we are 5 days behind. # We have dropped this down to 3 days on 2019-10-01 + +export MSGTOPIC_PREFIX=logging.stats RUN_ID="$(uuidgen -r)" simple_message_to_bus condense-mirrorlogs.start run_id="$RUN_ID" diff --git a/roles/web-data-analysis/files/countme-update.sh b/roles/web-data-analysis/files/countme-update.sh index 43238ff..9f3281d 100644 --- a/roles/web-data-analysis/files/countme-update.sh +++ b/roles/web-data-analysis/files/countme-update.sh @@ -1,5 +1,6 @@ #!/bin/bash +export MSGTOPIC_PREFIX=logging.stats RUN_ID="$(uuidgen -r)" simple_message_to_bus countme-update.start run_id="$RUN_ID"