fluent-plugin-mongo 1.6.0 → 1.6.2

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: fc300a11be780d8b3ea62e71db08393171fad3625d1d9259cb65a7abe11f9e5e
4
- data.tar.gz: db12f19c83ae360e9720c41a2d64c3ce8bd65487d554ed2e416277d0f158b311
3
+ metadata.gz: '09b007f64939a3ad6f8476d7845c8932ee122d035902a5ca75c22574fededde0'
4
+ data.tar.gz: 3f18cdb797b67bfadc7f6a26236ab5eb1d47af5b271c9820dacb65b684eacc08
5
5
  SHA512:
6
- metadata.gz: c105cf4d712af0524a554b072f86a2af2cfc5485825db24f47dcd47cc850628cfeb08af8f7db4337aefc7342b2325e35698707db22aa0e595d786a6d72317320
7
- data.tar.gz: '08454ce8638ee2bf64d1f6ae2d6adfd0632ed43ad47667558b9ee00dccb54a12d8fbac31c0b8032bd69598752a442bac02e7425e2ccd649754d7c48df1723b8b'
6
+ metadata.gz: 05d1cb4a3bc5c31f8318a25d04f80ded83f57b18e1ab2d4c1e7b43c85c644d7b1db2fd6ed2ea4ca24f3f9f8d3d03cc811566cd73e71f1bcda0a0cd7aee1f74d0
7
+ data.tar.gz: 8d76f125209e1d7bfcf890d445302df48988ea63e4e24e252e60b9fee8ecb38e9f46af0ab6c1faf9d627f8a166617b7b1a4aa772304ad730b583586846b88878
@@ -0,0 +1,72 @@
1
+ name: Bug Report
2
+ description: Create a report with a procedure for reproducing the bug
3
+ labels: "waiting-for-triage"
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Please check the [README](https://github.com/fluent/fluent-plugin-mongo/blob/master/README.rdoc) first. To help us investigate the problem, please provide the following information.
9
+ - type: textarea
10
+ id: description
11
+ attributes:
12
+ label: Describe the bug
13
+ description: A clear and concise description of what the bug is
14
+ validations:
15
+ required: true
16
+ - type: textarea
17
+ id: reproduce
18
+ attributes:
19
+ label: To Reproduce
20
+ description: Steps to reproduce the behavior
21
+ validations:
22
+ required: true
23
+ - type: textarea
24
+ id: expected
25
+ attributes:
26
+ label: Expected behavior
27
+ description: A clear and concise description of what you expected to happen
28
+ validations:
29
+ required: true
30
+ - type: textarea
31
+ id: environment
32
+ attributes:
33
+ label: Your Environment
34
+ description: |
35
+ - Fluentd or td-agent version: `fluentd --version` or `td-agent --version`
36
+ - Operating system: `cat /etc/os-release`
37
+ - Kernel version: `uname -r`
38
+
39
+ Tip: If you hit the problem with older fluentd version, try latest version first.
40
+ value: |
41
+ - Fluentd version:
42
+ - TD Agent/Fluent Package version:
43
+ - fluent-plugin-mongo version:
44
+ - mongo version:
45
+ - Operating system:
46
+ - Kernel version:
47
+ render: markdown
48
+ validations:
49
+ required: true
50
+ - type: textarea
51
+ id: configuration
52
+ attributes:
53
+ label: Your Configuration
54
+ description: |
55
+ Write your configuration here. Minimum reproducible fluentd.conf is recommended.
56
+ validations:
57
+ required: true
58
+ - type: textarea
59
+ id: logs
60
+ attributes:
61
+ label: Your Error Log
62
+ description: Write your ALL error log here
63
+ render: shell
64
+ validations:
65
+ required: true
66
+ - type: textarea
67
+ id: addtional-context
68
+ attributes:
69
+ label: Additional context
70
+ description: Add any other context about the problem here.
71
+ validations:
72
+ required: false
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Ask a Question
4
+ url: https://discuss.fluentd.org/
5
+ about: I have questions about fluent-plugin-mongo. Please ask and answer questions at https://discuss.fluentd.org/.
@@ -0,0 +1,38 @@
1
+ name: Feature request
2
+ description: Suggest an idea for this project
3
+ labels: "waiting-for-triage"
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Please check the [README](https://github.com/fluent/fluent-plugin-mongo/blob/master/README.rdoc) first. To help us understand the request, please provide the following information.
9
+ - type: textarea
10
+ id: description
11
+ attributes:
12
+ label: Is your feature request related to a problem? Please describe.
13
+ description: |
14
+ A clear and concise description of what the problem is.
15
+ Ex. I'm always frustrated when [...]
16
+ validations:
17
+ required: true
18
+ - type: textarea
19
+ id: solution
20
+ attributes:
21
+ label: Describe the solution you'd like
22
+ description: A clear and concise description of what you want to happen.
23
+ validations:
24
+ required: true
25
+ - type: textarea
26
+ id: alternative
27
+ attributes:
28
+ label: Describe alternatives you've considered
29
+ description: A clear and concise description of any alternative solutions or features you've considered.
30
+ validations:
31
+ required: true
32
+ - type: textarea
33
+ id: addtional-context
34
+ attributes:
35
+ label: Additional context
36
+ description: Add any other context or screenshots about the feature request here.
37
+ validations:
38
+ required: false
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'monthly'
@@ -0,0 +1,24 @@
1
+ name: Add bugs to fluent project
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+
8
+ jobs:
9
+ add-to-project:
10
+ name: Add issue to project
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Generate token
14
+ id: generate_token
15
+ uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
16
+ with:
17
+ app-id: ${{ secrets.PROJECT_APP_ID }}
18
+ private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
19
+ owner: fluent
20
+ - uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
21
+ with:
22
+ project-url: https://github.com/orgs/fluent/projects/4
23
+ github-token: ${{ steps.generate_token.outputs.token }}
24
+ labeled: waiting-for-triage
@@ -4,46 +4,39 @@ on:
4
4
  branches: [master]
5
5
  pull_request:
6
6
  branches: [master]
7
+ schedule:
8
+ - cron: '0 0 1 * *'
7
9
  jobs:
10
+ ruby-versions:
11
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
+ with:
13
+ engine: cruby
14
+ min_version: 2.7
8
15
  build:
16
+ needs: ruby-versions
9
17
  runs-on: ${{ matrix.os }}
10
- continue-on-error: ${{ matrix.experimental }}
18
+ continue-on-error: ${{ matrix.ruby == 'head' }}
11
19
  strategy:
12
20
  fail-fast: false
13
21
  matrix:
14
- ruby: [ '3.1', '3.0', '2.7', '2.6' ]
15
- mongodb-version: ['5.0', '4.4', '4.2', '4.0']
22
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
23
+ mongodb-version: ['8.0', '7.0', '6.0', '5.0', '4.4', '4.2']
16
24
  os:
17
25
  - ubuntu-latest
18
- experimental: [false]
19
- include:
20
- - ruby: head
21
- os: ubuntu-latest
22
- experimental: true
23
- mongodb-version: '4.0'
24
- - ruby: head
25
- os: ubuntu-latest
26
- experimental: true
27
- mongodb-version: '4.2'
28
- - ruby: head
29
- os: ubuntu-latest
30
- experimental: true
31
- mongodb-version: '4.4'
32
26
 
33
27
  name: Ruby ${{ matrix.ruby }} and MongoDB ${{ matrix.mongodb-version }} on ${{ matrix.os }}
34
28
  steps:
35
- - uses: actions/checkout@v2
36
- - uses: ruby/setup-ruby@v1
29
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30
+ - uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64 # v1.299.0
37
31
  with:
38
32
  ruby-version: ${{ matrix.ruby }}
39
33
  - name: Start MongoDB
40
- uses: supercharge/mongodb-github-action@1.3.0
34
+ uses: supercharge/mongodb-github-action@315db7fe45ac2880b7758f1933e6e5d59afd5e94 # v1.12.1
41
35
  with:
42
36
  mongodb-version: ${{ matrix.mongodb-version }}
43
37
  - name: unit testing
44
38
  env:
45
39
  CI: true
46
40
  run: |
47
- gem install bundler rake
48
41
  bundle install --jobs 4 --retry 3
49
42
  bundle exec rake test
data/ChangeLog CHANGED
@@ -1,3 +1,15 @@
1
+ Release 1.6.2 - 2026/04/23
2
+
3
+ * out_mongo: prevent infinite retry on MaxBSONSize error (#206)
4
+ * out_mongo: fix NoMethodError during gracefulReload (#205)
5
+ * Add support for MongoDB 6.0, 7.0, 8.0 (#177)
6
+
7
+ Release 1.6.1 - 2026/02/12
8
+
9
+ * out_mongo: Fix RangeError by converting large integers to BSON::Decimal128
10
+ * gem: add bigdecimal as dependency for Ruby 3.4
11
+ * Drop support for MongoDB 4.0.
12
+
1
13
  Release 1.6.0 - 2022/07/15
2
14
 
3
15
  * Update mongo gem dependency
data/README.rdoc CHANGED
@@ -17,6 +17,17 @@ The gem is hosted at {Rubygems.org}[http://rubygems.org]. You can install the ge
17
17
 
18
18
  $ fluent-gem install fluent-plugin-mongo
19
19
 
20
+ === For Windows users
21
+
22
+ This plugin depends on the C extension library (such as `bson` gem) which requires a C compiler to install.
23
+
24
+ If you are using Windows, you must install the {MSYS2}[https://www.msys2.org/] development toolchain before installing this plugin:
25
+
26
+ 1. Run the following command in your command prompt:
27
+ $ ridk install
28
+ 2. Select option `3` (MSYS2 and MINGW development toolchain).
29
+ 3. Once the compiler installation is complete, run the <tt>ridk exec fluent-gem install fluent-plugin-mongo</tt> command.
30
+
20
31
  = Plugins
21
32
 
22
33
  == Output plugin
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.6.2
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_dependency "fluentd", [">= 0.14.22", "< 2"]
20
+ gem.add_dependency "bigdecimal", "~> 4.0"
20
21
  gem.add_runtime_dependency "mongo", ">= 2.15.0", "< 2.19.0"
21
22
  gem.add_development_dependency "rake", ">= 0.9.2"
22
23
  gem.add_development_dependency "simplecov", ">= 0.5.4"
@@ -186,7 +186,7 @@ module Fluent::Plugin
186
186
  end
187
187
 
188
188
  def shutdown
189
- @client.close
189
+ @client&.close
190
190
  super
191
191
  end
192
192
 
@@ -351,11 +351,17 @@ module Fluent::Plugin
351
351
  replace_key_of_hash(r, /^\$/, @replace_dollar_in_key_with)
352
352
  end
353
353
  end
354
+ records.map! do |r|
355
+ replace_value_of_hash(r)
356
+ end
354
357
 
355
358
  get_collection(database, collection, @collection_options).insert_many(records)
356
359
  rescue Mongo::Error::BulkWriteError => e
357
360
  log.warn "#{records.size - e.result["n_inserted"]} documents are not inserted. Maybe these documents are invalid as a BSON."
358
361
  forget_collection(collection)
362
+ rescue Mongo::Error::MaxBSONSize => e
363
+ log.warn e
364
+ raise Fluent::UnrecoverableError, e
359
365
  rescue ArgumentError => e
360
366
  log.warn e
361
367
  end
@@ -384,5 +390,23 @@ module Fluent::Plugin
384
390
  hash_or_array
385
391
  end
386
392
  end
393
+
394
+ INT64_MAX = (2 ** 63) - 1
395
+ def replace_value_of_hash(hash_or_array)
396
+ case hash_or_array
397
+ when Array
398
+ hash_or_array.map { |v| replace_value_of_hash(v) }
399
+ when Hash
400
+ hash_or_array.each_pair { |k, v| hash_or_array[k] = replace_value_of_hash(v) }
401
+ when Integer
402
+ if hash_or_array > INT64_MAX
403
+ BSON::Decimal128.new(hash_or_array.to_s)
404
+ else
405
+ hash_or_array
406
+ end
407
+ else
408
+ hash_or_array
409
+ end
410
+ end
387
411
  end
388
412
  end
@@ -229,8 +229,6 @@ class MongoOutputTest < ::Test::Unit::TestCase
229
229
  @type mongo
230
230
  connection_string mongodb://localhost:#{port}/#{database_name}
231
231
  collection #{collection_name}
232
- capped
233
- capped_size 100
234
232
  expire_after 120
235
233
  ])
236
234
  assert_equal("mongodb://localhost:#{port}/#{database_name}", d.instance.connection_string)
@@ -249,6 +247,20 @@ class MongoOutputTest < ::Test::Unit::TestCase
249
247
  assert_equal({"expireAfterSeconds"=>120.0}, expire_after_hash)
250
248
  end
251
249
 
250
+ def test_overflow_integer_value
251
+ d = create_driver
252
+ d.run(default_tag: 'test') do
253
+ time = event_time("2011-01-02 13:14:15 UTC")
254
+ d.feed(time, {'overflow' => (2 ** 63)})
255
+ d.feed(time, {'nested' => {'overflow' => (2 ** 63)}})
256
+ d.feed(time, {'array' => [(2 ** 63)]})
257
+ end
258
+ documents = get_documents
259
+ assert_equal(BSON::Decimal128.new((2 ** 63).to_s), documents[0]['overflow'])
260
+ assert_equal(BSON::Decimal128.new((2 ** 63).to_s), documents[1]['nested']['overflow'])
261
+ assert_equal(BSON::Decimal128.new((2 ** 63).to_s), documents[2]['array'][0])
262
+ end
263
+
252
264
  class WriteWithCollectionPlaceholder < self
253
265
  def setup
254
266
  @tag = 'custom'
@@ -608,4 +620,25 @@ class MongoOutputTest < ::Test::Unit::TestCase
608
620
  assert_nil actual_documents.first['my_id']['id']
609
621
  end
610
622
  end
623
+
624
+ def test_unrecoverable_error_on_huge_document
625
+ d = create_driver(%[
626
+ @type mongo
627
+ database test
628
+ collection test_unrecoverable
629
+ <buffer>
630
+ chunk_limit_size 30m
631
+ </buffer>
632
+ ])
633
+
634
+ d.run(default_tag: 'test') do
635
+ time = event_time("2011-01-02 13:14:15 UTC")
636
+ # The document size exceeds the 16MB limit of BSON, so it should raise an UnrecoverableError.
637
+ d.feed(time, {'msg' => 'x' * (20 * 1024 * 1024)})
638
+ end
639
+
640
+ logs = d.logs.join("\n")
641
+ assert_match(/got unrecoverable error.*Fluent::UnrecoverableError/, logs)
642
+ assert_match(/MaxBSONSize/, logs)
643
+ end
611
644
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-07-15 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: fluentd
@@ -30,6 +29,20 @@ dependencies:
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
31
  version: '2'
32
+ - !ruby/object:Gem::Dependency
33
+ name: bigdecimal
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '4.0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: '4.0'
33
46
  - !ruby/object:Gem::Dependency
34
47
  name: mongo
35
48
  requirement: !ruby/object:Gem::Requirement
@@ -141,9 +154,13 @@ executables:
141
154
  extensions: []
142
155
  extra_rdoc_files: []
143
156
  files:
157
+ - ".github/ISSUE_TEMPLATE/bug_report.yaml"
158
+ - ".github/ISSUE_TEMPLATE/config.yml"
159
+ - ".github/ISSUE_TEMPLATE/feature_request.yaml"
160
+ - ".github/dependabot.yml"
161
+ - ".github/workflows/add-to-project.yml"
144
162
  - ".github/workflows/linux.yml"
145
163
  - ".gitignore"
146
- - ".travis.yml"
147
164
  - AUTHORS
148
165
  - ChangeLog
149
166
  - Gemfile
@@ -165,7 +182,6 @@ homepage: https://github.com/fluent/fluent-plugin-mongo
165
182
  licenses:
166
183
  - Apache-2.0
167
184
  metadata: {}
168
- post_install_message:
169
185
  rdoc_options: []
170
186
  require_paths:
171
187
  - lib
@@ -180,8 +196,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
196
  - !ruby/object:Gem::Version
181
197
  version: '0'
182
198
  requirements: []
183
- rubygems_version: 3.3.5
184
- signing_key:
199
+ rubygems_version: 4.0.6
185
200
  specification_version: 4
186
201
  summary: MongoDB plugin for Fluentd
187
- test_files: []
202
+ test_files:
203
+ - test/helper.rb
204
+ - test/plugin/test_in_mongo_tail.rb
205
+ - test/plugin/test_out_mongo.rb
206
+ - test/plugin/test_out_mongo_replset.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- rvm:
2
- - 2.4.10
3
- - 2.5
4
- - 2.6
5
- - 2.7
6
- - ruby-head
7
-
8
- gemfile:
9
- - Gemfile
10
-
11
- services:
12
- - mongodb
13
-
14
- script: bundle exec rake test
15
-
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head