fluent-plugin-kubernetes_metadata_filter 2.4.4 → 2.4.5

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: '0960ac42673a9a25d8c1e293f152f432a89abe9bdad0cf2065670c9a5dee2a0c'
4
- data.tar.gz: d351fb9d627c46b6da586ed9fa77f64ac2c3d475f924473a948fc190b3bbc9b2
3
+ metadata.gz: e067ab263fb4e86956da0e6ee07540701e8c728b3f658a9e7d27fbca6ac28307
4
+ data.tar.gz: 155aff320729d471fe41a09b9a5b838ac70f4bc5d32de39f95735d8ec4cf2213
5
5
  SHA512:
6
- metadata.gz: 2cf30a65489f4d740302fa0c461cec207f0d8581a88be4a3692059a40fd17f3619b38f291f5a5dc3f585965d264113ed556d0f9fdea848a1ff818a0e7aa959e8
7
- data.tar.gz: 66b9d0ad3e645b2f98c4a19f3d73cec2970a1e99a442520c2ea21d127be3071d2b54d020c97c37d3766324e92e1b035dbbb1782ed539c2db22294ebd0f571ad9
6
+ metadata.gz: afa694eaa98e032be272fcc94a6a6c9703185255f43d24475c0b1516e2ef3fb4f57040398e67197512701c5b3e14c04946c9516efee1dcefdf922342d592731c
7
+ data.tar.gz: 528302e11718e025dbadd349122fd7addd345284781b38c6a03d9bb8815b25d744248ec4cee866324fe13f40b340dedb424cbf33ec9a8e1f6a1782ba851aca29
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-kubernetes_metadata_filter (2.4.4)
4
+ fluent-plugin-kubernetes_metadata_filter (2.4.5)
5
5
  fluentd (>= 0.14.0, < 2)
6
6
  kubeclient (< 5)
7
7
  lru_redux
data/README.md CHANGED
@@ -208,6 +208,7 @@ Then output becomes as belows
208
208
  "host": "jimmi-redhat.localnet",
209
209
  "pod_name":"fabric8-console-controller-98rqc",
210
210
  "pod_id": "c76927af-f563-11e4-b32d-54ee7527188d",
211
+ "pod_ip": "172.17.0.8",
211
212
  "container_name": "fabric8-console-container",
212
213
  "namespace_name": "default",
213
214
  "namespace_id": "23437884-8e08-4d95-850b-e94378c9b2fd",
@@ -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.4.4"
7
+ gem.version = "2.4.5"
8
8
  gem.authors = ["Jimmi Dyson"]
9
9
  gem.email = ["jimmidyson@gmail.com"]
10
10
  gem.description = %q{Filter plugin to add Kubernetes metadata}
@@ -29,7 +29,6 @@ module KubernetesMetadata
29
29
  # the configuration.
30
30
  namespace_watcher = start_namespace_watch
31
31
  Thread.current[:namespace_watch_retry_backoff_interval] = @watch_retry_interval
32
- Thread.current[:namespace_watch_retry_count] = 0
33
32
 
34
33
  # Any failures / exceptions in the followup watcher notice
35
34
  # processing will be swallowed and retried. These failures /
@@ -96,11 +95,19 @@ module KubernetesMetadata
96
95
  watcher
97
96
  end
98
97
 
98
+ # Reset namespace watch retry count and backoff interval as there is a
99
+ # successful watch notice.
100
+ def reset_namespace_watch_retry_stats
101
+ Thread.current[:namespace_watch_retry_count] = 0
102
+ Thread.current[:namespace_watch_retry_backoff_interval] = @watch_retry_interval
103
+ end
104
+
99
105
  # Process a watcher notice and potentially raise an exception.
100
106
  def process_namespace_watcher_notices(watcher)
101
107
  watcher.each do |notice|
102
108
  case notice.type
103
109
  when 'MODIFIED'
110
+ reset_namespace_watch_retry_stats
104
111
  cache_key = notice.object['metadata']['uid']
105
112
  cached = @namespace_cache[cache_key]
106
113
  if cached
@@ -110,10 +117,16 @@ module KubernetesMetadata
110
117
  @stats.bump(:namespace_cache_watch_misses)
111
118
  end
112
119
  when 'DELETED'
120
+ reset_namespace_watch_retry_stats
113
121
  # ignore and let age out for cases where
114
122
  # deleted but still processing logs
115
123
  @stats.bump(:namespace_cache_watch_deletes_ignored)
124
+ when 'ERROR'
125
+ @stats.bump(:namespace_watch_error_type_notices)
126
+ message = notice['object']['message'] if notice['object'] && notice['object']['message']
127
+ raise "Error while watching namespaces: #{message}"
116
128
  else
129
+ reset_namespace_watch_retry_stats
117
130
  # Don't pay attention to creations, since the created namespace may not
118
131
  # be used by any namespace on this node.
119
132
  @stats.bump(:namespace_cache_watch_ignored)
@@ -98,12 +98,19 @@ module KubernetesMetadata
98
98
  watcher
99
99
  end
100
100
 
101
+ # Reset pod watch retry count and backoff interval as there is a
102
+ # successful watch notice.
103
+ def reset_pod_watch_retry_stats
104
+ Thread.current[:pod_watch_retry_count] = 0
105
+ Thread.current[:pod_watch_retry_backoff_interval] = @watch_retry_interval
106
+ end
107
+
101
108
  # Process a watcher notice and potentially raise an exception.
102
109
  def process_pod_watcher_notices(watcher)
103
110
  watcher.each do |notice|
104
111
  case notice.type
105
112
  when 'MODIFIED'
106
- Thread.current[:pod_watch_retry_count] = 0
113
+ reset_pod_watch_retry_stats
107
114
  cache_key = notice.object['metadata']['uid']
108
115
  cached = @cache[cache_key]
109
116
  if cached
@@ -116,12 +123,16 @@ module KubernetesMetadata
116
123
  @stats.bump(:pod_cache_watch_misses)
117
124
  end
118
125
  when 'DELETED'
119
- Thread.current[:pod_watch_retry_count] = 0
126
+ reset_pod_watch_retry_stats
120
127
  # ignore and let age out for cases where pods
121
128
  # deleted but still processing logs
122
129
  @stats.bump(:pod_cache_watch_delete_ignored)
130
+ when 'ERROR'
131
+ @stats.bump(:pod_watch_error_type_notices)
132
+ message = notice['object']['message'] if notice['object'] && notice['object']['message']
133
+ raise "Error while watching pods: #{message}"
123
134
  else
124
- Thread.current[:pod_watch_retry_count] = 0
135
+ reset_pod_watch_retry_stats
125
136
  # Don't pay attention to creations, since the created pod may not
126
137
  # end up on this node.
127
138
  @stats.bump(:pod_cache_watch_ignored)
@@ -70,6 +70,12 @@ class WatchNamespacesTestTest < WatchTest
70
70
  }
71
71
  }
72
72
  )
73
+ @error = OpenStruct.new(
74
+ type: 'ERROR',
75
+ object: {
76
+ 'message' => 'some error message'
77
+ }
78
+ )
73
79
  end
74
80
 
75
81
  test 'namespace list caches namespaces' do
@@ -137,6 +143,39 @@ class WatchNamespacesTestTest < WatchTest
137
143
  assert_equal(3, @stats[:namespace_watch_failures])
138
144
  assert_equal(2, Thread.current[:namespace_watch_retry_count])
139
145
  assert_equal(4, Thread.current[:namespace_watch_retry_backoff_interval])
146
+ assert_nil(@stats[:namespace_watch_error_type_notices])
147
+ end
148
+ end
149
+ end
150
+
151
+ test 'namespace watch retries when error is received' do
152
+ @client.stub :get_namespaces, @initial do
153
+ @client.stub :watch_namespaces, [@error] do
154
+ assert_raise Fluent::UnrecoverableError do
155
+ set_up_namespace_thread
156
+ end
157
+ assert_equal(3, @stats[:namespace_watch_failures])
158
+ assert_equal(2, Thread.current[:namespace_watch_retry_count])
159
+ assert_equal(4, Thread.current[:namespace_watch_retry_backoff_interval])
160
+ assert_equal(3, @stats[:namespace_watch_error_type_notices])
161
+ end
162
+ end
163
+ end
164
+
165
+ test 'namespace watch continues after retries succeed' do
166
+ @client.stub :get_namespaces, @initial do
167
+ @client.stub :watch_namespaces, [@modified, @error, @modified] do
168
+ # Force the infinite watch loop to exit after 3 seconds. Verifies that
169
+ # no unrecoverable error was thrown during this period of time.
170
+ assert_raise Timeout::Error.new('execution expired') do
171
+ Timeout.timeout(3) do
172
+ set_up_namespace_thread
173
+ end
174
+ end
175
+ assert_operator(@stats[:namespace_watch_failures], :>=, 3)
176
+ assert_operator(Thread.current[:namespace_watch_retry_count], :<=, 1)
177
+ assert_operator(Thread.current[:namespace_watch_retry_backoff_interval], :<=, 1)
178
+ assert_operator(@stats[:namespace_watch_error_type_notices], :>=, 3)
140
179
  end
141
180
  end
142
181
  end
@@ -136,6 +136,12 @@ class DefaultPodWatchStrategyTest < WatchTest
136
136
  }
137
137
  }
138
138
  )
139
+ @error = OpenStruct.new(
140
+ type: 'ERROR',
141
+ object: {
142
+ 'message' => 'some error message'
143
+ }
144
+ )
139
145
  end
140
146
 
141
147
  test 'pod list caches pods' do
@@ -219,6 +225,39 @@ class DefaultPodWatchStrategyTest < WatchTest
219
225
  assert_equal(3, @stats[:pod_watch_failures])
220
226
  assert_equal(2, Thread.current[:pod_watch_retry_count])
221
227
  assert_equal(4, Thread.current[:pod_watch_retry_backoff_interval])
228
+ assert_nil(@stats[:pod_watch_error_type_notices])
229
+ end
230
+ end
231
+ end
232
+
233
+ test 'pod watch retries when error is received' do
234
+ @client.stub :get_pods, @initial do
235
+ @client.stub :watch_pods, [@error] do
236
+ assert_raise Fluent::UnrecoverableError do
237
+ set_up_pod_thread
238
+ end
239
+ assert_equal(3, @stats[:pod_watch_failures])
240
+ assert_equal(2, Thread.current[:pod_watch_retry_count])
241
+ assert_equal(4, Thread.current[:pod_watch_retry_backoff_interval])
242
+ assert_equal(3, @stats[:pod_watch_error_type_notices])
243
+ end
244
+ end
245
+ end
246
+
247
+ test 'pod watch continues after retries succeed' do
248
+ @client.stub :get_pods, @initial do
249
+ @client.stub :watch_pods, [@modified, @error, @modified] do
250
+ # Force the infinite watch loop to exit after 3 seconds. Verifies that
251
+ # no unrecoverable error was thrown during this period of time.
252
+ assert_raise Timeout::Error.new('execution expired') do
253
+ Timeout.timeout(3) do
254
+ set_up_pod_thread
255
+ end
256
+ end
257
+ assert_operator(@stats[:pod_watch_failures], :>=, 3)
258
+ assert_operator(Thread.current[:pod_watch_retry_count], :<=, 1)
259
+ assert_operator(Thread.current[:pod_watch_retry_backoff_interval], :<=, 1)
260
+ assert_operator(@stats[:pod_watch_error_type_notices], :>=, 3)
222
261
  end
223
262
  end
224
263
  end
@@ -33,6 +33,8 @@ class WatchTest < Test::Unit::TestCase
33
33
  @watch_retry_exponential_backoff_base = 2
34
34
  @cache = {}
35
35
  @stats = KubernetesMetadata::Stats.new
36
+ Thread.current[:pod_watch_retry_count] = 0
37
+ Thread.current[:namespace_watch_retry_count] = 0
36
38
 
37
39
  @client = OpenStruct.new
38
40
  def @client.resourceVersion
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.4.4
4
+ version: 2.4.5
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-03-12 00:00:00.000000000 Z
11
+ date: 2020-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd