From a95808355cd0138faeec474f1ea9abc38176b499 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Wed, 22 Nov 2023 13:03:03 +0100 Subject: [PATCH] Make scripts to sync log files more robust Previously, an expired certificate on log01 made sending messages out of the scripts fail, which caused a couple days worth of lost logs. Signed-off-by: Nils Philippsen --- roles/fedora-messaging-utils/files/simple_message_to_bus | 8 +++++++- roles/web-data-analysis/files/sync-http-logs.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/roles/fedora-messaging-utils/files/simple_message_to_bus b/roles/fedora-messaging-utils/files/simple_message_to_bus index dcddc8beea..dc9f33f3f5 100644 --- a/roles/fedora-messaging-utils/files/simple_message_to_bus +++ b/roles/fedora-messaging-utils/files/simple_message_to_bus @@ -1,5 +1,11 @@ #!/bin/bash + +# This scripts is used to send messages to the Fedora message bus. It will catch problems with +# actually sending the underlying message so that other scripts using it continue regardless. + +set +e + # 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}." @@ -31,6 +37,6 @@ for body_piece in $MSGBODY_PRESET "$@"; do done body="${body}}" -fedora-messaging publish - << EOF >/dev/null +fedora-messaging publish - << EOF >/dev/null || : {"body": ${body}, "headers": {"fedora_messaging_schema": "base.message", "fedora_messaging_severity": 20, "sent-at": "${sent_at}"}, "id": "${id}", "queue": "queue", "topic": "${topic}"} EOF diff --git a/roles/web-data-analysis/files/sync-http-logs.py b/roles/web-data-analysis/files/sync-http-logs.py index 79f3574e18..5ca0a4de5c 100644 --- a/roles/web-data-analysis/files/sync-http-logs.py +++ b/roles/web-data-analysis/files/sync-http-logs.py @@ -37,7 +37,10 @@ log = logging.getLogger(__name__) def send_bus_msg(topic, **kwargs): msg = message.Message(topic=f"{MSGTOPIC_PREFIX}.{topic}", body=kwargs) - api.publish(msg) + try: + api.publish(msg) + except Exception as exc: + log.warning("Can’t send message to the bus: %s, %s", msg, exc) def send_sync_msg(topic, **kwargs):