From 56dfb9b02ce0445e949f3713ac50994061d191f6 Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Wed, 12 Feb 2020 18:27:22 +0200 Subject: [PATCH] WIP, cf #275 need some way to distinguish "exited intentionally" (.finish/break/return) from connection closed. --- lib/kubeclient/watch_stream.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/kubeclient/watch_stream.rb b/lib/kubeclient/watch_stream.rb index ef676660..76a6988c 100644 --- a/lib/kubeclient/watch_stream.rb +++ b/lib/kubeclient/watch_stream.rb @@ -28,6 +28,14 @@ def each yield @formatter.call(line.chomp) end end + # We get to this point if apiserver closed the socket. + # The connection can also be aborted by network issues / middleboxes, + # which can cause ConnectionError (https://github.com/httprb/http/issues/556). + # The exact cause doesn't matter to caller, bottom line is "infinite" watch finished. + # TODO: attempt resuming (https://github.com/abonas/kubeclient/pull/273). + rescue HTTP::ConnectionError + return + # .finish closing the socket underneath us can cause a wide range of exceptions... rescue StandardError raise unless @finished end