From 102a12ea5a2b0cc349d975346bba2de857320949 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 15 Jan 2020 12:38:34 +0100 Subject: [PATCH] Catch all exceptions when calling socket.getaddrinfo (#1355) it serves two purposes: 1. We don't want accidentally break the thread 2. During the shutdown socket.gaierror become unresolvable and nasty exceptions are raised Close: https://github.com/zalando/patroni/issues/1353 --- patroni/dcs/etcd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patroni/dcs/etcd.py b/patroni/dcs/etcd.py index 880b5578..02e88407 100644 --- a/patroni/dcs/etcd.py +++ b/patroni/dcs/etcd.py @@ -73,8 +73,8 @@ class DnsCachingResolver(Thread): def _do_resolve(host, port): try: return socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP) - except socket.gaierror: - logger.warning('failed to resolve host %s', host) + except Exception as e: + logger.warning('failed to resolve host %s: %s', host, e) return []