fluentd 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: f7457e2a191772c11ca520188030ea3ef06c211d
4
- data.tar.gz: 2ae8a9864a31245d3fca6756cb4f39c82aed53fc
3
+ metadata.gz: '08745174bdefc09fdc359003c6acb65f63d58bac'
4
+ data.tar.gz: 45e36b62fe808b05273d98eab2ca69c0e46b8c93
5
5
  SHA512:
6
- metadata.gz: 6ad103cd892630b1c15452a4749ddba854b2ca73e87bbe252bdf75a7a85964589801e21d002bf6140b23d107dbed207e856a0eaee275ea04c895ebb5df31d361
7
- data.tar.gz: 44cfc8efcc83ac52e55fb35afcc93486dbb44ed9ee84ac20fa8da335a011812f04eb256bdb55d741facc8bdbb5e87728d75c11f118fe370f7690b553b082223a
6
+ metadata.gz: b855e7e95bd3d6b29b50a6b4ba3321a4fd4166c4e0ef8bd4ab104252bd1b6b738a16eb8a93eae35cbf4b1daf7a8ad209d7ef1cb3be508633071d9490ccb15ffb
7
+ data.tar.gz: 90754b2ba1765da45e47906866dbb3cfd77bd5373134e9f160b58f3bab3832e1db144124a2665cec19a7e731c70620edf7f14a9d453cd452646263dcc4b14b74
@@ -13,7 +13,9 @@ matrix:
13
13
  os: linux
14
14
  - rvm: 2.3.3
15
15
  os: linux
16
- - rvm: 2.4.2
16
+ - rvm: 2.4.3
17
+ os: linux
18
+ - rvm: 2.5.0
17
19
  os: linux
18
20
  - rvm: ruby-head
19
21
  os: linux
@@ -47,6 +49,9 @@ branches:
47
49
  - v0.12
48
50
  - v0.14
49
51
 
52
+ before_install:
53
+ - gem update --system
54
+
50
55
  sudo: false
51
56
  dist: trusty # for TLSv1.2 support
52
57
 
@@ -1,4 +1,32 @@
1
- # v1.0
1
+ # v1.1
2
+
3
+ ## Release v1.1.1 - 2018/03/05
4
+
5
+ ### Enhancements
6
+
7
+ * in_debug_agent: Support multi worker environment
8
+ https://github.com/fluent/fluentd/pull/1869
9
+ * in_forward: Improve SSL setup to support mutual TLS
10
+ https://github.com/fluent/fluentd/pull/1861
11
+ * buf_file: Skip and delete broken file chunks to avoid unsuccessful retry in resume
12
+ https://github.com/fluent/fluentd/pull/1874
13
+ * command: Show fluentd version for debug purpose
14
+ https://github.com/fluent/fluentd/pull/1839
15
+
16
+ ### Bug fixes
17
+
18
+ * in_forward: Do not close connection until write is complete on failed auth PONG
19
+ https://github.com/fluent/fluentd/pull/1835
20
+ * in_tail: Fix IO event race condition during shutdown
21
+ https://github.com/fluent/fluentd/pull/1876
22
+ * in_http: Emit event time instead of raw time value in batch
23
+ https://github.com/fluent/fluentd/pull/1850
24
+ * parser_json: Add EncodingError to rescue list for oj 3.x.
25
+ https://github.com/fluent/fluentd/pull/1875
26
+ * config: Fix config_param for string type with frozen string
27
+ https://github.com/fluent/fluentd/pull/1838
28
+ * timer: Fix a bug to leak non-repeating timer watchers
29
+ https://github.com/fluent/fluentd/pull/1864
2
30
 
3
31
  ## Release v1.1.0 - 2018/01/17
4
32
 
@@ -25,6 +53,8 @@
25
53
  https://github.com/fluent/fluentd/pull/1805
26
54
  * time: Fix the method for TimeFormatter#call
27
55
  https://github.com/fluent/fluentd/pull/1813
56
+
57
+ # v1.0
28
58
 
29
59
  ## Release v1.0.2 - 2017/12/17
30
60
 
@@ -35,7 +35,7 @@ After 6 months a maintainer will be made an "owner" of the GitHub organization.
35
35
 
36
36
  ## Projects
37
37
 
38
- The fluent organization is open to receive new projects under it umbrella. To apply a project as part of the __fluent__ organization, it have to met the following criteria:
38
+ The fluent organization is open to receive new sub-projects under it umbrella. To apply a project as part of the __fluent__ organization, it have to met the following criteria:
39
39
 
40
40
  - Licensed under the terms of the Apache License v2.0
41
41
  - Project have been active for at least one year since it inception
@@ -46,7 +46,7 @@ The fluent organization is open to receive new projects under it umbrella. To ap
46
46
  - Metering
47
47
  - Be supported by 2/3 majority of organization
48
48
 
49
- The submission process starts as a Pull Request on Fluentd repository with the required information mentioned above.
49
+ The submission process starts as a Pull Request on Fluentd repository with the required information mentioned above. Once a project is accepted, it's considered a __CNCF sub-project under the umbrella of Fluentd__
50
50
 
51
51
  ## Code of Conduct
52
52
 
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -22,6 +22,7 @@ require 'fluent/formatter'
22
22
  require 'fluent/plugin'
23
23
  require 'fluent/config/element'
24
24
  require 'fluent/engine'
25
+ require 'fluent/version'
25
26
 
26
27
  class FluentBinlogReader
27
28
  SUBCOMMAND = %w(cat head formats)
@@ -49,7 +50,14 @@ HELP
49
50
 
50
51
  def command
51
52
  command = @argv.shift
52
- if !command || !SUBCOMMAND.include?(command)
53
+ if command
54
+ if command == '--version'
55
+ puts "#{File.basename($PROGRAM_NAME)} #{Fluent::VERSION}"
56
+ exit 0
57
+ elsif !SUBCOMMAND.include?(command)
58
+ usage "'#{command}' is not supported: Required subcommand : #{SUBCOMMAND.join(' | ')}"
59
+ end
60
+ else
53
61
  usage "Required subcommand : #{SUBCOMMAND.join(' | ')}"
54
62
  end
55
63
 
@@ -70,6 +78,7 @@ module BinlogReaderCommand
70
78
 
71
79
  @options = { plugin: [] }
72
80
  @opt_parser = OptionParser.new do |opt|
81
+ opt.version = Fluent::VERSION
73
82
  opt.separator 'Options:'
74
83
 
75
84
  opt.on('-p DIR', '--plugin', 'add library directory path') do |v|
@@ -1,6 +1,7 @@
1
1
  require 'openssl'
2
2
  require 'optparse'
3
3
  require 'fileutils'
4
+ require 'fluent/version'
4
5
 
5
6
  module Fluent
6
7
  class CaGenerate
@@ -12,7 +13,7 @@ module Fluent
12
13
  cert_common_name: 'Fluentd Forward CA',
13
14
  }
14
15
  HELP_TEXT = <<HELP
15
- Usage: fluent-ca-genrate DIR_PATH PRIVATE_KEY_PASSPHRASE [--country COUNTRY] [--state STATE] [--locality LOCALITY] [--common-name COMMON_NAME]
16
+ Usage: fluent-ca-generate DIR_PATH PRIVATE_KEY_PASSPHRASE [--country COUNTRY] [--state STATE] [--locality LOCALITY] [--common-name COMMON_NAME]
16
17
  HELP
17
18
 
18
19
  def initialize(argv = ARGV)
@@ -145,6 +146,7 @@ HELP
145
146
 
146
147
  def configure_option_parser
147
148
  @opt_parser.banner = HELP_TEXT
149
+ @opt_parser.version = Fluent::VERSION
148
150
 
149
151
  @opt_parser.on('--key-length [KEY_LENGTH]',
150
152
  "configure key length. (default: #{DEFAULT_OPTIONS[:private_key_length]})") do |v|
@@ -18,10 +18,12 @@ require 'optparse'
18
18
  require 'fluent/env'
19
19
  require 'fluent/time'
20
20
  require 'fluent/msgpack_factory'
21
+ require 'fluent/version'
21
22
 
22
23
  op = OptionParser.new
23
24
 
24
25
  op.banner += " <tag>"
26
+ op.version = Fluent::VERSION
25
27
 
26
28
  port = 24224
27
29
  host = '127.0.0.1'
@@ -22,6 +22,7 @@ require "fluent/env"
22
22
  require "fluent/engine"
23
23
  require "fluent/system_config"
24
24
  require "fluent/config/element"
25
+ require 'fluent/version'
25
26
 
26
27
  class FluentPluginConfigFormatter
27
28
 
@@ -210,6 +211,7 @@ class FluentPluginConfigFormatter
210
211
 
211
212
  def prepare_option_parser
212
213
  @parser = OptionParser.new
214
+ @parser.version = Fluent::VERSION
213
215
  @parser.banner = <<BANNER
214
216
  Usage: #{$0} [options] <type> <name>
215
217
 
@@ -21,6 +21,7 @@ require "erb"
21
21
  require "open-uri"
22
22
 
23
23
  require "fluent/registry"
24
+ require 'fluent/version'
24
25
 
25
26
  class FluentPluginGenerator
26
27
  attr_reader :type, :name
@@ -91,6 +92,7 @@ class FluentPluginGenerator
91
92
 
92
93
  def prepare_parser
93
94
  @parser = OptionParser.new
95
+ @parser.version = Fluent::VERSION
94
96
  @parser.banner = <<BANNER
95
97
  Usage: fluent-plugin-generate [options] <type> <name>
96
98
 
@@ -64,7 +64,11 @@ module Fluent
64
64
  end
65
65
  end
66
66
 
67
- STRING_TYPE = Proc.new { |val, opts| val.to_s.force_encoding(Encoding::UTF_8) }
67
+ STRING_TYPE = Proc.new { |val, opts|
68
+ v = val.to_s
69
+ v = v.frozen? ? v.dup : v # config_param can't assume incoming string is mutable
70
+ v.force_encoding(Encoding::UTF_8)
71
+ }
68
72
  ENUM_TYPE = Proc.new { |val, opts|
69
73
  s = val.to_sym
70
74
  list = opts[:list]
@@ -141,7 +141,13 @@ module Fluent
141
141
  next
142
142
  end
143
143
 
144
- chunk = Fluent::Plugin::Buffer::FileChunk.new(m, path, mode) # file chunk resumes contents of metadata
144
+ begin
145
+ chunk = Fluent::Plugin::Buffer::FileChunk.new(m, path, mode) # file chunk resumes contents of metadata
146
+ rescue Fluent::Plugin::Buffer::FileChunk::FileChunkError => e
147
+ handle_broken_files(path, mode, e)
148
+ next
149
+ end
150
+
145
151
  case chunk.state
146
152
  when :staged
147
153
  stage[chunk.metadata] = chunk
@@ -167,6 +173,12 @@ module Fluent
167
173
 
168
174
  return chunk
169
175
  end
176
+
177
+ def handle_broken_files(path, mode, e)
178
+ log.error "found broken chunk file during resume. Deleted corresponding files:", :path => path, :mode => mode, :err_msg => e.message
179
+ # After support 'backup_dir' feature, these files are moved to backup_dir instead of unlink.
180
+ File.unlink(path, path + '.meta') rescue nil
181
+ end
170
182
  end
171
183
  end
172
184
  end
@@ -22,6 +22,8 @@ module Fluent
22
22
  module Plugin
23
23
  class Buffer
24
24
  class FileChunk < Chunk
25
+ class FileChunkError < StandardError; end
26
+
25
27
  ### buffer path user specified : /path/to/directory/user_specified_prefix.*.log
26
28
  ### buffer chunk path : /path/to/directory/user_specified_prefix.b513b61c9791029c2513b61c9791029c2.log
27
29
  ### buffer chunk metadata path : /path/to/directory/user_specified_prefix.b513b61c9791029c2513b61c9791029c2.log.meta
@@ -309,6 +311,8 @@ module Fluent
309
311
  # staging buffer chunk without metadata is classic buffer chunk file
310
312
  # and it should be enqueued immediately
311
313
  if File.exist?(@meta_path)
314
+ raise FileChunkError, "staged file chunk is empty" if File.size(@path).zero?
315
+
312
316
  @chunk = File.open(@path, 'rb+')
313
317
  @chunk.set_encoding(Encoding::ASCII_8BIT)
314
318
  @chunk.sync = true
@@ -319,7 +323,13 @@ module Fluent
319
323
  @meta.set_encoding(Encoding::ASCII_8BIT)
320
324
  @meta.sync = true
321
325
  @meta.binmode
322
- restore_metadata(@meta.read)
326
+ begin
327
+ restore_metadata(@meta.read)
328
+ rescue => e
329
+ @chunk.close
330
+ @meta.close
331
+ raise FileChunkError, "staged meta file is broken. #{e.message}"
332
+ end
323
333
  @meta.seek(0, IO::SEEK_SET)
324
334
 
325
335
  @state = :staged
@@ -345,6 +355,8 @@ module Fluent
345
355
 
346
356
  def load_existing_enqueued_chunk(path)
347
357
  @path = path
358
+ raise FileChunkError, "enqueued file chunk is empty" if File.size(@path).zero?
359
+
348
360
  @chunk = File.open(@path, 'rb')
349
361
  @chunk.set_encoding(Encoding::ASCII_8BIT)
350
362
  @chunk.binmode
@@ -354,7 +366,12 @@ module Fluent
354
366
 
355
367
  @meta_path = @path + '.meta'
356
368
  if File.readable?(@meta_path)
357
- restore_metadata(File.open(@meta_path){|f| f.set_encoding(Encoding::ASCII_8BIT); f.binmode; f.read })
369
+ begin
370
+ restore_metadata(File.open(@meta_path){|f| f.set_encoding(Encoding::ASCII_8BIT); f.binmode; f.read })
371
+ rescue => e
372
+ @chunk.close
373
+ raise FileChunkError, "enqueued meta file is broken. #{e.message}"
374
+ end
358
375
  else
359
376
  restore_metadata_partially(@chunk)
360
377
  end
@@ -34,6 +34,9 @@ module Fluent::Plugin
34
34
 
35
35
  def configure(conf)
36
36
  super
37
+ if system_config.workers > 1
38
+ @port += fluentd_worker_id
39
+ end
37
40
  if @unix_path
38
41
  unless ::Fluent::FileUtil.writable?(@unix_path)
39
42
  raise Fluent::ConfigError, "in_debug_agent: `#{@unix_path}` is not writable"
@@ -41,6 +44,10 @@ module Fluent::Plugin
41
44
  end
42
45
  end
43
46
 
47
+ def multi_workers_ready?
48
+ @unix_path.nil?
49
+ end
50
+
44
51
  def start
45
52
  super
46
53
 
@@ -50,7 +57,7 @@ module Fluent::Plugin
50
57
  else
51
58
  uri = "druby://#{@bind}:#{@port}"
52
59
  end
53
- log.info "listening dRuby", uri: uri, object: @object
60
+ log.info "listening dRuby", uri: uri, object: @object, worker: fluentd_worker_id
54
61
  obj = eval(@object)
55
62
  @server = DRb::DRbServer.new(uri, obj)
56
63
  end
@@ -199,8 +199,8 @@ module Fluent::Plugin
199
199
  when :pingpong
200
200
  success, reason_or_salt, shared_key = check_ping(msg, conn.remote_addr, user_auth_salt, nonce)
201
201
  unless success
202
+ conn.on(:write_complete) { |c| c.close }
202
203
  send_data.call(serializer, generate_pong(false, reason_or_salt, nonce, shared_key))
203
- conn.close
204
204
  next
205
205
  end
206
206
  send_data.call(serializer, generate_pong(true, reason_or_salt, nonce, shared_key))
@@ -202,7 +202,11 @@ module Fluent::Plugin
202
202
  if @add_remote_addr
203
203
  single_record['REMOTE_ADDR'] = params['REMOTE_ADDR']
204
204
  end
205
- single_time = single_record.delete("time") || time
205
+ single_time = if t = single_record.delete('time')
206
+ Fluent::EventTime.from_time(Time.at(t))
207
+ else
208
+ time
209
+ end
206
210
  mes.add(single_time, single_record)
207
211
  end
208
212
  router.emit_stream(tag, mes)
@@ -678,10 +678,15 @@ module Fluent::Plugin
678
678
  @iobuf = ''.force_encoding('ASCII-8BIT')
679
679
  @lines = []
680
680
  @io = nil
681
+ @notify_mutex = Mutex.new
681
682
  @watcher.log.info "following tail of #{@watcher.path}"
682
683
  end
683
684
 
684
685
  def on_notify
686
+ @notify_mutex.synchronize { handle_notify }
687
+ end
688
+
689
+ def handle_notify
685
690
  with_io do |io|
686
691
  begin
687
692
  read_more = false
@@ -62,7 +62,7 @@ module Fluent
62
62
  r = @load_proc.call(text)
63
63
  time, record = convert_values(parse_time(r), r)
64
64
  yield time, record
65
- rescue @error_class
65
+ rescue @error_class, EncodingError # EncodingError is for oj 3.x or later
66
66
  yield nil, nil
67
67
  end
68
68
 
@@ -33,6 +33,11 @@ module Fluent
33
33
  ctx.ciphers = ciphers
34
34
  end
35
35
 
36
+ if conf.client_cert_auth
37
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
38
+ end
39
+
40
+ ctx.ca_file = conf.ca_path
36
41
  ctx.cert = cert
37
42
  ctx.key = key
38
43
  if extra && !extra.empty?
@@ -43,6 +43,15 @@ module Fluent
43
43
  end
44
44
  end
45
45
 
46
+ def event_loop_detach(watcher)
47
+ if watcher.attached?
48
+ watcher.detach
49
+ end
50
+ @_event_loop_mutex.synchronize do
51
+ @_event_loop_attached_watchers.delete(watcher)
52
+ end
53
+ end
54
+
46
55
  def event_loop_wait_until_start
47
56
  sleep(0.1) until event_loop_running?
48
57
  end
@@ -237,7 +237,7 @@ module Fluent
237
237
 
238
238
  SERVER_TRANSPORT_PARAMS = [
239
239
  :protocol, :version, :ciphers, :insecure,
240
- :cert_path, :private_key_path, :private_key_passphrase,
240
+ :ca_path, :cert_path, :private_key_path, :private_key_passphrase, :client_cert_auth,
241
241
  :ca_cert_path, :ca_private_key_path, :ca_private_key_passphrase,
242
242
  :generate_private_key_length,
243
243
  :generate_cert_country, :generate_cert_state, :generate_cert_state,
@@ -271,9 +271,11 @@ module Fluent
271
271
  config_param :insecure, :bool, default: false
272
272
 
273
273
  # Cert signed by public CA
274
+ config_param :ca_path, :string, default: nil
274
275
  config_param :cert_path, :string, default: nil
275
276
  config_param :private_key_path, :string, default: nil
276
277
  config_param :private_key_passphrase, :string, default: nil, secret: true
278
+ config_param :client_cert_auth, :bool, default: false
277
279
 
278
280
  # Cert generated and signed by private CA Certificate
279
281
  config_param :ca_cert_path, :string, default: nil
@@ -15,6 +15,7 @@
15
15
  #
16
16
 
17
17
  require 'fluent/plugin_helper/event_loop'
18
+ require 'set'
18
19
 
19
20
  module Fluent
20
21
  module PluginHelper
@@ -33,7 +34,8 @@ module Fluent
33
34
  raise ArgumentError, "BUG: title must be a symbol" unless title.is_a? Symbol
34
35
  raise ArgumentError, "BUG: block not specified for callback" unless block_given?
35
36
  checker = ->(){ @_timer_running }
36
- timer = TimerWatcher.new(title, interval, repeat, log, checker, &block)
37
+ detacher = ->(watcher){ event_loop_detach(watcher) }
38
+ timer = TimerWatcher.new(title, interval, repeat, log, checker, detacher, &block)
37
39
  @_timers << title
38
40
  event_loop_attach(timer)
39
41
  timer
@@ -45,7 +47,7 @@ module Fluent
45
47
 
46
48
  def initialize
47
49
  super
48
- @_timers = []
50
+ @_timers ||= Set.new
49
51
  end
50
52
 
51
53
  def start
@@ -60,16 +62,17 @@ module Fluent
60
62
 
61
63
  def terminate
62
64
  super
63
- @_timers = []
65
+ @_timers = nil
64
66
  end
65
67
 
66
68
  class TimerWatcher < Coolio::TimerWatcher
67
- def initialize(title, interval, repeat, log, checker, &callback)
69
+ def initialize(title, interval, repeat, log, checker, detacher, &callback)
68
70
  @title = title
69
71
  @callback = callback
70
72
  @repeat = repeat
71
73
  @log = log
72
74
  @checker = checker
75
+ @detacher = detacher
73
76
  super(interval, repeat)
74
77
  end
75
78
 
@@ -81,9 +84,7 @@ module Fluent
81
84
  detach
82
85
  @log.error "Timer detached.", title: @title
83
86
  ensure
84
- if attached?
85
- detach unless @repeat
86
- end
87
+ @detacher.call(self) unless @repeat
87
88
  end
88
89
  end
89
90
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '1.1.0'
19
+ VERSION = '1.1.1'
20
20
 
21
21
  end
@@ -508,6 +508,11 @@ module Fluent::Config
508
508
  assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1", "name5" => "t5", "opt3" => "a"})))
509
509
  end
510
510
 
511
+ test 'can accept frozen string' do
512
+ b2 = ConfigurableSpec::Base2.new
513
+ assert_instance_of(ConfigurableSpec::Base2, b2.configure(config_element("", "", {"name1" => "t1".freeze, "name5" => "t5", "opt3" => "a"})))
514
+ end
515
+
511
516
  test 'raise errors without any specifications for param without defaults' do
512
517
  b2 = ConfigurableSpec::Base2.new
513
518
  assert_raise(Fluent::ConfigError) { b2.configure(config_element("", "", {})) }
@@ -840,4 +840,128 @@ class FileBufferTest < Test::Unit::TestCase
840
840
  assert File.exist?(@not_chunk)
841
841
  end
842
842
  end
843
+
844
+ sub_test_case 'there are existing broken file chunks' do
845
+ setup do
846
+ @bufdir = File.expand_path('../../tmp/broken_buffer_file', __FILE__)
847
+ FileUtils.mkdir_p @bufdir unless File.exist?(@bufdir)
848
+ @bufpath = File.join(@bufdir, 'broken_test.*.log')
849
+
850
+ Fluent::Test.setup
851
+ @d = FluentPluginFileBufferTest::DummyOutputPlugin.new
852
+ @p = Fluent::Plugin::FileBuffer.new
853
+ @p.owner = @d
854
+ @p.configure(config_element('buffer', '', {'path' => @bufpath}))
855
+ end
856
+
857
+ teardown do
858
+ if @p
859
+ @p.stop unless @p.stopped?
860
+ @p.before_shutdown unless @p.before_shutdown?
861
+ @p.shutdown unless @p.shutdown?
862
+ @p.after_shutdown unless @p.after_shutdown?
863
+ @p.close unless @p.closed?
864
+ @p.terminate unless @p.terminated?
865
+ end
866
+ if @bufdir
867
+ Dir.glob(File.join(@bufdir, '*')).each do |path|
868
+ next if ['.', '..'].include?(File.basename(path))
869
+ File.delete(path)
870
+ end
871
+ end
872
+ end
873
+
874
+ def create_first_chunk(mode)
875
+ cid = Fluent::UniqueId.generate
876
+ path = File.join(@bufdir, "broken_test.#{mode}#{Fluent::UniqueId.hex(cid)}.log")
877
+ File.open(path, 'wb') do |f|
878
+ f.write ["t1.test", event_time('2016-04-17 14:00:15 -0700').to_i, {"message" => "yay"}].to_json + "\n"
879
+ f.write ["t2.test", event_time('2016-04-17 14:00:17 -0700').to_i, {"message" => "yay"}].to_json + "\n"
880
+ f.write ["t3.test", event_time('2016-04-17 14:00:21 -0700').to_i, {"message" => "yay"}].to_json + "\n"
881
+ f.write ["t4.test", event_time('2016-04-17 14:00:28 -0700').to_i, {"message" => "yay"}].to_json + "\n"
882
+ end
883
+ write_metadata(
884
+ path + '.meta', cid, metadata(timekey: event_time('2016-04-17 14:00:00 -0700').to_i),
885
+ 4, event_time('2016-04-17 14:00:00 -0700').to_i, event_time('2016-04-17 14:00:28 -0700').to_i
886
+ )
887
+
888
+ return cid, path
889
+ end
890
+
891
+ def create_second_chunk(mode)
892
+ cid = Fluent::UniqueId.generate
893
+ path = File.join(@bufdir, "broken_test.#{mode}#{Fluent::UniqueId.hex(cid)}.log")
894
+ File.open(path, 'wb') do |f|
895
+ f.write ["t1.test", event_time('2016-04-17 14:01:15 -0700').to_i, {"message" => "yay"}].to_json + "\n"
896
+ f.write ["t2.test", event_time('2016-04-17 14:01:17 -0700').to_i, {"message" => "yay"}].to_json + "\n"
897
+ f.write ["t3.test", event_time('2016-04-17 14:01:21 -0700').to_i, {"message" => "yay"}].to_json + "\n"
898
+ end
899
+ write_metadata(
900
+ path + '.meta', cid, metadata(timekey: event_time('2016-04-17 14:01:00 -0700').to_i),
901
+ 3, event_time('2016-04-17 14:01:00 -0700').to_i, event_time('2016-04-17 14:01:25 -0700').to_i
902
+ )
903
+
904
+ return cid, path
905
+ end
906
+
907
+ def compare_staged_chunk(staged, id, time, num, mode)
908
+ assert_equal 1, staged.size
909
+ m = metadata(timekey: event_time(time).to_i)
910
+ assert_equal id, staged[m].unique_id
911
+ assert_equal num, staged[m].size
912
+ assert_equal mode, staged[m].state
913
+ end
914
+
915
+ def compare_queued_chunk(queued, id, num, mode)
916
+ assert_equal 1, queued.size
917
+ assert_equal id, queued[0].unique_id
918
+ assert_equal num, queued[0].size
919
+ assert_equal mode, queued[0].state
920
+ end
921
+
922
+ def compare_log(plugin, msg)
923
+ logs = plugin.log.out.logs
924
+ assert { logs.any? { |log| log.include?(msg) } }
925
+ end
926
+
927
+ test '#resume ignores staged empty chunk' do
928
+ _, p1 = create_first_chunk('b')
929
+ File.open(p1, 'wb') { |f| } # create staged empty chunk file
930
+ c2id, _ = create_second_chunk('b')
931
+
932
+ @p.start
933
+ compare_staged_chunk(@p.stage, c2id, '2016-04-17 14:01:00 -0700', 3, :staged)
934
+ compare_log(@p, 'staged file chunk is empty')
935
+ end
936
+
937
+ test '#resume ignores staged broken metadata' do
938
+ c1id, _ = create_first_chunk('b')
939
+ _, p2 = create_second_chunk('b')
940
+ File.open(p2 + '.meta', 'wb') { |f| f.write("\0" * 70) } # create staged broken meta file
941
+
942
+ @p.start
943
+ compare_staged_chunk(@p.stage, c1id, '2016-04-17 14:00:00 -0700', 4, :staged)
944
+ compare_log(@p, 'staged meta file is broken')
945
+ end
946
+
947
+ test '#resume ignores enqueued empty chunk' do
948
+ _, p1 = create_first_chunk('q')
949
+ File.open(p1, 'wb') { |f| } # create enqueued empty chunk file
950
+ c2id, _ = create_second_chunk('q')
951
+
952
+ @p.start
953
+ compare_queued_chunk(@p.queue, c2id, 3, :queued)
954
+ compare_log(@p, 'enqueued file chunk is empty')
955
+ end
956
+
957
+ test '#resume ignores enqueued broken metadata' do
958
+ c1id, _ = create_first_chunk('q')
959
+ _, p2 = create_second_chunk('q')
960
+ File.open(p2 + '.meta', 'wb') { |f| f.write("\0" * 70) } # create enqueued broken meta file
961
+
962
+ @p.start
963
+ compare_queued_chunk(@p.queue, c1id, 4, :queued)
964
+ compare_log(@p, 'enqueued meta file is broken')
965
+ end
966
+ end
843
967
  end
@@ -25,4 +25,25 @@ class DebugAgentInputTest < Test::Unit::TestCase
25
25
  create_driver %[unix_path #{TMP_DIR}/does_not_exist/test_path]
26
26
  end
27
27
  end
28
+
29
+ def test_multi_worker_environment_with_port
30
+ Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
31
+ d = Fluent::Test::Driver::Input.new(Fluent::Plugin::DebugAgentInput)
32
+ d.instance.instance_eval { @_fluentd_worker_id = 2 }
33
+ d.configure('port 24230')
34
+
35
+ assert_true d.instance.multi_workers_ready?
36
+ assert_equal(24232, d.instance.instance_variable_get(:@port))
37
+ end
38
+ end
39
+
40
+ def test_multi_worker_environment_with_unix_path
41
+ Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
42
+ d = Fluent::Test::Driver::Input.new(Fluent::Plugin::DebugAgentInput)
43
+ d.instance.instance_eval { @_fluentd_worker_id = 2 }
44
+ d.configure("unix_path #{TMP_DIR}/test_path")
45
+
46
+ assert_false d.instance.multi_workers_ready?
47
+ end
48
+ end
28
49
  end
@@ -137,6 +137,31 @@ class HttpInputTest < Test::Unit::TestCase
137
137
  assert_equal_event_time time, d.events[1][1]
138
138
  end
139
139
 
140
+ def test_multi_json_with_time_field
141
+ d = create_driver
142
+ time = event_time("2011-01-02 13:14:15 UTC")
143
+ time_i = time.to_i
144
+ time_f = time.to_f
145
+
146
+ records = [{"a" => 1, 'time' => time_i},{"a" => 2, 'time' => time_f}]
147
+ events = [
148
+ ["tag1", time, {'a' => 1}],
149
+ ["tag1", time, {'a' => 2}],
150
+ ]
151
+ tag = "tag1"
152
+ res_codes = []
153
+ d.run(expect_records: 2, timeout: 5) do
154
+ res = post("/#{tag}", {"json" => records.to_json})
155
+ res_codes << res.code
156
+ end
157
+ assert_equal ["200"], res_codes
158
+ assert_equal events, d.events
159
+ assert_instance_of Fluent::EventTime, d.events[0][1]
160
+ assert_instance_of Fluent::EventTime, d.events[1][1]
161
+ assert_equal_event_time time, d.events[0][1]
162
+ assert_equal_event_time time, d.events[1][1]
163
+ end
164
+
140
165
  def test_json_with_add_remote_addr
141
166
  d = create_driver(CONFIG + "add_remote_addr true")
142
167
  time = event_time("2011-01-02 13:14:15 UTC")
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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-18 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -333,6 +333,7 @@ files:
333
333
  - ENTERPRISE_PROVIDERS.md
334
334
  - GOVERNANCE.md
335
335
  - Gemfile
336
+ - LICENSE
336
337
  - MAINTAINERS.md
337
338
  - README.md
338
339
  - Rakefile