Skip to content

Commit

Permalink
Add warning about retryable_response_codes
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
  • Loading branch information
ganmacs committed Jan 31, 2020
1 parent ae8b374 commit 56cf209
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/fluent/plugin/out_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RetryableResponse < StandardError; end
desc 'Raise UnrecoverableError when the response is non success, 4xx/5xx'
config_param :error_response_as_unrecoverable, :bool, default: true
desc 'The list of retryable response code'
config_param :retryable_response_codes, :array, value_type: :integer, default: [503]
config_param :retryable_response_codes, :array, value_type: :integer, default: nil

config_section :format do
config_set_default :@type, 'json'
Expand All @@ -90,6 +90,11 @@ def initialize
def configure(conf)
super

if @retryable_response_codes.nil?
log.warn('Status code 503 is going to be removed from default `retryable_response_codes`. Please add it by yourself if you wish')
@retryable_response_codes = [503]
end

@http_opt = setup_http_option
@proxy_uri = URI.parse(@proxy) if @proxy
@formatter = formatter_create
Expand Down Expand Up @@ -172,7 +177,7 @@ def setup_http_option
end

def parse_endpoint(chunk)
endpoint = extract_placeholders(@endpoint, chunk)
endpoint = extract_placeholders(@endpoint, chunk)
URI.parse(endpoint)
end

Expand Down
17 changes: 15 additions & 2 deletions test/plugin/test_out_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ def test_configure
assert_nil d.instance.headers
end

def test_configure_with_warn
d = create_driver(config)
assert_match(/Status code 503 is going to be removed/, d.instance.log.out.logs.join)
end

def test_configure_without_warn
d = create_driver(<<~CONFIG)
endpoint #{base_endpoint}/test
retryable_response_codes [503]
CONFIG
assert_not_match(/Status code 503 is going to be removed/, d.instance.log.out.logs.join)
end

data('json' => ['json', 'application/x-ndjson'],
'ltsv' => ['ltsv', 'text/tab-separated-values'],
'msgpack' => ['msgpack', 'application/x-msgpack'],
Expand Down Expand Up @@ -257,7 +270,7 @@ def test_write_with_disabled_unrecoverable
d.feed(event)
}
end
assert_match(/got error response from.*404 Not Found Not Found/, d.instance.log.out.logs.first)
assert_match(/got error response from.*404 Not Found Not Found/, d.instance.log.out.logs.join)
d.instance_shutdown
end

Expand Down Expand Up @@ -313,7 +326,7 @@ def test_basic_auth_with_invalid_auth
d.feed(event)
}
end
assert_match(/got unrecoverable error/, d.instance.log.out.logs.first)
assert_match(/got unrecoverable error/, d.instance.log.out.logs.join)

d.instance_shutdown
end
Expand Down

0 comments on commit 56cf209

Please sign in to comment.