lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.3.1 vs lib/fluent/plugin/out_s3.rb in fluent-plugin-s3-1.3.2
- old
+ new
@@ -207,10 +207,12 @@
log.warn "Set 'check_object false' and s3_object_key_format is not specified. Use '%{path}/%{time_slice}_%{hms_slice}.%{file_extension}' for s3_object_key_format"
@s3_object_key_format = "%{path}/%{time_slice}_%{hms_slice}.%{file_extension}"
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']
@values_for_s3_object_chunk = {}
@time_slice_with_tz = Fluent::Timezone.formatter(@timekey_zone, @configured_time_slice_format || timekey_to_timeformat(@buffer_config['timekey']))
@@ -447,9 +449,19 @@
@s3_object_key_format.gsub('%{hostname}') { |expr|
log.warn "%{hostname} will be removed in the future. Use \"\#{Socket.gethostname}\" instead"
Socket.gethostname
}
+ 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