Skip to content

Commit e3d87f1

Browse files
committed
Add warning for object conflict case. ref #326
Signed-off-by: Masahiro Nakagawa <[email protected]>
1 parent 7469d77 commit e3d87f1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/fluent/plugin/out_s3.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ def configure(conf)
209209
end
210210
end
211211

212+
check_s3_path_safety(conf)
213+
212214
# For backward compatibility
213215
# TODO: Remove time_slice_format when end of support compat_parameters
214216
@configured_time_slice_format = conf['time_slice_format']
@@ -451,6 +453,16 @@ def process_s3_object_key_format
451453
}
452454
end
453455

456+
def check_s3_path_safety(conf)
457+
unless conf.has_key?('s3_object_key_format')
458+
log.warn "The default value of s3_object_key_format will use ${chunk_id} instead of %{index} to avoid object conflict in v2"
459+
end
460+
461+
if (@buffer_config.flush_thread_count > 1) && ['${chunk_id}', '%{uuid_flush}'].none? { |key| @s3_object_key_format.include?(key) }
462+
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"
463+
end
464+
end
465+
454466
def check_apikeys
455467
@bucket.objects(prefix: @path, :max_keys => 1).first
456468
rescue Aws::S3::Errors::NoSuchBucket

0 commit comments

Comments
 (0)