fluent-plugin-opensearch 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc83833c1b081c2c7a43eb518ec339c2fe2b1c3153ea424d02b046bfd26129c
4
- data.tar.gz: '09443e78f21f9e3a064c0fdc0faea5d20d2b67ce85f8f187cef5322382a827e5'
3
+ metadata.gz: 4c4ad0e88f3c4bb0497f3af7d1fa669bc0a9e0820fd7ccbe32713fa86f9fdc69
4
+ data.tar.gz: 56626ed3aadd52c4b560fb6eb8d9a0c0070ac68178ce789a63db19c404ab39e7
5
5
  SHA512:
6
- metadata.gz: fa530480b103bacbe4e00bc0bff3d3aca549acb126fc2251affa80267e24391bd929f9c9a903906c83807cdddc880a6a53b6470ec944fcaaecd73943bcb3560a
7
- data.tar.gz: bc8a40ae17f566b1176edf1f163e8df740df72c19f99fce220dcc0a88cc1c857bfd5b1014f201f5261328eee234d3eb24a2421cc7b882e6c1b047e7e660fb4f3
6
+ metadata.gz: 620d0a42bb7b4db1bdd32bf863697644a5afc499a4d9b071a99192cfb8c621dd863e8f35f30ae6eab6ab90e982ed5a68a2dbab83de6f7b526e44ebe419fd6c5b
7
+ data.tar.gz: ca2cdd6fa2a704423e7cee2c065e72075b6e0d564414d5dcc1feb08608aa303fa93b9bf57afde32ed8a6e90c707bbe2c89bcdfcf8af84aabec904d1d52222dfd
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 1.1.1
6
+ - Pass a value of refresh\_credentials\_interval as duration\_seconds (#78)
7
+
5
8
  ### 1.1.0
6
9
  - Unpin `faraday` from v1, upgrade to v2.
7
10
  Note that if you can't migrate other plugins from `faraday` v1 yet, need to keep
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'fluent-plugin-opensearch'
6
- s.version = '1.1.0'
6
+ s.version = '1.1.1'
7
7
  s.authors = ['Hiroshi Hatake']
8
8
  s.email = ['cosmo0920.wp@gmail.com']
9
9
  s.description = %q{Opensearch output plugin for Fluent event collector}
@@ -83,6 +83,7 @@ module Fluent::Plugin
83
83
  attr_reader :template_names
84
84
  attr_reader :ssl_version_options
85
85
  attr_reader :compressable_connection
86
+ attr_reader :duration_seconds
86
87
 
87
88
  helpers :event_emitter, :compat_parameters, :record_accessor, :timer
88
89
 
@@ -94,6 +95,7 @@ module Fluent::Plugin
94
95
  DEFAULT_RELOAD_AFTER = -1
95
96
  DEFAULT_TARGET_BULK_BYTES = -1
96
97
  DEFAULT_POLICY_ID = "logstash-policy"
98
+ DEFAULT_DURATION = "5h"
97
99
 
98
100
  config_param :host, :string, :default => 'localhost'
99
101
  config_param :port, :integer, :default => 9200
@@ -195,7 +197,7 @@ module Fluent::Plugin
195
197
  config_param :assume_role_session_name, :string, :default => "fluentd"
196
198
  config_param :assume_role_web_identity_token_file, :string, :default => nil
197
199
  config_param :sts_credentials_region, :string, :default => nil
198
- config_param :refresh_credentials_interval, :time, :default => "5h"
200
+ config_param :refresh_credentials_interval, :time, :default => DEFAULT_DURATION
199
201
  config_param :aws_service_name, :enum, list: [:es, :aoss], :default => :es
200
202
  end
201
203
 
@@ -211,6 +213,8 @@ module Fluent::Plugin
211
213
 
212
214
  def initialize
213
215
  super
216
+
217
+ @duration_seconds = Fluent::Config.time_value(DEFAULT_DURATION)
214
218
  end
215
219
 
216
220
  ######################################################################################################
@@ -238,13 +242,15 @@ module Fluent::Plugin
238
242
  credentials = Aws::AssumeRoleCredentials.new({
239
243
  role_arn: conf[:assume_role_arn],
240
244
  role_session_name: conf[:assume_role_session_name],
241
- region: sts_creds_region(conf)
245
+ region: sts_creds_region(conf),
246
+ duration_seconds: @duration_seconds
242
247
  }).credentials
243
248
  else
244
249
  credentials = Aws::AssumeRoleWebIdentityCredentials.new({
245
250
  role_arn: conf[:assume_role_arn],
246
251
  web_identity_token_file: conf[:assume_role_web_identity_token_file],
247
- region: sts_creds_region(conf)
252
+ region: sts_creds_region(conf),
253
+ duration_seconds: @duration_seconds
248
254
  }).credentials
249
255
  end
250
256
  end
@@ -345,7 +351,18 @@ module Fluent::Plugin
345
351
  @_aws_credentials = aws_credentials(@endpoint)
346
352
 
347
353
  if @endpoint.refresh_credentials_interval
348
- timer_execute(:out_opensearch_expire_credentials, @endpoint.refresh_credentials_interval) do
354
+ @duration_seconds = Fluent::Config.time_value(@endpoint.refresh_credentials_interval)
355
+ # 60 * 60 * 12 = 12 hours
356
+ if @duration_seconds > 43200
357
+ raise Fluent::ConfigError, "Maximum duration is 12 hours."
358
+ end
359
+
360
+ # 60 * 15 = 15 minutes
361
+ if @duration_seconds < 900
362
+ raise Fluent::ConfigError, "Minimum duration is 15 minutes."
363
+ end
364
+
365
+ timer_execute(:out_opensearch_expire_credentials, @duration_seconds) do
349
366
  log.debug('Recreate the AWS credentials')
350
367
 
351
368
  @credential_mutex.synchronize do
@@ -300,6 +300,7 @@ class OpenSearchOutputTest < Test::Unit::TestCase
300
300
  'region' => "local",
301
301
  'access_key_id' => 'YOUR_AWESOME_KEY',
302
302
  'secret_access_key' => 'YOUR_AWESOME_SECRET',
303
+ 'refresh_credentials_interval' => '10h'
303
304
  }, []),
304
305
  Fluent::Config::Element.new('buffer', 'tag', {}, [])
305
306
 
@@ -316,6 +317,8 @@ class OpenSearchOutputTest < Test::Unit::TestCase
316
317
  assert_nil instance.endpoint.assume_role_web_identity_token_file
317
318
  assert_nil instance.endpoint.sts_credentials_region
318
319
  assert_equal :es, instance.endpoint.aws_service_name
320
+ assert_equal 36000, instance.endpoint.refresh_credentials_interval
321
+ assert_equal 36000, instance.duration_seconds
319
322
  end
320
323
 
321
324
  data("OpenSearch Service" => [:es, 'es'],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-opensearch
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
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-11 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  - !ruby/object:Gem::Version
271
271
  version: '0'
272
272
  requirements: []
273
- rubygems_version: 3.3.26
273
+ rubygems_version: 3.2.32
274
274
  signing_key:
275
275
  specification_version: 4
276
276
  summary: Opensearch output plugin for Fluent event collector