Skip to content

Commit

Permalink
fix socket shutdown in pod watcher
Browse files Browse the repository at this point in the history
System IO raises an EOFError when reading from a closed socket,
which happens when we close a long running connection listening
for pod events. Celluloid transforms EOFError into MailboxShutdown
and terminates the actor quietly. We ned to rescue EOFError before
it gets to Celluloid.
  • Loading branch information
Maciek Sufa committed Nov 26, 2015
1 parent 44e7874 commit 77631e6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions plugins/kubernetes/app/models/watchers/cluster_pod_watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ class ClusterPodWatcher
finalizer :stop_watching

def initialize(client)
@started = false
@client = client
@watch_stream = nil
async :start_watching
end

def start_watching
info 'watcher started'
@started = true
@watch_stream = @client.watch_pods
@watch_stream.each do |notice|
handle_notice notice
Expand All @@ -27,7 +25,6 @@ def start_watching

def stop_watching
info 'watcher stopped'
@started = false
if @watch_stream
@watch_stream.finish
@watch_stream = nil
Expand Down
2 changes: 1 addition & 1 deletion plugins/kubernetes/config/initializers/watchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def each(&block)
fail KubeException.new(response.code, response.reason, response)
end
read_stream(response.body, &block)
rescue Errno::EBADF
rescue IOError
raise unless @finished
end

Expand Down

0 comments on commit 77631e6

Please sign in to comment.