Skip to content

Commit

Permalink
Add warnings when all ignore_errors are specified but
Browse files Browse the repository at this point in the history
ignore_if_prev_success is not specified

Signed-off-by: Hiroshi Hatake <hatake@clear-code.com>
  • Loading branch information
cosmo0920 committed Mar 8, 2021
1 parent 2f5a6e1 commit bdbaef2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/fluent/plugin/out_copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def configure(conf)
@ignore_errors << (store.arg.include?('ignore_error'))
@ignore_if_prev_successes << (store.arg.include?('ignore_if_prev_success'))
}
if @ignore_errors.uniq.size == 1 && @ignore_errors.include?(true) && @ignore_if_prev_successes.uniq.include?(false)
log.warn "ignore_errors are specified in all <store>, but ignore_if_prev_success is not specified. Is this intended?"
end
end

def multi_workers_ready?
Expand Down
22 changes: 22 additions & 0 deletions test/plugin/test_out_copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ def test_configure_with_errorneus_ignore_if_prev_success
end
end

ALL_IGNORE_ERROR_WITHOUT_IGNORE_IF_PREV_SUCCESS_CONFIG = %[
@log_level info
<store ignore_error>
@type test
name c0
</store>
<store ignore_error>
@type test
name c1
</store>
<store ignore_error>
@type test
name c2
</store>
]
def test_configure_all_ignore_errors_without_ignore_if_prev_success
d = create_driver(ALL_IGNORE_ERROR_WITHOUT_IGNORE_IF_PREV_SUCCESS_CONFIG)
expected = /ignore_errors are specified in all <store>, but ignore_if_prev_success is not specified./
matches = d.logs.grep(expected)
assert_equal(1, matches.length, "Logs do not contain '#{expected}' '#{d.logs}'")
end

def test_configure_with_deep_copy_and_use_shallow_copy_mode
d = create_driver(%[
deep_copy true
Expand Down

0 comments on commit bdbaef2

Please sign in to comment.