fluent-plugin-kubernetes_metadata_filter 2.5.1 → 2.5.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 +4 -4
- data/Gemfile.lock +1 -1
- data/fluent-plugin-kubernetes_metadata_filter.gemspec +1 -1
- data/lib/fluent/plugin/kubernetes_metadata_common.rb +6 -0
- data/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb +14 -3
- data/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +3 -8
- data/test/plugin/test_watch_namespaces.rb +40 -0
- data/test/plugin/test_watch_pods.rb +26 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a683b622df5649113828c46b650d722a5042c4c92023de4ea3350c1a5057bf8c
|
4
|
+
data.tar.gz: 86572e207c7aa2b595510922ac7b3946d3f2f1a4031d3f795d8356700c54d140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77a3f4c2b33a0fe48e7b85636415d9b1d8d7aa1bba07af6c801290830a14f2c190c2dec76f9d48c7f0bc99131cb785dcf681217c5e42e90f3dfc9a24ad81f6e2
|
7
|
+
data.tar.gz: 051563042ca5826bb5f07a00367672b63718aac7a49f4e32cd9b83ba1312493ebafeee5211c8846eb4f3b0d5ec07f22c52d6f24ae059c4c6560d707f8a60404a
|
data/Gemfile.lock
CHANGED
@@ -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.5.
|
7
|
+
gem.version = "2.5.2"
|
8
8
|
gem.authors = ["Jimmi Dyson"]
|
9
9
|
gem.email = ["jimmidyson@gmail.com"]
|
10
10
|
gem.description = %q{Filter plugin to add Kubernetes metadata}
|
@@ -39,6 +39,12 @@ module KubernetesMetadata
|
|
39
39
|
begin
|
40
40
|
namespace_watcher ||= get_namespaces_and_start_watcher
|
41
41
|
process_namespace_watcher_notices(namespace_watcher)
|
42
|
+
rescue GoneError => e
|
43
|
+
# Expected error. Quietly go back through the loop in order to
|
44
|
+
# start watching from the latest resource versions
|
45
|
+
@stats.bump(:namespace_watch_gone_errors)
|
46
|
+
log.info("410 Gone encountered. Restarting namespace watch to reset resource versions.", e)
|
47
|
+
namespace_watcher = nil
|
42
48
|
rescue Exception => e
|
43
49
|
@stats.bump(:namespace_watch_failures)
|
44
50
|
if Thread.current[:namespace_watch_retry_count] < @watch_retry_max_times
|
@@ -123,9 +129,14 @@ module KubernetesMetadata
|
|
123
129
|
# deleted but still processing logs
|
124
130
|
@stats.bump(:namespace_cache_watch_deletes_ignored)
|
125
131
|
when 'ERROR'
|
126
|
-
|
127
|
-
|
128
|
-
|
132
|
+
if notice.object && notice.object['code'] == 410
|
133
|
+
@stats.bump(:namespace_watch_gone_notices)
|
134
|
+
raise GoneError
|
135
|
+
else
|
136
|
+
@stats.bump(:namespace_watch_error_type_notices)
|
137
|
+
message = notice['object']['message'] if notice['object'] && notice['object']['message']
|
138
|
+
raise "Error while watching namespaces: #{message}"
|
139
|
+
end
|
129
140
|
else
|
130
141
|
reset_namespace_watch_retry_stats
|
131
142
|
# Don't pay attention to creations, since the created namespace may not
|
@@ -20,12 +20,6 @@ require_relative 'kubernetes_metadata_common'
|
|
20
20
|
|
21
21
|
module KubernetesMetadata
|
22
22
|
|
23
|
-
class GoneError < StandardError
|
24
|
-
def initialize(msg="410 Gone")
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
23
|
module WatchPods
|
30
24
|
|
31
25
|
include ::KubernetesMetadata::Common
|
@@ -46,10 +40,11 @@ module KubernetesMetadata
|
|
46
40
|
begin
|
47
41
|
pod_watcher ||= get_pods_and_start_watcher
|
48
42
|
process_pod_watcher_notices(pod_watcher)
|
49
|
-
rescue GoneError
|
43
|
+
rescue GoneError => e
|
50
44
|
# Expected error. Quietly go back through the loop in order to
|
51
45
|
# start watching from the latest resource versions
|
52
|
-
|
46
|
+
@stats.bump(:pod_watch_gone_errors)
|
47
|
+
log.info("410 Gone encountered. Restarting pod watch to reset resource versions.", e)
|
53
48
|
pod_watcher = nil
|
54
49
|
rescue Exception => e
|
55
50
|
@stats.bump(:pod_watch_failures)
|
@@ -76,6 +76,20 @@ class WatchNamespacesTestTest < WatchTest
|
|
76
76
|
'message' => 'some error message'
|
77
77
|
}
|
78
78
|
)
|
79
|
+
@gone = OpenStruct.new(
|
80
|
+
type: 'ERROR',
|
81
|
+
object: {
|
82
|
+
'code' => 410,
|
83
|
+
'kind' => 'Status',
|
84
|
+
'message' => 'too old resource version: 123 (391079)',
|
85
|
+
'metadata' => {
|
86
|
+
'name' => 'gone',
|
87
|
+
'namespace' => 'gone',
|
88
|
+
'uid' => 'gone_uid'
|
89
|
+
},
|
90
|
+
'reason' => 'Gone'
|
91
|
+
}
|
92
|
+
)
|
79
93
|
end
|
80
94
|
|
81
95
|
test 'namespace list caches namespaces' do
|
@@ -179,4 +193,30 @@ class WatchNamespacesTestTest < WatchTest
|
|
179
193
|
end
|
180
194
|
end
|
181
195
|
end
|
196
|
+
|
197
|
+
test 'namespace watch raises a GoneError when a 410 Gone error is received' do
|
198
|
+
@cache['gone_uid'] = {}
|
199
|
+
@client.stub :watch_namespaces, [@gone] do
|
200
|
+
assert_raise KubernetesMetadata::Common::GoneError do
|
201
|
+
process_namespace_watcher_notices(start_namespace_watch)
|
202
|
+
end
|
203
|
+
assert_equal(1, @stats[:namespace_watch_gone_notices])
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
test 'namespace watch retries when 410 Gone errors are encountered' do
|
208
|
+
@client.stub :get_namespaces, @initial do
|
209
|
+
@client.stub :watch_namespaces, [@created, @gone, @modified] do
|
210
|
+
# Force the infinite watch loop to exit after 3 seconds. Verifies that
|
211
|
+
# no unrecoverable error was thrown during this period of time.
|
212
|
+
assert_raise Timeout::Error.new('execution expired') do
|
213
|
+
Timeout.timeout(3) do
|
214
|
+
set_up_namespace_thread
|
215
|
+
end
|
216
|
+
end
|
217
|
+
assert_operator(@stats[:namespace_watch_gone_errors], :>=, 3)
|
218
|
+
assert_operator(@stats[:namespace_watch_gone_notices], :>=, 3)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
182
222
|
end
|
@@ -244,16 +244,6 @@ class DefaultPodWatchStrategyTest < WatchTest
|
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
247
|
-
test 'pod watch raises a GoneError when a 410 Gone error is received' do
|
248
|
-
@cache['gone_uid'] = {}
|
249
|
-
@client.stub :watch_pods, [@gone] do
|
250
|
-
assert_raise KubernetesMetadata::GoneError do
|
251
|
-
process_pod_watcher_notices(start_pod_watch)
|
252
|
-
end
|
253
|
-
assert_equal(1, @stats[:pod_watch_gone_notices])
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
247
|
test 'pod watch retries when error is received' do
|
258
248
|
@client.stub :get_pods, @initial do
|
259
249
|
@client.stub :watch_pods, [@error] do
|
@@ -285,4 +275,30 @@ class DefaultPodWatchStrategyTest < WatchTest
|
|
285
275
|
end
|
286
276
|
end
|
287
277
|
end
|
278
|
+
|
279
|
+
test 'pod watch raises a GoneError when a 410 Gone error is received' do
|
280
|
+
@cache['gone_uid'] = {}
|
281
|
+
@client.stub :watch_pods, [@gone] do
|
282
|
+
assert_raise KubernetesMetadata::Common::GoneError do
|
283
|
+
process_pod_watcher_notices(start_pod_watch)
|
284
|
+
end
|
285
|
+
assert_equal(1, @stats[:pod_watch_gone_notices])
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
test 'pod watch retries when 410 Gone errors are encountered' do
|
290
|
+
@client.stub :get_pods, @initial do
|
291
|
+
@client.stub :watch_pods, [@created, @gone, @modified] do
|
292
|
+
# Force the infinite watch loop to exit after 3 seconds. Verifies that
|
293
|
+
# no unrecoverable error was thrown during this period of time.
|
294
|
+
assert_raise Timeout::Error.new('execution expired') do
|
295
|
+
Timeout.timeout(3) do
|
296
|
+
set_up_pod_thread
|
297
|
+
end
|
298
|
+
end
|
299
|
+
assert_operator(@stats[:pod_watch_gone_errors], :>=, 3)
|
300
|
+
assert_operator(@stats[:pod_watch_gone_notices], :>=, 3)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
288
304
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kubernetes_metadata_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmi Dyson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
- !ruby/object:Gem::Version
|
260
260
|
version: '0'
|
261
261
|
requirements: []
|
262
|
-
rubygems_version: 3.
|
262
|
+
rubygems_version: 3.0.8
|
263
263
|
signing_key:
|
264
264
|
specification_version: 4
|
265
265
|
summary: Fluentd filter plugin to add Kubernetes metadata
|