From e3d87f1314b7e9faf6c36bdbc213d0f1adf2b1dc Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Sat, 16 May 2020 00:01:19 +0900 Subject: [PATCH] Add warning for object conflict case. ref #326 Signed-off-by: Masahiro Nakagawa --- lib/fluent/plugin/out_s3.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/fluent/plugin/out_s3.rb b/lib/fluent/plugin/out_s3.rb index 8b173c70..dc546a9e 100644 --- a/lib/fluent/plugin/out_s3.rb +++ b/lib/fluent/plugin/out_s3.rb @@ -209,6 +209,8 @@ def configure(conf) end end + check_s3_path_safety(conf) + # For backward compatibility # TODO: Remove time_slice_format when end of support compat_parameters @configured_time_slice_format = conf['time_slice_format'] @@ -451,6 +453,16 @@ def process_s3_object_key_format } end + def check_s3_path_safety(conf) + unless conf.has_key?('s3_object_key_format') + log.warn "The default value of s3_object_key_format will use ${chunk_id} instead of %{index} to avoid object conflict in v2" + end + + if (@buffer_config.flush_thread_count > 1) && ['${chunk_id}', '%{uuid_flush}'].none? { |key| @s3_object_key_format.include?(key) } + log.warn "No ${chunk_id} or %{uuid_flush} in s3_object_key_format with multiple flush threads. Recommend to set ${chunk_id} or %{uuid_flush} to avoid data lost by object conflict" + end + end + def check_apikeys @bucket.objects(prefix: @path, :max_keys => 1).first rescue Aws::S3::Errors::NoSuchBucket