Skip to content
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

out_file: add warn message for symlink_path setting #4502

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/fluent/plugin/out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ def configure(conf)
log.warn "symlink_path is unavailable on Windows platform. disabled."
@symlink_path = nil
else
#add check if symlink_path has a tag placeholder.
Shingo-Nakayama marked this conversation as resolved.
Show resolved Hide resolved
placeholder_validators(:symlink_path, @symlink_path).reject{|v| v.type == :time }.each do |v|
begin
v.validate!
end
rescue Fluent::ConfigError => e
log.warn "#{e}. This means multiple chunks are competing for a single symlink_path, so some logs may not be taken from the symlink."
end

Shingo-Nakayama marked this conversation as resolved.
Show resolved Hide resolved
@buffer.extend SymlinkBufferMixin
@buffer.symlink_path = @symlink_path
@buffer.output_plugin_for_symlink = self
Expand Down
21 changes: 20 additions & 1 deletion test/plugin/test_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def create_driver(conf = CONFIG, opts = {})
'path' => "#{TMP_DIR}/${tag}/${type}/conf_test.%Y%m%d.%H%M.log",
'add_path_suffix' => 'false',
'append' => "true",
'symlink_path' => "#{TMP_DIR}/conf_test.current.log",
'symlink_path' => "#{TMP_DIR}/${tag}/conf_test.current.log",
'compress' => 'gzip',
'recompress' => 'true',
}, [
Expand Down Expand Up @@ -183,6 +183,25 @@ def create_driver(conf = CONFIG, opts = {})
Fluent::Test::Driver::Output.new(Fluent::Plugin::NullOutput).configure(conf)
end
end

test 'symlink path has not tag placeholder or key placeholder' do
Shingo-Nakayama marked this conversation as resolved.
Show resolved Hide resolved
conf = config_element('match', '**', {
Shingo-Nakayama marked this conversation as resolved.
Show resolved Hide resolved
'path' => "#{TMP_DIR}/${tag}/${key1}/${key2}/conf_test.%Y%m%d.%H%M.log",
'symlink_path' => "#{TMP_DIR}/conf_test.current.log",
}, [
config_element('buffer', 'time,tag,key1,key2', {
'@type' => 'file',
'timekey' => '1d',
'path' => "#{TMP_DIR}/buf_conf_test",
}),
])
assert_nothing_raised do
d = create_driver(conf)
assert do
d.logs.count { |log| log.include?("symlink_path:") } == 2
Shingo-Nakayama marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
end

sub_test_case 'fully configured output' do
Expand Down
Loading