From 8f1520452e0c9f135b25eb9fd1e390c57a44f0ec Mon Sep 17 00:00:00 2001 From: Luca Miccini Date: Tue, 1 Oct 2024 08:36:42 +0200 Subject: [PATCH] Wrap reverse dns lookup in try/except block --- templates/instanceha/bin/instanceha.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/instanceha/bin/instanceha.py b/templates/instanceha/bin/instanceha.py index 94760c9d..323f9efc 100755 --- a/templates/instanceha/bin/instanceha.py +++ b/templates/instanceha/bin/instanceha.py @@ -419,7 +419,11 @@ def _check_kdump(stale_services): #logging.debug("address is %s" % address[0]) # short hostname - name = socket.gethostbyaddr(address[0])[0].split('.', 1)[0] + try: + name = socket.gethostbyaddr(address[0])[0].split('.', 1)[0] + except Exception as msg: + logging.error('Failed reverse dns lookup for: %s - %s' % (address[0], msg)) + continue # fence_kdump checks if the magic number matches, so let's do it here too if hex(struct.unpack('ii',data)[0]).upper() != FENCE_KDUMP_MAGIC.upper() :