fluentd 1.7.2 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce449e77af62c25fcef41773c3717738ec443550becdde0ca666710739f7eae
4
- data.tar.gz: 00d125b1c53ac99c8d2edf8b915909b91e07642e7fdad35154147a3b5a472416
3
+ metadata.gz: b09f1cbc0b3f4be0bc2dedfc142a1f6f0ed195df071ec809c019987de83c0993
4
+ data.tar.gz: bfdc00fe223cbbef68da3472d1d99518c3a52562dc10e2f720912f93d40cd8d3
5
5
  SHA512:
6
- metadata.gz: d78a18ab98f55b3568b0e401f87d80444d14b09b544fc4962a14bf821180c5f97a155332888961ce096adfa9ae6d01def4a154dc4a769939b6256846cf0b14b3
7
- data.tar.gz: cc36a5137a9753d9888f6669d04dbfe943d35d3cb030f5718fa439f957e8658632e96246b219151b73f46a2ac74191a0f6e87f049aae1fe446b2e62fc3c4a274
6
+ metadata.gz: 1ac20a296903da6869d0cd28baafa4ec2e4ac001b96820f03417f7ec2913a5bf52641db630f9814f02b10ddafa993c5157e461dffae09688fba9cdcd704922e4
7
+ data.tar.gz: 4bc9cce3c2083b0de6d256cd6ffaa07c57e9390de886491d5f0cbb35b181b9af2b3c3a48ab619b6cecc4f9355a7fb0b71ae87f403db0a49ba13198149770f92b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # v1.7
2
2
 
3
+ ## Release v1.7.4 - 2019/10/24
4
+
5
+ ### Enhancement
6
+
7
+ * in_http: Add `use_204_response` parameter to return proper 204 response instead of 200.
8
+ fluentd v2 will change this parameter to `true`.
9
+ https://github.com/fluent/fluentd/pull/2640
10
+
11
+ ### Bug fixes
12
+
13
+ * child_process helper: fix stderr blocking for discard case
14
+ https://github.com/fluent/fluentd/pull/2649
15
+ * log: Fix log rotation handling on Windows
16
+ https://github.com/fluent/fluentd/pull/2663
17
+
18
+ ## Release v1.7.3 - 2019/10/01
19
+
20
+ ### Enhancement
21
+
22
+ * in_syslog: Replace priority_key with severity_key
23
+ https://github.com/fluent/fluentd/pull/2636
24
+
25
+ ### Bug fixes
26
+
27
+ * out_forward: Fix nil error after purge obsoleted sockets in socket cache
28
+ https://github.com/fluent/fluentd/pull/2635
29
+ * fix typo in ChangeLog
30
+ https://github.com/fluent/fluentd/pull/2633
31
+
3
32
  ## Release v1.7.2 - 2019/09/19
4
33
 
5
34
  ### Enhancement
@@ -36,7 +65,7 @@
36
65
  https://github.com/fluent/fluentd/pull/2598
37
66
  * buf_file_single: fix duplicated path setting check
38
67
  https://github.com/fluent/fluentd/pull/2600
39
- * fix msgpack-ruby depedency to use recent feature
68
+ * fix msgpack-ruby dependency to use recent feature
40
69
  https://github.com/fluent/fluentd/pull/2606
41
70
 
42
71
 
@@ -640,7 +669,7 @@
640
669
 
641
670
  ## Release v1.0.0 - 2017/12/6
642
671
 
643
- See [CNCF announcment](https://www.cncf.io/blog/2017/12/06/fluentd-v1-0/) :)
672
+ See [CNCF announcement](https://www.cncf.io/blog/2017/12/06/fluentd-v1-0/) :)
644
673
 
645
674
  ### New features / Enhancements
646
675
 
@@ -910,7 +939,7 @@ See [CNCF announcment](https://www.cncf.io/blog/2017/12/06/fluentd-v1-0/) :)
910
939
  https://github.com/fluent/fluentd/pull/1492
911
940
  * parser: Allow escape sequence in Apache access log
912
941
  https://github.com/fluent/fluentd/pull/1479
913
- * config: Add actual value in the placholder error message
942
+ * config: Add actual value in the placeholder error message
914
943
  https://github.com/fluent/fluentd/pull/1497
915
944
  * log: Add Fluent::Log#<< to support some SDKs
916
945
  https://github.com/fluent/fluentd/pull/1478
@@ -1227,7 +1256,7 @@ See [CNCF announcment](https://www.cncf.io/blog/2017/12/06/fluentd-v1-0/) :)
1227
1256
  https://github.com/fluent/fluentd/pull/1067
1228
1257
  * filter_record_transformer: Fix to prevent overwriting reserved placeholder keys
1229
1258
  https://github.com/fluent/fluentd/pull/1176
1230
- * Migrate some build-in plugins into v0.14 API
1259
+ * Migrate some built-in plugins into v0.14 API
1231
1260
  https://github.com/fluent/fluentd/pull/1149
1232
1261
  https://github.com/fluent/fluentd/pull/1151
1233
1262
  * Update dependencies
@@ -311,6 +311,16 @@ exit 0 if early_exit
311
311
 
312
312
  require 'fluent/supervisor'
313
313
  if opts[:supervise]
314
+ if Fluent.windows?
315
+ if opts[:log_path] && opts[:log_path] != "-"
316
+ if opts[:log_rotate_age] || opts[:log_rotate_size]
317
+ require 'pathname'
318
+
319
+ log_path = Pathname(opts[:log_path]).sub_ext("-supervisor#{Pathname(opts[:log_path]).extname}").to_s
320
+ opts[:log_path] = log_path
321
+ end
322
+ end
323
+ end
314
324
  Fluent::Supervisor.new(opts).run_supervisor
315
325
  else
316
326
  if opts[:standalone_worker] && opts[:workers] && opts[:workers] > 1
@@ -58,6 +58,8 @@ module Fluent::Plugin
58
58
  config_param :cors_allow_origins, :array, default: nil
59
59
  desc 'Respond with empty gif image of 1x1 pixel.'
60
60
  config_param :respond_with_empty_img, :bool, default: false
61
+ desc 'Respond status code with 204.'
62
+ config_param :use_204_response, :bool, default: false
61
63
 
62
64
  config_section :parse do
63
65
  config_set_default :@type, 'in_http'
@@ -152,7 +154,11 @@ module Fluent::Plugin
152
154
  if @respond_with_empty_img
153
155
  return ["200 OK", {'Content-Type'=>'image/gif; charset=utf-8'}, EMPTY_GIF_IMAGE]
154
156
  else
155
- return ["200 OK", {'Content-Type'=>'text/plain'}, ""]
157
+ if @use_204_response
158
+ return ["204 No Content", {}]
159
+ else
160
+ return ["200 OK", {'Content-Type'=>'text/plain'}, ""]
161
+ end
156
162
  end
157
163
  end
158
164
 
@@ -219,7 +225,11 @@ module Fluent::Plugin
219
225
  if @respond_with_empty_img
220
226
  return ["200 OK", {'Content-Type'=>'image/gif; charset=utf-8'}, EMPTY_GIF_IMAGE]
221
227
  else
222
- return ["200 OK", {'Content-Type'=>'text/plain'}, ""]
228
+ if @use_204_response
229
+ return ["204 No Content", {}]
230
+ else
231
+ return ["200 OK", {'Content-Type'=>'text/plain'}, ""]
232
+ end
223
233
  end
224
234
  end
225
235
 
@@ -56,7 +56,7 @@ module Fluent::Plugin
56
56
  23 => 'local7'
57
57
  }
58
58
 
59
- PRIORITY_MAP = {
59
+ SEVERITY_MAP = {
60
60
  0 => 'emerg',
61
61
  1 => 'alert',
62
62
  2 => 'crit',
@@ -91,8 +91,8 @@ module Fluent::Plugin
91
91
  config_param :resolve_hostname, :bool, default: nil
92
92
  desc 'The field name of source address of sender.'
93
93
  config_param :source_address_key, :string, default: nil
94
- desc 'The field name of the priority.'
95
- config_param :priority_key, :string, default: nil
94
+ desc 'The field name of the severity.'
95
+ config_param :severity_key, :string, default: nil, alias: :priority_key
96
96
  desc 'The field name of the facility.'
97
97
  config_param :facility_key, :string, default: nil
98
98
 
@@ -119,6 +119,10 @@ module Fluent::Plugin
119
119
 
120
120
  super
121
121
 
122
+ if conf.has_key?('priority_key')
123
+ log.warn "priority_key is deprecated. Use severity_key instead"
124
+ end
125
+
122
126
  @use_default = false
123
127
 
124
128
  @parser = parser_create
@@ -233,14 +237,14 @@ module Fluent::Plugin
233
237
 
234
238
  pri ||= record.delete('pri')
235
239
  facility = FACILITY_MAP[pri >> 3]
236
- priority = PRIORITY_MAP[pri & 0b111]
240
+ severity = SEVERITY_MAP[pri & 0b111]
237
241
 
238
- record[@priority_key] = priority if @priority_key
242
+ record[@severity_key] = severity if @severity_key
239
243
  record[@facility_key] = facility if @facility_key
240
244
  record[@source_address_key] = sock.remote_addr if @source_address_key
241
245
  record[@source_hostname_key] = sock.remote_host if @source_hostname_key
242
246
 
243
- tag = "#{@tag}.#{facility}.#{priority}"
247
+ tag = "#{@tag}.#{facility}.#{severity}"
244
248
  emit(tag, time, record)
245
249
  end
246
250
  rescue => e
@@ -81,7 +81,9 @@ module Fluent::Plugin
81
81
  end
82
82
  end
83
83
  end
84
- @available_sockets = @available_sockets.select { |_, v| !v.empty? }
84
+
85
+ # reuse same object (@available_sockets)
86
+ @available_sockets.reject! { |_, v| v.empty? }
85
87
 
86
88
  sockets += @inactive_sockets
87
89
  @inactive_sockets.clear
@@ -257,7 +257,8 @@ module Fluent
257
257
  readio = writeio = stderrio = wait_thread = nil
258
258
  readio_in_use = writeio_in_use = stderrio_in_use = false
259
259
 
260
- if !mode.include?(:stderr) && !mode.include?(:read_with_stderr) && stderr != :discard # connect
260
+ if !mode.include?(:stderr) && !mode.include?(:read_with_stderr)
261
+ spawn_opts[:err] = IO::NULL if stderr == :discard
261
262
  writeio, readio, wait_thread = *Open3.popen2(*spawn_args, spawn_opts)
262
263
  elsif mode.include?(:read_with_stderr)
263
264
  writeio, readio, wait_thread = *Open3.popen2e(*spawn_args, spawn_opts)
@@ -281,7 +282,7 @@ module Fluent
281
282
  stderrio.set_encoding(external_encoding, internal_encoding, encoding_options)
282
283
  stderrio_in_use = true
283
284
  else
284
- stderrio.reopen(IO::NULL) if stderrio && stderrio == :discard
285
+ stderrio.reopen(IO::NULL) if stderrio && stderr == :discard
285
286
  end
286
287
 
287
288
  pid = wait_thread.pid # wait_thread => Process::Waiter
@@ -353,13 +353,21 @@ module Fluent
353
353
  @log_rotate_size = log_rotate_size
354
354
  end
355
355
 
356
+ def worker_id_suffixed_path(worker_id, path)
357
+ require 'pathname'
358
+
359
+ Pathname(path).sub_ext("-#{worker_id}#{Pathname(path).extname}").to_s
360
+ end
361
+
356
362
  def init(process_type, worker_id)
357
363
  @opts[:process_type] = process_type
358
364
  @opts[:worker_id] = worker_id
359
365
 
360
366
  if @path && @path != "-"
361
367
  @logdev = if @log_rotate_age || @log_rotate_size
362
- Fluent::LogDeviceIO.new(@path, shift_age: @log_rotate_age, shift_size: @log_rotate_size)
368
+ Fluent::LogDeviceIO.new(Fluent.windows? ?
369
+ worker_id_suffixed_path(worker_id, @path) : @path,
370
+ shift_age: @log_rotate_age, shift_size: @log_rotate_size)
363
371
  else
364
372
  File.open(@path, "a")
365
373
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.7.2'
19
+ VERSION = '1.7.4'
20
20
 
21
21
  end
@@ -5,7 +5,7 @@ require 'timecop'
5
5
 
6
6
  class SocketCacheTest < Test::Unit::TestCase
7
7
  sub_test_case 'checkout_or' do
8
- test 'when gived key does not exist' do
8
+ test 'when given key does not exist' do
9
9
  c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log)
10
10
  sock = mock!.open { 'socket' }.subject
11
11
  assert_equal('socket', c.checkout_or('key') { sock.open })
@@ -38,6 +38,16 @@ class SocketCacheTest < Test::Unit::TestCase
38
38
  sock = mock!.open { new_sock }.subject
39
39
  assert_equal(new_sock, c.checkout_or('key') { sock.open })
40
40
  end
41
+
42
+ test 'reuse same hash object after calling purge_obsolete_socks' do
43
+ c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log)
44
+ c.checkout_or('key') { 'socket' }
45
+ c.purge_obsolete_socks
46
+
47
+ assert_nothing_raised(NoMethodError) do
48
+ c.checkout_or('key') { 'new socket' }
49
+ end
50
+ end
41
51
  end
42
52
 
43
53
  sub_test_case 'checkin' do
@@ -495,7 +495,7 @@ class BufferFileChunkTest < Test::Unit::TestCase
495
495
  end
496
496
  end
497
497
 
498
- test 'ensure to remove metadata file if #write_metadata raise an error becuase of disk full' do
498
+ test 'ensure to remove metadata file if #write_metadata raise an error because of disk full' do
499
499
  chunk_path = File.join(@chunkdir, 'test.*.log')
500
500
  stub(Fluent::UniqueId).hex(anything) { 'id' } # to fix chunk id
501
501
 
@@ -32,6 +32,7 @@ class HttpInputTest < Test::Unit::TestCase
32
32
  body_size_limit 10m
33
33
  keepalive_timeout 5
34
34
  respond_with_empty_img true
35
+ use_204_response false
35
36
  ]
36
37
 
37
38
  def create_driver(conf=CONFIG)
@@ -549,8 +550,8 @@ class HttpInputTest < Test::Unit::TestCase
549
550
  assert_equal_event_time time, d.events[1][1]
550
551
  end
551
552
 
552
- def test_resonse_with_empty_img
553
- d = create_driver(CONFIG + "respond_with_empty_img true")
553
+ def test_response_with_empty_img
554
+ d = create_driver(CONFIG)
554
555
  assert_equal true, d.instance.respond_with_empty_img
555
556
 
556
557
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -577,6 +578,61 @@ class HttpInputTest < Test::Unit::TestCase
577
578
  assert_equal_event_time time, d.events[1][1]
578
579
  end
579
580
 
581
+ def test_response_without_empty_img
582
+ d = create_driver(CONFIG + "respond_with_empty_img false")
583
+ assert_equal false, d.instance.respond_with_empty_img
584
+
585
+ time = event_time("2011-01-02 13:14:15 UTC")
586
+ time_i = time.to_i
587
+ events = [
588
+ ["tag1", time, {"a"=>1}],
589
+ ["tag2", time, {"a"=>2}],
590
+ ]
591
+ res_codes = []
592
+ res_bodies = []
593
+
594
+ d.run do
595
+ events.each do |tag, _t, record|
596
+ res = post("/#{tag}", {"json"=>record.to_json, "time"=>time_i.to_s})
597
+ res_codes << res.code
598
+ end
599
+ end
600
+ assert_equal ["200", "200"], res_codes
601
+ assert_equal [], res_bodies
602
+ assert_equal events, d.events
603
+ assert_equal_event_time time, d.events[0][1]
604
+ assert_equal_event_time time, d.events[1][1]
605
+ end
606
+
607
+ def test_response_use_204_response
608
+ d = create_driver(CONFIG + %[
609
+ respond_with_empty_img false
610
+ use_204_response true
611
+ ])
612
+ assert_equal true, d.instance.use_204_response
613
+
614
+ time = event_time("2011-01-02 13:14:15 UTC")
615
+ time_i = time.to_i
616
+ events = [
617
+ ["tag1", time, {"a"=>1}],
618
+ ["tag2", time, {"a"=>2}],
619
+ ]
620
+ res_codes = []
621
+ res_bodies = []
622
+
623
+ d.run do
624
+ events.each do |tag, _t, record|
625
+ res = post("/#{tag}", {"json"=>record.to_json, "time"=>time_i.to_s})
626
+ res_codes << res.code
627
+ end
628
+ end
629
+ assert_equal ["204", "204"], res_codes
630
+ assert_equal [], res_bodies
631
+ assert_equal events, d.events
632
+ assert_equal_event_time time, d.events[0][1]
633
+ assert_equal_event_time time, d.events[1][1]
634
+ end
635
+
580
636
  def test_cors_allowed
581
637
  d = create_driver(CONFIG + "cors_allow_origins [\"http://foo.com\"]")
582
638
  assert_equal ["http://foo.com"], d.instance.cors_allow_origins
@@ -217,11 +217,15 @@ EOS
217
217
  compare_test_result(d.events, tests, {host: host})
218
218
  end
219
219
 
220
- def test_msg_size_with_priority_key
221
- d = create_driver([CONFIG, 'priority_key priority'].join("\n"))
220
+ data(
221
+ severity_key: 'severity_key',
222
+ priority_key: 'priority_key',
223
+ )
224
+ def test_msg_size_with_severity_key(param_name)
225
+ d = create_driver([CONFIG, "#{param_name} severity"].join("\n"))
222
226
  tests = create_test_case
223
227
 
224
- priority = 'info'
228
+ severity = 'info'
225
229
  d.run(expect_emits: 2) do
226
230
  u = UDPSocket.new
227
231
  u.connect('127.0.0.1', PORT)
@@ -231,7 +235,7 @@ EOS
231
235
  end
232
236
 
233
237
  assert(d.events.size > 0)
234
- compare_test_result(d.events, tests, {priority: priority})
238
+ compare_test_result(d.events, tests, {severity: severity})
235
239
  end
236
240
 
237
241
  def test_msg_size_with_facility_key
@@ -311,7 +315,7 @@ EOS
311
315
  assert_equal(options[:host], events[i][2]['source_host']) if options[:host]
312
316
  assert_equal(options[:address], events[i][2]['source_address']) if options[:address]
313
317
  assert_equal(options[:hostname], events[i][2]['source_hostname']) if options[:hostname]
314
- assert_equal(options[:priority], events[i][2]['priority']) if options[:priority]
318
+ assert_equal(options[:severity], events[i][2]['severity']) if options[:severity]
315
319
  assert_equal(options[:facility], events[i][2]['facility']) if options[:facility]
316
320
  }
317
321
  end
@@ -1112,7 +1112,7 @@ class BufferedOutputTest < Test::Unit::TestCase
1112
1112
  assert_equal(0, @i.write_count)
1113
1113
 
1114
1114
  Timecop.freeze(Time.parse('2019-02-09 00:00:12 +0900'))
1115
- # wirte should be called in few seconds since
1115
+ # write should be called in few seconds since
1116
1116
  # running interval of enque thread is timekey_wait / 11.0.
1117
1117
  waiting(5){ sleep 0.1 until @i.write_count == 1 }
1118
1118
  end
@@ -124,6 +124,43 @@ class ChildProcessTest < Test::Unit::TestCase
124
124
  assert_equal expected, ary
125
125
  end
126
126
 
127
+ test 'can execute external command at just once, which can handle both of read and write. Ignore stderr message/no block' do
128
+ m = Mutex.new
129
+ ary = []
130
+ Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
131
+ ran = false
132
+ # lots of stderr message should not be blocked and message should not be printed in test.
133
+ cmd = "ruby -e 'while !STDIN.eof? && line = STDIN.readline; STDERR.puts line.chomp * 1000; STDOUT.puts line.chomp; STDOUT.flush rescue nil; end'"
134
+ @d.child_process_execute(:t2_and_ignore_stderr, cmd, mode: [:write, :read]) do |writeio, readio|
135
+ m.lock
136
+ ran = true
137
+
138
+ [[1,2],[3,4],[5,6]].each do |i,j|
139
+ writeio.write "my data#{i}\n"
140
+ writeio.write "my data#{j}\n"
141
+ writeio.flush
142
+ end
143
+ writeio.close
144
+
145
+ while line = readio.readline
146
+ ary << line
147
+ end
148
+ m.unlock
149
+ end
150
+ begin
151
+ sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran
152
+ m.lock
153
+ rescue
154
+ ensure
155
+ m.unlock
156
+ end
157
+ end
158
+
159
+ assert_equal [], @d.log.out.logs
160
+ expected = (1..6).map{|i| "my data#{i}\n" }
161
+ assert_equal expected, ary
162
+ end
163
+
127
164
  test 'can execute external command at just once, which can handle all of read, write and stderr' do
128
165
  m = Mutex.new
129
166
  ary1 = []
@@ -710,7 +710,7 @@ EOC
710
710
  end
711
711
  end
712
712
 
713
- test 'raises configuration error for worker id collisions on multi workers syntax when multi avaliable worker_ids are left' do
713
+ test 'raises configuration error for worker id collisions on multi workers syntax when multi available worker_ids are left' do
714
714
  errmsg = "specified worker_id<1> collisions is detected on <worker> directive. Available worker id(s): [2, 3]"
715
715
  assert_raise Fluent::ConfigError.new(errmsg) do
716
716
  conf = <<-EOC
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-20 00:00:00.000000000 Z
11
+ date: 2019-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack