Skip to content

Commit

Permalink
guard and ignore network errors in heartbeat until name resolution su…
Browse files Browse the repository at this point in the history
…cceeded once
  • Loading branch information
tagomoris committed Jan 5, 2017
1 parent c761785 commit b058cb2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/fluent/plugin/out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def configure(conf)
rescue => e
raise unless @ignore_network_errors_at_startup
log.warn "failed to resolve node name when configured", server: (server.name || server.host), error: e
node.disable!
end
@nodes << node
end
Expand Down Expand Up @@ -463,6 +464,7 @@ def initialize(sender, server, failure:)

@resolved_host = nil
@resolved_time = 0
@resolved_once = false
end

attr_accessor :usock
Expand Down Expand Up @@ -563,9 +565,20 @@ def send_data(tag, chunk)

# FORWARD_TCP_HEARTBEAT_DATA = FORWARD_HEADER + ''.to_msgpack + [].to_msgpack
def send_heartbeat
begin
dest_addr = resolved_host
@resolved_once = true
rescue ::SocketError
if !@resolved_once && @ignore_network_errors_at_startup
log.warn "failed to resolve node name in heartbeating", server: (n.name || n.host), error: e
return
end
raise
end

case @sender.heartbeat_type
when :tcp
@sender.create_transfer_socket(resolved_host, port) do |sock|
@sender.create_transfer_socket(dest_addr, port) do |sock|
## don't send any data to not cause a compatibility problem
# sock.write FORWARD_TCP_HEARTBEAT_DATA

Expand Down

0 comments on commit b058cb2

Please sign in to comment.