Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,13 @@ def configure(conf)
buf_type = Plugin.lookup_type_from_class(@buffer.class)
log.warn "'flush_at_shutdown' is false, and buffer plugin '#{buf_type}' is not persistent buffer."
log.warn "your configuration will lose buffered data at shutdown. please confirm your configuration again."
else
if Fluent.windows? && @buffer.persistent?
service_timeout = read_wait_to_kill_service_timeout
if service_timeout && service_timeout <= 5000 # default value might varies on windows client/server
log.warn "your WaitToKillServiceTimeout=#{service_timeout} registry configuration seems too short. Recommend to extend that value not to corrupt flushing buffer with forcibly shutdown"
end
end
end

if (@flush_mode != :interval) && buffer_conf.has_key?('flush_interval')
Expand Down Expand Up @@ -418,6 +425,22 @@ def configure(conf)
self
end

def read_wait_to_kill_service_timeout
if Fluent.windows?
begin
require "win32/registry"
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Control",
Win32::Registry::KEY_READ) do |reg|
reg["WaitToKillServiceTimeout"].to_i
end
rescue => e
log.warn "'flush_at_shutdown' is true, but can't check WaitToKillServiceTimeout registry configuration", error: e
end
else
nil # not supported
end
end

def keep_buffer_config_compat
# Need this to call `@buffer_config.disable_chunk_backup` just as before,
# since some plugins may use this option in this way.
Expand Down
18 changes: 18 additions & 0 deletions test/command/test_fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1760,4 +1760,22 @@ def create_config_include_dir_configuration(config_path, config_dir, yaml_format
end
end
end

sub_test_case "test suspicious shorter service timeout on windows" do
test 'warn the default value of timekey (1d) is used as-is' do
omit "skip service timeout on windows test case" unless Fluent.windows?
conf_path = create_conf_file("warning.conf", <<~EOF)
<system>
config_include_dir ""
</system>
<match>
@type file
path #{@tmp_dir}/test.log
flush_at_shutdown
</match>
EOF
message="your WaitToKillServiceTimeout=5000 registry configuration seems too short. Recommend to extend that value not to corrupt flushing buffer with forcibly shutdown"
assert_log_matches(create_cmdline(conf_path, '--dry-run'), message)
end
end
end