xcflushd 1.1.0 → 1.2.0

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
  SHA1:
3
- metadata.gz: 8ce36d38201d9c3738a277cddbbae9b1f7a79a05
4
- data.tar.gz: bddd1d1f27f34ded85d5d8cebeeced9b292ac7f0
3
+ metadata.gz: 19c512d589477a74d1ade15d47a120f089f8955d
4
+ data.tar.gz: 0d3b16a8a1127980a9e36f126855686fd2f3958c
5
5
  SHA512:
6
- metadata.gz: d4f02d26ef2fb8cdf559b5741f6c514df6a63b5a071618cc7048138ee43003d5717de46cc57c60a93d0337b46066038a58d0c3521328a890470d219609b50a3c
7
- data.tar.gz: 8f01cfd539c1e763288f9149efa16755b05edaeb22c5d29bdae7baac6df13e1a0310e20b11cc99ce831ad3fa4b81c44da5680ea398fcb2a54b028c2090765f09
6
+ metadata.gz: 9a06128d9b86a58539faf979fa6456ad39f7be4e1fc85b2191983c534e417a7ab5d9af625ca4ac068bc6d0293c145c4030dd12eb8f3c5bbb5b5273db9bb73d53
7
+ data.tar.gz: c3fbc3c768d11fd0a00c6c7853d564541e7821015d9922588f93faf6d0125e671d53bed208ebdabd0d97fa1e430af61beb7bb08fa1e75d7c52bfcd4d913c587e
@@ -1,3 +1,15 @@
1
+ ## [1.2.0] - 2017-06-21
2
+
3
+ Note: this version requires Apicast-XC >= v1.3.0.
4
+
5
+ - The priority auth renewer now only publishes each response in the redis
6
+ pubsub channel once, unless there is an error while publishing.
7
+ We were publishing each response several times, but that was because of a
8
+ race condition caused by Apicast-XC that has been fixed. This change improves
9
+ performance a bit because it lowers the number of commands issued to Redis.
10
+ - Introduced minor changes in the Dockerfile that decrease the image size.
11
+
12
+
1
13
  ## [1.1.0] - 2017-05-02
2
14
  - Switched from MRI to JRuby. our tests show that JRuby performs better than
3
15
  MRI when there is a high number of calls to be made to 3scale's backend in a
data/Dockerfile CHANGED
@@ -33,7 +33,7 @@ RUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache \
33
33
  && chown -R ${USER_NAME}: ${USER_HOME} \
34
34
  && apt-get -y -q clean
35
35
 
36
- RUN apt-get install -y -q openjdk-8-jre
36
+ RUN apt-get install -y -q openjdk-8-jre && apt-get -y -q clean
37
37
 
38
38
  USER ${USER_NAME}
39
39
 
@@ -67,7 +67,7 @@ ARG BUILD_DEPS="libyaml-dev libreadline-dev libncurses-dev libffi-dev libgdbm3 l
67
67
  USER root
68
68
  RUN test -z "${BUILD_DEPS}" \
69
69
  || ( \
70
- apt-get update && apt-get install -y -q ${BUILD_DEPS} \
70
+ apt-get update && apt-get install -y -q ${BUILD_DEPS} && apt-get -y -q clean \
71
71
  )
72
72
 
73
73
  WORKDIR ${APP_HOME}
@@ -81,7 +81,8 @@ RUN rbenv install -s \
81
81
  && gem update --system \
82
82
  && ( bundler --version || gem install bundler ) \
83
83
  && bundle config --global jobs `grep -c processor /proc/cpuinfo` \
84
- && bundle config --global cache_all true
84
+ && bundle config --global cache_all true \
85
+ && gem cleanup all
85
86
 
86
87
  COPY Gemfile Gemfile.lock xcflushd.gemspec ${APP_HOME}/
87
88
  COPY lib/xcflushd/version.rb ${APP_HOME}/lib/xcflushd/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xcflushd (1.1.0)
4
+ xcflushd (1.2.0)
5
5
  3scale_client (~> 2.11)
6
6
  concurrent-ruby (~> 1.0.5)
7
7
  daemons (~> 1.2.4)
@@ -149,7 +149,7 @@ module Xcflushd
149
149
  # in the auths that failed. Also, as we do not publish anything when
150
150
  # there is an error, the subscriber waits until it timeouts.
151
151
  # This is good enough for now, but there is room for improvement.
152
- publish_auth_repeatedly(combination, metric_auth) if success
152
+ publish_auth(combination, metric_auth) if success
153
153
  end
154
154
  end
155
155
 
@@ -173,51 +173,35 @@ module Xcflushd
173
173
  combination[:metric])
174
174
  end
175
175
 
176
- def publish_auth_repeatedly(combination, authorization)
177
- # There is a race condition here. A renew and publish task is only run
178
- # when there is not another one renewing the same combination. When there
179
- # is another, the incoming request does not trigger a new task, but waits
180
- # for the publish below. The request could miss the published message
181
- # if events happened in this order:
182
- # 1) The request publishes the combination it needs in the requests
183
- # channel.
184
- # 2) A new task is not executed, because there is another renewing
185
- # the same combination.
186
- # 3) That task publishes the result.
187
- # 4) The request subscribes to receive the result, but now it is
188
- # too late.
189
- # I cannot think of an easy way to solve this. There is some time
190
- # between the moment the requests performs the publish and the
191
- # subscribe actions. To mitigate the problem we can publish several
192
- # times during some ms. We will see if this is good enough.
193
- # Trade-off: Waiting long times between publishing attempts reduces the
194
- # probability of triggering the problem described. However, it also makes
195
- # incoming requests slow because tasks accumulate in the thread pool
196
- # waiting.
197
- publish_failures = 0
198
- PUBLISH_WAIT_TIMES.each do |wait_time|
199
- begin
200
- publish_auth(combination, authorization)
201
- rescue
202
- publish_failures += 1
203
- end
204
- sleep(wait_time)
176
+ def authorization_message(authorization)
177
+ if authorization.authorized?
178
+ '1'.freeze
179
+ else
180
+ authorization.reason ? "0:#{authorization.reason}" : '0'.freeze
205
181
  end
182
+ end
206
183
 
207
- if publish_failures > 0
208
- logger.warn('There was an error while publishing a response in the '\
209
- "priority channel. Combination: #{combination}".freeze)
184
+ def publish_message(channel, msg)
185
+ wait = PUBLISH_WAIT_TIMES.each
186
+
187
+ begin
188
+ redis_pub.publish(channel, msg)
189
+ rescue => e
190
+ begin
191
+ sleep wait.next
192
+ rescue StopIteration
193
+ raise e
194
+ end
195
+ retry
210
196
  end
211
197
  end
212
198
 
213
199
  def publish_auth(combination, authorization)
214
- msg = if authorization.authorized?
215
- '1'.freeze
216
- else
217
- authorization.reason ? "0:#{authorization.reason}" : '0'.freeze
218
- end
219
-
220
- redis_pub.publish(channel_for_combination(combination), msg)
200
+ publish_message channel_for_combination(combination),
201
+ authorization_message(authorization)
202
+ rescue => e
203
+ logger.warn "cannot publish in priority channel " \
204
+ "for combination #{combination}: #{e}"
221
205
  end
222
206
 
223
207
  def currently_authorizing?(channel_msg)
@@ -33,12 +33,18 @@ module Xcflushd
33
33
  redis = Redis.new(host: redis_host, port: redis_port, driver: redis_driver)
34
34
  storage = Storage.new(redis, @logger, StorageKeys)
35
35
 
36
+ # The 3scale client shows a warning when using provider keys, because
37
+ # they are deprecated in favor of service tokens. However, we need to
38
+ # continue using provider keys, so we set warn_deprecated to false to
39
+ # avoid generating unnecessary warnings.
36
40
  threescale = ThreeScale::Client.new(provider_key: opts[:provider_key],
37
41
  host: opts[:backend].host,
38
42
  port: opts[:backend].port ||
39
43
  (opts[:secure] ? 443 : 80),
40
44
  secure: opts[:secure],
41
- persistent: true)
45
+ persistent: true,
46
+ warn_deprecated: false)
47
+
42
48
  reporter = Reporter.new(threescale)
43
49
  authorizer = Authorizer.new(threescale)
44
50
 
@@ -155,8 +155,11 @@ module Xcflushd
155
155
  logger.error(SOME_REPORTS_MISSING_ERROR)
156
156
  else
157
157
  keys.each_with_index do |key, i|
158
- # The usage could be empty if we failed to rename the key in the
159
- # previous step. hgetall returns {} for keys that do not exist.
158
+ # hgetall returns {} for keys that do not exist. That can happen
159
+ # for 2 reasons:
160
+ # 1) Apicast-xc does not guarantee that a key in the set of cached
161
+ # reports will always exist.
162
+ # 2) We failed to rename the key in the previous step.
160
163
  unless usages[i].empty?
161
164
  service_id, creds = storage_keys.service_and_creds(key, suffix)
162
165
  result << { service_id: service_id,
@@ -1,3 +1,3 @@
1
1
  module Xcflushd
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcflushd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Martinez Ruiz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-05-02 00:00:00.000000000 Z
12
+ date: 2017-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  requirements: []
267
267
  rubyforge_project:
268
- rubygems_version: 2.6.12
268
+ rubygems_version: 2.6.8
269
269
  signing_key:
270
270
  specification_version: 4
271
271
  summary: Daemon for flushing XC reports to 3scale.