fluent-plugin-kubernetes_metadata_filter 2.10.0 → 2.13.0
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 +4 -4
- data/Gemfile.lock +28 -28
- data/fluent-plugin-kubernetes_metadata_filter.gemspec +3 -3
- data/lib/fluent/plugin/filter_kubernetes_metadata.rb +74 -58
- data/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb +33 -0
- data/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +33 -0
- data/test/plugin/test_filter_kubernetes_metadata.rb +0 -9
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c9c8ca7a91fa8c0fa0d87086c446978ed54afd901a635889cc9c0c6276258588
|
|
4
|
+
data.tar.gz: a67192dc10a2ceda476cad7ee35e28973670603bd86aa6c083d47c7cbebf9b85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4143d6376a80ba53f0cf1b9699d23d4862b9f748e927585694dbd942edec3d214989c59a1cfd90bd7b02379ee5beeea3a01a9d7ec5947752e8e1e1becb2e7bd5
|
|
7
|
+
data.tar.gz: 12b6b13c20272ca6d285856a816b52ddffa92ac53b93a91222adb8e9f0be07d1a21808d61c2d4364473e0be57b1f4af6414627cca9a08ce88143e02b2f4bc7b1
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fluent-plugin-kubernetes_metadata_filter (2.
|
|
5
|
-
fluentd (>= 0.14.0, < 1.
|
|
4
|
+
fluent-plugin-kubernetes_metadata_filter (2.13.0)
|
|
5
|
+
fluentd (>= 0.14.0, < 1.16)
|
|
6
6
|
kubeclient (>= 4.0.0, < 5.0.0)
|
|
7
7
|
lru_redux
|
|
8
8
|
|
|
@@ -25,28 +25,28 @@ GEM
|
|
|
25
25
|
docile (1.4.0)
|
|
26
26
|
domain_name (0.5.20190701)
|
|
27
27
|
unf (>= 0.0.5, < 1.0.0)
|
|
28
|
-
escape_utils (1.2.
|
|
28
|
+
escape_utils (1.2.2)
|
|
29
29
|
ffi (1.15.5)
|
|
30
30
|
ffi-compiler (1.0.1)
|
|
31
31
|
ffi (>= 1.0.0)
|
|
32
32
|
rake
|
|
33
|
-
fluentd (1.
|
|
33
|
+
fluentd (1.15.0)
|
|
34
34
|
bundler
|
|
35
35
|
cool.io (>= 1.4.5, < 2.0.0)
|
|
36
36
|
http_parser.rb (>= 0.5.1, < 0.9.0)
|
|
37
37
|
msgpack (>= 1.3.1, < 2.0.0)
|
|
38
|
-
serverengine (>= 2.
|
|
38
|
+
serverengine (>= 2.3.0, < 3.0.0)
|
|
39
39
|
sigdump (~> 0.2.2)
|
|
40
40
|
strptime (>= 0.2.4, < 1.0.0)
|
|
41
41
|
tzinfo (>= 1.0, < 3.0)
|
|
42
42
|
tzinfo-data (~> 1.0)
|
|
43
43
|
webrick (>= 1.4.2, < 1.8.0)
|
|
44
44
|
yajl-ruby (~> 1.0)
|
|
45
|
-
github-linguist (7.
|
|
45
|
+
github-linguist (7.21.0)
|
|
46
46
|
charlock_holmes (~> 0.7.7)
|
|
47
47
|
escape_utils (~> 1.2.0)
|
|
48
48
|
mini_mime (~> 1.0)
|
|
49
|
-
rugged (
|
|
49
|
+
rugged (~> 1.0)
|
|
50
50
|
hashdiff (1.0.1)
|
|
51
51
|
http (4.4.1)
|
|
52
52
|
addressable (~> 2.3)
|
|
@@ -54,13 +54,13 @@ GEM
|
|
|
54
54
|
http-form_data (~> 2.2)
|
|
55
55
|
http-parser (~> 1.2.0)
|
|
56
56
|
http-accept (1.7.0)
|
|
57
|
-
http-cookie (1.0.
|
|
57
|
+
http-cookie (1.0.5)
|
|
58
58
|
domain_name (~> 0.5)
|
|
59
59
|
http-form_data (2.3.0)
|
|
60
60
|
http-parser (1.2.3)
|
|
61
61
|
ffi-compiler (>= 1.0, < 2.0)
|
|
62
62
|
http_parser.rb (0.8.0)
|
|
63
|
-
jsonpath (1.1.
|
|
63
|
+
jsonpath (1.1.2)
|
|
64
64
|
multi_json
|
|
65
65
|
kubeclient (4.9.3)
|
|
66
66
|
http (>= 3.0, < 5.0)
|
|
@@ -73,39 +73,39 @@ GEM
|
|
|
73
73
|
mime-types-data (3.2022.0105)
|
|
74
74
|
mini_mime (1.1.2)
|
|
75
75
|
minitest (4.7.5)
|
|
76
|
-
msgpack (1.5.
|
|
76
|
+
msgpack (1.5.3)
|
|
77
77
|
multi_json (1.15.0)
|
|
78
78
|
netrc (0.11.0)
|
|
79
|
-
parallel (1.
|
|
80
|
-
parser (3.
|
|
79
|
+
parallel (1.22.1)
|
|
80
|
+
parser (3.1.2.0)
|
|
81
81
|
ast (~> 2.4.1)
|
|
82
82
|
power_assert (2.0.1)
|
|
83
|
-
public_suffix (4.0.
|
|
84
|
-
rainbow (3.
|
|
83
|
+
public_suffix (4.0.7)
|
|
84
|
+
rainbow (3.1.1)
|
|
85
85
|
rake (13.0.6)
|
|
86
86
|
recursive-open-struct (1.1.3)
|
|
87
|
-
regexp_parser (2.
|
|
87
|
+
regexp_parser (2.5.0)
|
|
88
88
|
rest-client (2.1.0)
|
|
89
89
|
http-accept (>= 1.7.0, < 2.0)
|
|
90
90
|
http-cookie (>= 1.0.2, < 2.0)
|
|
91
91
|
mime-types (>= 1.16, < 4.0)
|
|
92
92
|
netrc (~> 0.8)
|
|
93
93
|
rexml (3.2.5)
|
|
94
|
-
rr (3.0.
|
|
95
|
-
rubocop (1.
|
|
94
|
+
rr (3.0.9)
|
|
95
|
+
rubocop (1.28.2)
|
|
96
96
|
parallel (~> 1.10)
|
|
97
|
-
parser (>= 3.
|
|
97
|
+
parser (>= 3.1.0.0)
|
|
98
98
|
rainbow (>= 2.2.2, < 4.0)
|
|
99
99
|
regexp_parser (>= 1.8, < 3.0)
|
|
100
100
|
rexml
|
|
101
|
-
rubocop-ast (>= 1.
|
|
101
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
|
102
102
|
ruby-progressbar (~> 1.7)
|
|
103
103
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
104
|
-
rubocop-ast (1.
|
|
105
|
-
parser (>= 3.
|
|
104
|
+
rubocop-ast (1.17.0)
|
|
105
|
+
parser (>= 3.1.1.0)
|
|
106
106
|
ruby-progressbar (1.11.0)
|
|
107
|
-
rugged (1.
|
|
108
|
-
serverengine (2.
|
|
107
|
+
rugged (1.4.3)
|
|
108
|
+
serverengine (2.3.0)
|
|
109
109
|
sigdump (~> 0.2.2)
|
|
110
110
|
sigdump (0.2.4)
|
|
111
111
|
simplecov (0.21.2)
|
|
@@ -113,7 +113,7 @@ GEM
|
|
|
113
113
|
simplecov-html (~> 0.11)
|
|
114
114
|
simplecov_json_formatter (~> 0.1)
|
|
115
115
|
simplecov-html (0.12.3)
|
|
116
|
-
simplecov_json_formatter (0.1.
|
|
116
|
+
simplecov_json_formatter (0.1.4)
|
|
117
117
|
strptime (0.2.5)
|
|
118
118
|
test-unit (3.0.9)
|
|
119
119
|
power_assert
|
|
@@ -126,15 +126,15 @@ GEM
|
|
|
126
126
|
tzinfo (>= 1.0.0)
|
|
127
127
|
unf (0.1.4)
|
|
128
128
|
unf_ext
|
|
129
|
-
unf_ext (0.0.8.
|
|
130
|
-
unicode-display_width (2.
|
|
129
|
+
unf_ext (0.0.8.2)
|
|
130
|
+
unicode-display_width (2.2.0)
|
|
131
131
|
vcr (6.0.0)
|
|
132
132
|
webmock (3.14.0)
|
|
133
133
|
addressable (>= 2.8.0)
|
|
134
134
|
crack (>= 0.3.2)
|
|
135
135
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
136
136
|
webrick (1.7.0)
|
|
137
|
-
yajl-ruby (1.4.
|
|
137
|
+
yajl-ruby (1.4.3)
|
|
138
138
|
|
|
139
139
|
PLATFORMS
|
|
140
140
|
ruby
|
|
@@ -155,4 +155,4 @@ DEPENDENCIES
|
|
|
155
155
|
yajl-ruby
|
|
156
156
|
|
|
157
157
|
BUNDLED WITH
|
|
158
|
-
2.3.
|
|
158
|
+
2.3.16
|
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = 'fluent-plugin-kubernetes_metadata_filter'
|
|
8
|
-
gem.version = '2.
|
|
8
|
+
gem.version = '2.13.0'
|
|
9
9
|
gem.authors = ['OpenShift Cluster Logging','Jimmi Dyson']
|
|
10
10
|
gem.email = ['team-logging@redhat.com','jimmidyson@gmail.com']
|
|
11
11
|
gem.description = 'Filter plugin to add Kubernetes metadata'
|
|
@@ -15,9 +15,9 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
|
17
17
|
|
|
18
|
-
gem.required_ruby_version = '>= 2.
|
|
18
|
+
gem.required_ruby_version = '>= 2.6.0'
|
|
19
19
|
|
|
20
|
-
gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.
|
|
20
|
+
gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 1.16']
|
|
21
21
|
gem.add_runtime_dependency 'kubeclient', ['>= 4.0.0', '< 5.0.0']
|
|
22
22
|
gem.add_runtime_dependency 'lru_redux'
|
|
23
23
|
|
|
@@ -118,11 +118,21 @@ module Fluent::Plugin
|
|
|
118
118
|
@stats.bump(:pod_cache_api_updates)
|
|
119
119
|
log.trace("parsed metadata for #{namespace_name}/#{pod_name}: #{metadata}")
|
|
120
120
|
@cache[metadata['pod_id']] = metadata
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
rescue KubeException => e
|
|
122
|
+
if e.error_code == 401
|
|
123
|
+
# recreate client to refresh token
|
|
124
|
+
log.info("Encountered '401 Unauthorized' exception, recreating client to refresh token")
|
|
125
|
+
create_client()
|
|
126
|
+
else
|
|
127
|
+
log.error "Exception '#{e}' encountered fetching pod metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}"
|
|
128
|
+
@stats.bump(:pod_cache_api_nil_error)
|
|
129
|
+
end
|
|
130
|
+
{}
|
|
131
|
+
rescue StandardError => e
|
|
132
|
+
@stats.bump(:pod_cache_api_nil_error)
|
|
133
|
+
log.error "Exception '#{e}' encountered fetching pod metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}"
|
|
134
|
+
{}
|
|
135
|
+
end
|
|
126
136
|
|
|
127
137
|
def dump_stats
|
|
128
138
|
@curr_time = Time.now
|
|
@@ -150,15 +160,27 @@ module Fluent::Plugin
|
|
|
150
160
|
@stats.bump(:namespace_cache_api_updates)
|
|
151
161
|
log.trace("parsed metadata for #{namespace_name}: #{metadata}")
|
|
152
162
|
@namespace_cache[metadata['namespace_id']] = metadata
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
163
|
+
rescue KubeException => e
|
|
164
|
+
if e.error_code == 401
|
|
165
|
+
# recreate client to refresh token
|
|
166
|
+
log.info("Encountered '401 Unauthorized' exception, recreating client to refresh token")
|
|
167
|
+
create_client()
|
|
168
|
+
else
|
|
169
|
+
log.error "Exception '#{e}' encountered fetching namespace metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}"
|
|
170
|
+
@stats.bump(:namespace_cache_api_nil_error)
|
|
171
|
+
end
|
|
172
|
+
{}
|
|
173
|
+
rescue StandardError => e
|
|
174
|
+
@stats.bump(:namespace_cache_api_nil_error)
|
|
175
|
+
log.error "Exception '#{e}' encountered fetching namespace metadata from Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}"
|
|
176
|
+
{}
|
|
157
177
|
end
|
|
158
178
|
|
|
159
179
|
def initialize
|
|
160
180
|
super
|
|
161
181
|
@prev_time = Time.now
|
|
182
|
+
@ssl_options = {}
|
|
183
|
+
@auth_options = {}
|
|
162
184
|
end
|
|
163
185
|
|
|
164
186
|
def configure(conf)
|
|
@@ -230,7 +252,7 @@ module Fluent::Plugin
|
|
|
230
252
|
end
|
|
231
253
|
|
|
232
254
|
if present?(@kubernetes_url)
|
|
233
|
-
ssl_options = {
|
|
255
|
+
@ssl_options = {
|
|
234
256
|
client_cert: present?(@client_cert) ? OpenSSL::X509::Certificate.new(File.read(@client_cert)) : nil,
|
|
235
257
|
client_key: present?(@client_key) ? OpenSSL::PKey::RSA.new(File.read(@client_key)) : nil,
|
|
236
258
|
ca_file: @ca_file,
|
|
@@ -249,24 +271,14 @@ module Fluent::Plugin
|
|
|
249
271
|
0x80000
|
|
250
272
|
end
|
|
251
273
|
ssl_store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL | flagval
|
|
252
|
-
ssl_options[:cert_store] = ssl_store
|
|
274
|
+
@ssl_options[:cert_store] = ssl_store
|
|
253
275
|
end
|
|
254
276
|
|
|
255
|
-
auth_options = {}
|
|
256
|
-
|
|
257
277
|
if present?(@bearer_token_file)
|
|
258
|
-
|
|
259
|
-
auth_options[:bearer_token] = bearer_token
|
|
278
|
+
@auth_options[:bearer_token_file] = @bearer_token_file
|
|
260
279
|
end
|
|
261
280
|
|
|
262
|
-
|
|
263
|
-
@client = Kubeclient::Client.new(
|
|
264
|
-
@kubernetes_url,
|
|
265
|
-
@apiVersion,
|
|
266
|
-
ssl_options: ssl_options,
|
|
267
|
-
auth_options: auth_options,
|
|
268
|
-
as: :parsed_symbolized
|
|
269
|
-
)
|
|
281
|
+
create_client()
|
|
270
282
|
|
|
271
283
|
if @test_api_adapter
|
|
272
284
|
log.info "Extending client with test api adaper #{@test_api_adapter}"
|
|
@@ -305,6 +317,18 @@ module Fluent::Plugin
|
|
|
305
317
|
end
|
|
306
318
|
end
|
|
307
319
|
|
|
320
|
+
def create_client()
|
|
321
|
+
log.debug 'Creating K8S client'
|
|
322
|
+
@client = nil
|
|
323
|
+
@client = Kubeclient::Client.new(
|
|
324
|
+
@kubernetes_url,
|
|
325
|
+
@apiVersion,
|
|
326
|
+
ssl_options: @ssl_options,
|
|
327
|
+
auth_options: @auth_options,
|
|
328
|
+
as: :parsed_symbolized
|
|
329
|
+
)
|
|
330
|
+
end
|
|
331
|
+
|
|
308
332
|
def get_metadata_for_record(namespace_name, pod_name, container_name, cache_key, create_time, batch_miss_cache, docker_id)
|
|
309
333
|
metadata = {
|
|
310
334
|
'docker' => { 'container_id' => "" },
|
|
@@ -331,44 +355,36 @@ module Fluent::Plugin
|
|
|
331
355
|
metadata
|
|
332
356
|
end
|
|
333
357
|
|
|
334
|
-
def
|
|
335
|
-
return es if (es.respond_to?(:empty?) && es.empty?) || !es.is_a?(Fluent::EventStream)
|
|
336
|
-
new_es = Fluent::MultiEventStream.new
|
|
358
|
+
def filter(tag, time, record)
|
|
337
359
|
tag_match_data = tag.match(@tag_to_kubernetes_name_regexp_compiled) unless @use_journal
|
|
338
|
-
tag_metadata = nil
|
|
339
360
|
batch_miss_cache = {}
|
|
340
|
-
|
|
341
|
-
if tag_match_data &&
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
metadata = k_metadata
|
|
366
|
-
end
|
|
367
|
-
record = record.merge(metadata) if metadata
|
|
368
|
-
new_es.add(time, record)
|
|
361
|
+
if tag_match_data
|
|
362
|
+
cache_key = if tag_match_data.names.include?('pod_uuid') && !tag_match_data['pod_uuid'].nil?
|
|
363
|
+
tag_match_data['pod_uuid']
|
|
364
|
+
else
|
|
365
|
+
tag_match_data['docker_id']
|
|
366
|
+
end
|
|
367
|
+
docker_id = tag_match_data.names.include?('docker_id') ? tag_match_data['docker_id'] : nil
|
|
368
|
+
tag_metadata = get_metadata_for_record(tag_match_data['namespace'], tag_match_data['pod_name'], tag_match_data['container_name'],
|
|
369
|
+
cache_key, create_time_from_record(record, time), batch_miss_cache, docker_id)
|
|
370
|
+
end
|
|
371
|
+
metadata = Marshal.load(Marshal.dump(tag_metadata)) if tag_metadata
|
|
372
|
+
if (@use_journal || @use_journal.nil?) &&
|
|
373
|
+
(j_metadata = get_metadata_for_journal_record(record, time, batch_miss_cache))
|
|
374
|
+
metadata = j_metadata
|
|
375
|
+
end
|
|
376
|
+
if @lookup_from_k8s_field && record.key?('kubernetes') && record.key?('docker') &&
|
|
377
|
+
record['kubernetes'].respond_to?(:has_key?) && record['docker'].respond_to?(:has_key?) &&
|
|
378
|
+
record['kubernetes'].key?('namespace_name') &&
|
|
379
|
+
record['kubernetes'].key?('pod_name') &&
|
|
380
|
+
record['kubernetes'].key?('container_name') &&
|
|
381
|
+
record['docker'].key?('container_id') &&
|
|
382
|
+
(k_metadata = get_metadata_for_record(record['kubernetes']['namespace_name'], record['kubernetes']['pod_name'],
|
|
383
|
+
record['kubernetes']['container_name'], record['docker']['container_id'],
|
|
384
|
+
create_time_from_record(record, time), batch_miss_cache, record['docker']['container_id']))
|
|
385
|
+
metadata = k_metadata
|
|
369
386
|
end
|
|
370
|
-
|
|
371
|
-
new_es
|
|
387
|
+
metadata ? record.merge(metadata) : record
|
|
372
388
|
end
|
|
373
389
|
|
|
374
390
|
def get_metadata_for_journal_record(record, time, batch_miss_cache)
|
|
@@ -46,6 +46,39 @@ module KubernetesMetadata
|
|
|
46
46
|
@stats.bump(:namespace_watch_gone_errors)
|
|
47
47
|
log.info('410 Gone encountered. Restarting namespace watch to reset resource versions.', e)
|
|
48
48
|
namespace_watcher = nil
|
|
49
|
+
rescue KubeException => e
|
|
50
|
+
if e.error_code == 401
|
|
51
|
+
# recreate client to refresh token
|
|
52
|
+
log.info("Encountered '401 Unauthorized' exception in watch, recreating client to refresh token")
|
|
53
|
+
create_client()
|
|
54
|
+
namespace_watcher = nil
|
|
55
|
+
else
|
|
56
|
+
# treat all other errors the same as StandardError, log, swallow and reset
|
|
57
|
+
@stats.bump(:namespace_watch_failures)
|
|
58
|
+
if Thread.current[:namespace_watch_retry_count] < @watch_retry_max_times
|
|
59
|
+
# Instead of raising exceptions and crashing Fluentd, swallow
|
|
60
|
+
# the exception and reset the watcher.
|
|
61
|
+
log.info(
|
|
62
|
+
'Exception encountered parsing namespace watch event. ' \
|
|
63
|
+
'The connection might have been closed. Sleeping for ' \
|
|
64
|
+
"#{Thread.current[:namespace_watch_retry_backoff_interval]} " \
|
|
65
|
+
'seconds and resetting the namespace watcher.', e
|
|
66
|
+
)
|
|
67
|
+
sleep(Thread.current[:namespace_watch_retry_backoff_interval])
|
|
68
|
+
Thread.current[:namespace_watch_retry_count] += 1
|
|
69
|
+
Thread.current[:namespace_watch_retry_backoff_interval] *= @watch_retry_exponential_backoff_base
|
|
70
|
+
namespace_watcher = nil
|
|
71
|
+
else
|
|
72
|
+
# Since retries failed for many times, log as errors instead
|
|
73
|
+
# of info and raise exceptions and trigger Fluentd to restart.
|
|
74
|
+
message =
|
|
75
|
+
'Exception encountered parsing namespace watch event. The ' \
|
|
76
|
+
'connection might have been closed. Retried ' \
|
|
77
|
+
"#{@watch_retry_max_times} times yet still failing. Restarting."
|
|
78
|
+
log.error(message, e)
|
|
79
|
+
raise Fluent::UnrecoverableError, message
|
|
80
|
+
end
|
|
81
|
+
end
|
|
49
82
|
rescue StandardError => e
|
|
50
83
|
@stats.bump(:namespace_watch_failures)
|
|
51
84
|
if Thread.current[:namespace_watch_retry_count] < @watch_retry_max_times
|
|
@@ -47,6 +47,39 @@ module KubernetesMetadata
|
|
|
47
47
|
@stats.bump(:pod_watch_gone_errors)
|
|
48
48
|
log.info('410 Gone encountered. Restarting pod watch to reset resource versions.', e)
|
|
49
49
|
pod_watcher = nil
|
|
50
|
+
rescue KubeException => e
|
|
51
|
+
if e.error_code == 401
|
|
52
|
+
# recreate client to refresh token
|
|
53
|
+
log.info("Encountered '401 Unauthorized' exception in watch, recreating client to refresh token")
|
|
54
|
+
create_client()
|
|
55
|
+
namespace_watcher = nil
|
|
56
|
+
else
|
|
57
|
+
# treat all other errors the same as StandardError, log, swallow and reset
|
|
58
|
+
@stats.bump(:pod_watch_failures)
|
|
59
|
+
if Thread.current[:pod_watch_retry_count] < @watch_retry_max_times
|
|
60
|
+
# Instead of raising exceptions and crashing Fluentd, swallow
|
|
61
|
+
# the exception and reset the watcher.
|
|
62
|
+
log.info(
|
|
63
|
+
'Exception encountered parsing pod watch event. The ' \
|
|
64
|
+
'connection might have been closed. Sleeping for ' \
|
|
65
|
+
"#{Thread.current[:pod_watch_retry_backoff_interval]} " \
|
|
66
|
+
'seconds and resetting the pod watcher.', e
|
|
67
|
+
)
|
|
68
|
+
sleep(Thread.current[:pod_watch_retry_backoff_interval])
|
|
69
|
+
Thread.current[:pod_watch_retry_count] += 1
|
|
70
|
+
Thread.current[:pod_watch_retry_backoff_interval] *= @watch_retry_exponential_backoff_base
|
|
71
|
+
pod_watcher = nil
|
|
72
|
+
else
|
|
73
|
+
# Since retries failed for many times, log as errors instead
|
|
74
|
+
# of info and raise exceptions and trigger Fluentd to restart.
|
|
75
|
+
message =
|
|
76
|
+
'Exception encountered parsing pod watch event. The ' \
|
|
77
|
+
'connection might have been closed. Retried ' \
|
|
78
|
+
"#{@watch_retry_max_times} times yet still failing. Restarting."
|
|
79
|
+
log.error(message, e)
|
|
80
|
+
raise Fluent::UnrecoverableError, message
|
|
81
|
+
end
|
|
82
|
+
end
|
|
50
83
|
rescue StandardError => e
|
|
51
84
|
@stats.bump(:pod_watch_failures)
|
|
52
85
|
if Thread.current[:pod_watch_retry_count] < @watch_retry_max_times
|
|
@@ -156,15 +156,6 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
|
|
|
156
156
|
d.filtered.map(&:last)
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
test 'nil event stream' do
|
|
160
|
-
# not certain how this is possible but adding test to properly
|
|
161
|
-
# guard against this condition we have seen - test for nil,
|
|
162
|
-
# empty, no empty method, not an event stream
|
|
163
|
-
plugin = create_driver.instance
|
|
164
|
-
plugin.filter_stream('tag', nil)
|
|
165
|
-
plugin.filter_stream('tag', Fluent::MultiEventStream.new)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
159
|
sub_test_case 'parsing_pod_metadata when container_status is missing from the pod status' do
|
|
169
160
|
test 'using the tag_to_kubernetes_name_regexp for /var/log/containers ' do
|
|
170
161
|
VCR.use_cassettes(
|
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.
|
|
4
|
+
version: 2.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenShift Cluster Logging
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2022-
|
|
12
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fluentd
|
|
@@ -20,7 +20,7 @@ dependencies:
|
|
|
20
20
|
version: 0.14.0
|
|
21
21
|
- - "<"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: '1.
|
|
23
|
+
version: '1.16'
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -30,7 +30,7 @@ dependencies:
|
|
|
30
30
|
version: 0.14.0
|
|
31
31
|
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.
|
|
33
|
+
version: '1.16'
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: kubeclient
|
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -266,14 +266,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
266
266
|
requirements:
|
|
267
267
|
- - ">="
|
|
268
268
|
- !ruby/object:Gem::Version
|
|
269
|
-
version: 2.
|
|
269
|
+
version: 2.6.0
|
|
270
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
271
|
requirements:
|
|
272
272
|
- - ">="
|
|
273
273
|
- !ruby/object:Gem::Version
|
|
274
274
|
version: '0'
|
|
275
275
|
requirements: []
|
|
276
|
-
rubygems_version: 3.
|
|
276
|
+
rubygems_version: 3.1.4
|
|
277
277
|
signing_key:
|
|
278
278
|
specification_version: 4
|
|
279
279
|
summary: Fluentd filter plugin to add Kubernetes metadata
|