fluent-plugin-kubernetes_metadata_filter 2.1.0 → 2.1.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
  SHA1:
3
- metadata.gz: 58bdc9ed97a93eb46eeec306ad5851b94d3b5656
4
- data.tar.gz: 56806c61750f533d2190c0a0915fb1fed0b4d46e
3
+ metadata.gz: 149bef65a13bf7ef7fc0a3964b4f8ba0696489f8
4
+ data.tar.gz: 99f30525e67d6d92593a1e6bbd5160b19889dab0
5
5
  SHA512:
6
- metadata.gz: e38271b6f13d95781df47a4c99474ec9d54bd8926a48a55d2613086079997728902d74b1207986325e36f9ea647b65786b0602f280a8ae5d4c37f3ae4737973a
7
- data.tar.gz: 90a46813a80eec7928f35387adc4778d3c07e1e6f61eea0cf3ca1725ef8195bf73816f733bb7c5cb0464cd69269981a8fb7562bc2a3e17ffaf00384624821b74
6
+ metadata.gz: d06e30879346ca2cca50a377357860e353263e9887f00de254d9906632080d6ec61eca74657a68debd60bcb594df5afdaeca8d54596ee57690cd0c40851261ae
7
+ data.tar.gz: 57c74b482aed9cece0895b9959929c16fc8fa55c705d93b889270171be55c5150682fb03d7c2a60fbbbfa91089998481a126d73aa3534951cc5772ebd1b6c055
data/README.md CHANGED
@@ -53,7 +53,7 @@ when true (default: `true`)
53
53
  * `orphaned_namespace_name` - The namespace to associate with records where the namespace can not be determined (default: `.orphaned`)
54
54
  * `orphaned_namespace_id` - The namespace id to associate with records where the namespace can not be determined (default: `orphaned`)
55
55
 
56
- **NOTE:** As of the release 1.1.x of this plugin, it no longer supports parsing the source message into JSON and attaching it to the
56
+ **NOTE:** As of the release 2.1.x of this plugin, it no longer supports parsing the source message into JSON and attaching it to the
57
57
  payload. The following configuration options are removed:
58
58
 
59
59
  * `merge_json_log`
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-kubernetes_metadata_filter"
7
- gem.version = "2.1.0"
7
+ gem.version = "2.1.1"
8
8
  gem.authors = ["Jimmi Dyson"]
9
9
  gem.email = ["jimmidyson@gmail.com"]
10
10
  gem.description = %q{Filter plugin to add Kubernetes metadata}
@@ -90,12 +90,12 @@ module Fluent::Plugin
90
90
  rescue Exception=>e
91
91
  log.debug(e)
92
92
  @stats.bump(:pod_cache_api_nil_bad_resp_payload)
93
- log.trace("returning empty metadata for #{namespace_name}/#{pod_name} due to error") if log.trace?
93
+ log.trace("returning empty metadata for #{namespace_name}/#{pod_name} due to error '#{e}'") if log.trace?
94
94
  end
95
95
  end
96
- rescue KubeException=>e
96
+ rescue Exception=>e
97
97
  @stats.bump(:pod_cache_api_nil_error)
98
- log.debug "Exception encountered fetching pod metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}: #{e.message}"
98
+ log.debug "Exception '#{e}' encountered fetching pod metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}"
99
99
  end
100
100
  {}
101
101
  end
@@ -132,12 +132,12 @@ module Fluent::Plugin
132
132
  rescue Exception => e
133
133
  log.debug(e)
134
134
  @stats.bump(:namespace_cache_api_nil_bad_resp_payload)
135
- log.trace("returning empty metadata for #{namespace_name} due to error") if log.trace?
135
+ log.trace("returning empty metadata for #{namespace_name} due to error '#{e}'") if log.trace?
136
136
  end
137
137
  end
138
- rescue KubeException => kube_error
138
+ rescue Exception => kube_error
139
139
  @stats.bump(:namespace_cache_api_nil_error)
140
- log.debug "Exception encountered fetching namespace metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}: #{kube_error.message}"
140
+ log.debug "Exception '#{kube_error}' encountered fetching namespace metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}"
141
141
  end
142
142
  {}
143
143
  end
@@ -18,7 +18,6 @@
18
18
  #
19
19
  module KubernetesMetadata
20
20
  module CacheStrategy
21
-
22
21
  def get_pod_metadata(key, namespace_name, pod_name, record_create_time, batch_miss_cache)
23
22
  metadata = {}
24
23
  ids = @id_cache[key]
@@ -140,12 +140,6 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
140
140
  cache_size 1
141
141
  ', d: nil)
142
142
  d = create_driver(config) if d.nil?
143
- if ENV['LOGLEVEL']
144
- logger = Logger.new(STDOUT)
145
- logger.level = eval("Logger::#{ENV['LOGLEVEL'].upcase}")
146
- instance = d.instance
147
- instance.instance_variable_set(:@log,logger)
148
- end
149
143
  d.run(default_tag: DEFAULT_TAG) {
150
144
  d.feed(@time, msg)
151
145
  }
@@ -164,6 +158,33 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
164
158
  d.filtered.map{|e| e.last}
165
159
  end
166
160
 
161
+ test 'inability to connect to the api server handles exception and doensnt block pipeline' do
162
+ VCR.use_cassette('kubernetes_docker_metadata') do
163
+ driver = create_driver('
164
+ kubernetes_url https://localhost:8443
165
+ watch false
166
+ cache_size 1
167
+ ')
168
+ stub_request(:any, 'https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc').to_raise(SocketError.new('error from pod fetch'))
169
+ stub_request(:any, 'https://localhost:8443/api/v1/namespaces/default').to_raise(SocketError.new('socket error from namespace fetch'))
170
+ filtered = emit({'time'=>'2015-05-08T09:22:01Z'}, '', :d => driver)
171
+ expected_kube_metadata = {
172
+ 'time'=>'2015-05-08T09:22:01Z',
173
+ 'docker' => {
174
+ 'container_id' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459'
175
+ },
176
+ 'kubernetes' => {
177
+ 'pod_name' => 'fabric8-console-controller-98rqc',
178
+ 'container_name' => 'fabric8-console-container',
179
+ "namespace_id"=>"orphaned",
180
+ 'namespace_name' => '.orphaned',
181
+ "orphaned_namespace"=>"default"
182
+ }
183
+ }
184
+ assert_equal(expected_kube_metadata, filtered[0])
185
+ end
186
+ end
187
+
167
188
  test 'with docker & kubernetes metadata where id cache hit and metadata miss' do
168
189
  VCR.use_cassette('kubernetes_docker_metadata') do
169
190
  driver = create_driver('
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-kubernetes_metadata_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmi Dyson