-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add authentication feature to in_forward #813
Conversation
Is it still WIP? |
Yes, this PR is still WIP. |
The following change may help you: diff --git a/lib/fluent/plugin/out_forward.rb b/lib/fluent/plugin/out_forward.rb
index 12693c7..ad7474c 100644
--- a/lib/fluent/plugin/out_forward.rb
+++ b/lib/fluent/plugin/out_forward.rb
@@ -336,7 +336,11 @@ module Fluent
# To avoid a decrease of troughput, it is necessary to prepare a list of chunks that wait for responses
# and process them asynchronously.
if IO.select([sock], nil, nil, @ack_response_timeout)
- raw_data = sock.recv(1024)
+ begin
+ raw_data = sock.recv(1024)
+ rescue Errno::ECONNRESET
+ raw_data = ""
+ end
# When connection is closed by remote host, socket is ready to read and #recv returns an empty string that means EOF.
# If this happens we assume the data wasn't delivered and retry it.
diff --git a/lib/fluent/test/base.rb b/lib/fluent/test/base.rb
index 089005f..d5e3b72 100644
--- a/lib/fluent/test/base.rb
+++ b/lib/fluent/test/base.rb
@@ -56,7 +56,11 @@ module Fluent
else
@instance = klass
end
- @instance.router = Engine.root_agent.event_router
+ @instance.router = Object.new
+ router = @instance.router
+ def router.method_missing(name, *args, **kw_args, &block)
+ Engine.root_agent.event_router.__send__(name, *args, **kw_args, &block)
+ end
@instance.log = TestLogger.new
Engine.root_agent.instance_variable_set(:@log, @instance.log)
diff --git a/test/plugin/test_out_forward.rb b/test/plugin/test_out_forward.rb
index 909d5bb..b2781e4 100644
--- a/test/plugin/test_out_forward.rb
+++ b/test/plugin/test_out_forward.rb
@@ -259,7 +259,7 @@ class ForwardOutputTest < Test::Unit::TestCase
end
def test_require_a_node_supporting_responses_to_respond_with_ack
- target_input_driver = create_target_input_driver(true)
+ target_input_driver = create_target_input_driver
d = create_driver(CONFIG + %[
flush_interval 1s
@@ -296,7 +296,7 @@ class ForwardOutputTest < Test::Unit::TestCase
def test_require_a_node_not_supporting_responses_to_respond_with_ack
# in_forward, that doesn't support ack feature, and keep connection alive
- target_input_driver = create_target_input_driver
+ target_input_driver = create_target_input_driver(->(options){ nil })
d = create_driver(CONFIG + %[
flush_interval 1s
@@ -337,7 +337,7 @@ class ForwardOutputTest < Test::Unit::TestCase
# bdf1f4f104c00a791aa94dc20087fe2011e1fd83
def test_require_a_node_not_supporting_responses_2_to_respond_with_ack
# in_forward, that doesn't support ack feature, and disconnect immediately
- target_input_driver = create_target_input_driver(false, true)
+ target_input_driver = create_target_input_driver(->(options){ nil }, true)
d = create_driver(CONFIG + %[
flush_interval 1s For
require "socket"
server = TCPServer.new("127.0.0.1", 0)
client = TCPSocket.new("127.0.0.1", server.addr[1])
server_client = server.accept
client.write("x")
server_client.close
client.recv(1024) # => Errno::ECONNRESET If NOTE: For We can't use multiple test drivers in a test because we can't hook router's instance.router.define_singleton_method(:emit_stream) {|tag,es|
m.call(tag, es)
} If we use the singleton method strategy, we should create a new router for each test driver. okkez@137b9b8 may be a workaround for the limitation. But it may not be a good strategy. For We should follow |
I forgot to mention about my change is just a proof of concept. We should rethink about whether is the implementation reasonable or not. For example, the following code is tricky: + @instance.router = Object.new
+ router = @instance.router
+ def router.method_missing(name, *args, **kw_args, &block)
+ Engine.root_agent.event_router.__send__(name, *args, **kw_args, &block)
+ end We should create proxy class and instantiate it. Or create a new router for each driver. |
CI in Windows environment is failing. This is caused by Could you fix tests in any way below?:
|
OK, I will fix in a few days. |
Ah, it's my mistake that: |
@okkez ping |
How about |
Rebased |
# '' : socket is disconnected without any data | ||
# nil: socket read timeout | ||
def read_data(io, timeout) | ||
skip if Fluent.windows? && RUBY_VERSION < "2.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line causes errors in AppVeyor: e.g. https://ci.appveyor.com/project/fluent/fluentd/build/656/job/o4qg0yn2w44a32a6#L1485
Perhaps, it should be omit
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks correct > omit
instead of skip
@okkez Could you rebase once again and fix to use |
OK, I will rebase tomorrow. |
59c5444
to
389b7a4
Compare
Rebased. |
Failed CI on Appveyor, why? |
Some failures and warnings are actually occurring. |
1F1E log.
|
On my local (Windows7 32bit with Ruby 2.2.3), I could not reproduce 1F (test_time). |
Pass all tests on my local Windows7 32bit. |
@@ -50,8 +50,67 @@ def initialize | |||
desc 'Skip an event if incoming event is invalid.' | |||
config_param :skip_invalid_event, :bool, default: false | |||
|
|||
# TODO check recent fluent-plugin-secure-forward updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment.
This is based on out_secure_forward. TODO: test!!!
This test case: out_forward connects to in_forward that does not support ack feature.
Thank you for revising my PR 👍 |
I've added authentication feature to in_forward based on v0.14 branch.
in_forward test is green but out_forward test is red for now.