From a3203d29d9f35c9ba962dcd78d64e46c30a3ee13 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Tue, 7 Sep 2021 13:34:03 +0200 Subject: [PATCH] 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 --- .../fedora-messaging-utils/files/simple_message_to_bus | 10 +++++++--- roles/web-data-analysis/files/combineHttpLogs.sh | 1 + roles/web-data-analysis/files/condense-mirrorlogs.sh | 2 ++ roles/web-data-analysis/files/countme-update.sh | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/roles/fedora-messaging-utils/files/simple_message_to_bus b/roles/fedora-messaging-utils/files/simple_message_to_bus index 7091968fc0..2e8a17f157 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 ee03b81e98..73d1f5d8c9 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 ab78fcc469..7d5f7dd862 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 43238ffcc2..9f3281d96c 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"