Skip to content

Commit 41cd031

Browse files
committed
Add error handling to setup-network to catch IncompleteRead errors
These pop up frequently and while systemctl restarts the daemon the chaff in the log is annoying. It looks like the kubernetes-client maintainers won't fix the bug so we've got to work around it. kubernetes-client/python#1693
1 parent 0d334bc commit 41cd031

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

roles/epic/files/setup-network

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import netifaces
66
import subprocess
77
import grpc
88
import kubernetes
9+
import time
910
from containerd.services.containers.v1 import containers_pb2_grpc, containers_pb2
1011
from subprocess import PIPE
1112
from kubernetes.client.exceptions import ApiException
13+
from urllib3.exceptions import ProtocolError
1214

1315

1416
EPIC_NAMESPACE="epic"
@@ -192,6 +194,11 @@ if __name__ == "__main__":
192194

193195
k8_api = kubernetes.client.CoreV1Api()
194196
watch = kubernetes.watch.Watch()
195-
for event in watch.stream(k8_api.list_pod_for_all_namespaces, label_selector='app.kubernetes.io/part-of=epic,app.kubernetes.io/component=envoy-deployment'):
196-
print("Event: %s %s %s" % (event['type'], event['object'].metadata.name, event['object'].metadata.namespace))
197-
handle_event(event, addr)
197+
while True:
198+
try:
199+
for event in watch.stream(k8_api.list_pod_for_all_namespaces, label_selector='app.kubernetes.io/part-of=epic,app.kubernetes.io/component=envoy-deployment'):
200+
print("Event: %s %s %s" % (event['type'], event['object'].metadata.name, event['object'].metadata.namespace))
201+
handle_event(event, addr)
202+
except ProtocolError as e:
203+
print("urllib3.exceptions.ProtocolError: %s. Pausing and will reconnect" % (e))
204+
time.sleep(3)

0 commit comments

Comments
 (0)