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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0389c6d97f2957a0701da71d3cbcc7865ed51745e2eb49bb0a6327097865a921'
4
- data.tar.gz: 7bec1b1e810008641a3286406c7402e82dcb62d6132b5f39cfa035c2ec168829
3
+ metadata.gz: 1db5895e894194d27fa746f21e316c9bc8093f32d567023fd087e0be14a20839
4
+ data.tar.gz: 8c98ccd955718ecd48c46809345b665ab4f47a5dc1fe40fccf3dacedb8618283
5
5
  SHA512:
6
- metadata.gz: 3f83c7fcac2202d6380f7e54ecf231530ea09adf8e7019cef5d5935a2c024d85161b4749e7d1f355f8b38b59d26d57d95035c89abe0cb6b555edf0391b81475d
7
- data.tar.gz: 0d939d35f02541ca57ac6a1735d6c008ba985ed977842f78a9ad95011e3146d8c2e3a939020354532d53b7975c5a572ffa9702f9ce82a36a4af235c50b6efaca
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
 
@@ -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
- File.chown(old_stat.uid, old_stat.gid, file_name) if old_stat
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
- FileHelper.write_atomically(@full_path) do |io|
229
- @serializer.serialize(@sincedb, io, time.to_f)
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
@@ -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
@@ -40,8 +40,7 @@ module LogStash module Inputs
40
40
  end
41
41
 
42
42
  def process_event(event)
43
- event.set("[@metadata][path]", path)
44
- input.post_process_this(event)
43
+ input.post_process_this(event, path)
45
44
  end
46
45
 
47
46
  end
@@ -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.0'
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
- Stud.try(3.times) do
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, timeout: 3 * interval)
367
- wait(timeout).for { File.exist?(path) }.to be_falsey
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.0
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-04-30 00:00:00.000000000 Z
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