Skip to content

Commit 6c95e9d

Browse files
author
Guy Boertje
authored
Merge pull request #144 from marcinc/retry-with-delay-only-on-recoverable-errors
Handle file not found exception on S3 upload
2 parents 39d2eb9 + a8dca8b commit 6c95e9d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/logstash/outputs/s3/uploader.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ def upload(file, options = {})
3636
begin
3737
obj = bucket.object(file.key)
3838
obj.upload_file(file.path, upload_options)
39+
rescue Errno::ENOENT => e
40+
logger.error("File doesn't exist! Unrecoverable error.", :exception => e.class, :message => e.message, :path => file.path, :backtrace => e.backtrace)
3941
rescue => e
4042
# When we get here it usually mean that S3 tried to do some retry by himself (default is 3)
4143
# When the retry limit is reached or another error happen we will wait and retry.
4244
#
4345
# Thread might be stuck here, but I think its better than losing anything
4446
# its either a transient errors or something bad really happened.
45-
logger.error("Uploading failed, retrying", :exception => e.class, :message => e.message, :path => file.path, :backtrace => e.backtrace)
47+
logger.error("Uploading failed, retrying.", :exception => e.class, :message => e.message, :path => file.path, :backtrace => e.backtrace)
48+
sleep TIME_BEFORE_RETRYING_SECONDS
4649
retry
4750
end
4851

0 commit comments

Comments
 (0)