From c857eed10bc46e5938e0cb85b4fbd5bf6b343721 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Wed, 30 Dec 2020 20:49:45 +0100 Subject: [PATCH] Subtract 10s from last check time when fetching logs --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 9739a31..9abc3af 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ import pathlib import sys import threading import traceback -from datetime import datetime +from datetime import datetime, timedelta from queue import SimpleQueue from signal import signal, SIGHUP, SIGINT, SIGTERM, setitimer, SIGALRM, ITIMER_REAL, SIGUSR1, SIGUSR2, strsignal @@ -112,8 +112,9 @@ class PodKeeper: for container in pod_description["Containers"]: if container["State"] != "running": print(f"Container {container['Name']} exited", file=sys.stderr, flush=True) - logs = podman.logs('--since', self.last_check.isoformat(), container['Name']) - print(f"Log since last check:\n{logs}", file=sys.stderr, flush=True) + logs_since = self.last_check - timedelta(seconds=10) + logs = podman.logs('--since', logs_since.isoformat(), container['Name']) + print(f"Log since last check (-10s):\n{logs}", file=sys.stderr, flush=True) self.stopping.set() self.last_check = new_timestamp