Add requests.ConnectionError to watcher retries

Apparently with switch to Python 3, requests library raises a different
exception when read time out occurrs and it's quite general
requests.ConnectionError. This causes tracebacks like [1] to show up in
logs.

This is pretty scary for the user, so this commit suppresses those exceptions
and adds them to the list of exceptions K8sClient restarts watching.

[1] http://paste.openstack.org/show/786574/

Change-Id: I09f3803edffbe2ea5f1913238adc23212a323100
This commit is contained in:
Michał Dulko
2019-11-22 16:01:25 +01:00
parent 28b27c5de2
commit 22f3030443

View File

@@ -271,7 +271,8 @@ class K8sClient(object):
# At this point it's safely passed to handler.
m = line_dict.get('object', {}).get('metadata', {})
resource_version = m.get('resourceVersion', None)
except (requests.ReadTimeout, ssl.SSLError) as e:
except (requests.ReadTimeout, requests.ConnectionError,
ssl.SSLError) as e:
if isinstance(e, ssl.SSLError) and e.args != ('timed out',):
raise