logstash-input-file 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/filewatch/helper.rb +5 -2
- data/lib/filewatch/sincedb_collection.rb +13 -2
- data/lib/jars/filewatch-1.0.1.jar +0 -0
- data/lib/logstash/inputs/file.rb +3 -4
- data/lib/logstash/inputs/file_listener.rb +1 -2
- data/logstash-input-file.gemspec +1 -1
- data/spec/inputs/file_read_spec.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1db5895e894194d27fa746f21e316c9bc8093f32d567023fd087e0be14a20839
|
4
|
+
data.tar.gz: 8c98ccd955718ecd48c46809345b665ab4f47a5dc1fe40fccf3dacedb8618283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7448a61c0b4a732ba1625318db1c0e18a19413f0cd283ca604ca9bd63ecd8af77f10df99e9cba85d4e70abfac493011b2867618b072b02baf656dd85dda18f
|
7
|
+
data.tar.gz: fd7a0c304c711d12f2b89f1974a1d15a637fc01f721a7438144125cf3a30b2b0ed3e74b3b522ccefc1203d64daa8277f501238e351235142aa1b16b844ae88a2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 4.3.1
|
2
|
+
- Add extra safety to `chown` call in `atomic_write`, avoiding plugin crashes and falling back to a
|
3
|
+
`non_atomic_write` in the event of failure [#295](https://github.com/logstash-plugins/logstash-input-file/pull/295)
|
4
|
+
- Refactor: unify event updates to happen in one place [#297](https://github.com/logstash-plugins/logstash-input-file/pull/297)
|
5
|
+
- Test: Actually retry tests on `RSpec::Expectations::ExpectationNotMetError` and retry instead of relying on timeout
|
6
|
+
[#297](https://github.com/logstash-plugins/logstash-input-file/pull/297)
|
7
|
+
|
1
8
|
## 4.3.0
|
2
9
|
- Add ECS Compatibility Mode [#291](https://github.com/logstash-plugins/logstash-input-file/pull/291)
|
3
10
|
|
data/lib/filewatch/helper.rb
CHANGED
@@ -30,6 +30,7 @@ module FileHelper
|
|
30
30
|
temp_file.binmode
|
31
31
|
return_val = yield temp_file
|
32
32
|
temp_file.close
|
33
|
+
new_stat = File.stat(temp_file)
|
33
34
|
|
34
35
|
# Overwrite original file with temp file
|
35
36
|
File.rename(temp_file.path, file_name)
|
@@ -37,8 +38,10 @@ module FileHelper
|
|
37
38
|
# Unable to get permissions of the original file => return
|
38
39
|
return return_val if old_stat.nil?
|
39
40
|
|
40
|
-
# Set correct uid/gid on new file
|
41
|
-
|
41
|
+
# Set correct uid/gid on new file if ownership is different.
|
42
|
+
if old_stat && (old_stat.gid != new_stat.gid || old_stat.uid != new_stat.uid)
|
43
|
+
File.chown(old_stat.uid, old_stat.gid, file_name) if old_stat
|
44
|
+
end
|
42
45
|
|
43
46
|
return_val
|
44
47
|
end
|
@@ -225,13 +225,24 @@ module FileWatch
|
|
225
225
|
|
226
226
|
# @return expired keys
|
227
227
|
def atomic_write(time)
|
228
|
-
|
229
|
-
|
228
|
+
logger.trace? && logger.trace("non_atomic_write: ", :time => time)
|
229
|
+
begin
|
230
|
+
FileHelper.write_atomically(@full_path) do |io|
|
231
|
+
@serializer.serialize(@sincedb, io, time.to_f)
|
232
|
+
end
|
233
|
+
rescue Errno::EPERM, Errno::EACCES => e
|
234
|
+
logger.warn("sincedb_write: unable to write atomically due to permissions error, falling back to non-atomic write: #{path} error:", :exception => e.class, :message => e.message)
|
235
|
+
@write_method = method(:non_atomic_write)
|
236
|
+
non_atomic_write(time)
|
237
|
+
rescue => e
|
238
|
+
logger.warn("sincedb_write: unable to write atomically, attempting non-atomic write: #{path} error:", :exception => e.class, :message => e.message)
|
239
|
+
non_atomic_write(time)
|
230
240
|
end
|
231
241
|
end
|
232
242
|
|
233
243
|
# @return expired keys
|
234
244
|
def non_atomic_write(time)
|
245
|
+
logger.trace? && logger.trace("non_atomic_write: ", :time => time)
|
235
246
|
File.open(@full_path, "w+") do |io|
|
236
247
|
@serializer.serialize(@sincedb, io, time.to_f)
|
237
248
|
end
|
Binary file
|
data/lib/logstash/inputs/file.rb
CHANGED
@@ -373,12 +373,11 @@ class File < LogStash::Inputs::Base
|
|
373
373
|
@completely_stopped.make_true
|
374
374
|
end # def run
|
375
375
|
|
376
|
-
def post_process_this(event)
|
376
|
+
def post_process_this(event, path)
|
377
|
+
event.set("[@metadata][path]", path)
|
377
378
|
event.set("[@metadata][host]", @host)
|
378
379
|
attempt_set(event, @source_host_field, @host)
|
379
|
-
|
380
|
-
source_path = event.get('[@metadata][path]') and
|
381
|
-
attempt_set(event, @source_path_field, source_path)
|
380
|
+
attempt_set(event, @source_path_field, path) if path
|
382
381
|
|
383
382
|
decorate(event)
|
384
383
|
@queue.get << event
|
data/logstash-input-file.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-file'
|
4
|
-
s.version = '4.3.
|
4
|
+
s.version = '4.3.1'
|
5
5
|
s.licenses = ['Apache-2.0']
|
6
6
|
s.summary = "Streams events from files"
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -338,7 +338,7 @@ describe LogStash::Inputs::File do
|
|
338
338
|
sincedb_content = File.read(sincedb_path).strip
|
339
339
|
expect( sincedb_content ).to_not be_empty
|
340
340
|
|
341
|
-
|
341
|
+
try(3) do
|
342
342
|
sleep(1.5) # > sincedb_clean_after
|
343
343
|
|
344
344
|
sincedb_content = File.read(sincedb_path).strip
|
@@ -363,7 +363,10 @@ describe LogStash::Inputs::File do
|
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
366
|
-
def wait_for_file_removal(path
|
367
|
-
|
366
|
+
def wait_for_file_removal(path)
|
367
|
+
timeout = interval
|
368
|
+
try(5) do
|
369
|
+
wait(timeout).for { File.exist?(path) }.to be_falsey
|
370
|
+
end
|
368
371
|
end
|
369
372
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|