vmpooler 0.13.2 → 0.13.3

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: a200f3215b389575c605363ed55bb21b9a1779084cee39fef88fe28c2a51e9ab
4
- data.tar.gz: fd48ee0ff0fd5ea1f19dbd0b19bce49d821b0a17ef6f62aca91804cbdebc7d88
3
+ metadata.gz: fe0ef9bcf3e665cc952fce0975a4381883fca200ef93a883e54c7db7e1fc10e7
4
+ data.tar.gz: d44b61c41a57f940cf0df4bf07aabed10b1a72e91cae5b2105f092a7d98d6d05
5
5
  SHA512:
6
- metadata.gz: 63df277bab9ab5f049886d30166856ba5adfc85119e3408d91339827f6b05d3b12dde49c78c051c23d90bf123590e14d6cc7e41598cd315f2df9637a5c7c7042
7
- data.tar.gz: 3f6ce744a9c792c12800d7da0b6738e995d8f9a0cbc86bd3635977b3c463765b371100f5ea3ad509a15b7bd83be5bf37e4ea72cf7004535a36afe263577ed356
6
+ metadata.gz: e0e7bbec11ceecc5fdee0fe15b3d37e290a6c884a708a6a5acb2e790d54fb1f1e24ec6966973f02bbecd204a29497e9c17ae3b8be26a0d3f15cec508a0d64532
7
+ data.tar.gz: 7302cf41676a65ff5d0bb4108a8f5ac03a96a92e3cd0ec56deee2f2a60d6e73f09eee569ef0f4140e3c27e81a16c3e2d24b951764a772bdeaa082a96d8bde1fe
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'vmpooler/util/parsing'
4
+
3
5
  module Vmpooler
4
6
  class API
5
7
  class V1 < Sinatra::Base
@@ -334,9 +336,10 @@ module Vmpooler
334
336
  end
335
337
 
336
338
  def too_many_requested?(payload)
337
- payload&.each do |_poolname, count|
339
+ payload&.each do |poolname, count|
338
340
  next unless count.to_i > config['max_ondemand_instances_per_request']
339
341
 
342
+ metrics.increment('ondemandrequest.toomanyrequests.' + poolname)
340
343
  return true
341
344
  end
342
345
  false
@@ -360,6 +363,7 @@ module Vmpooler
360
363
  if backend.exists("vmpooler__odrequest__#{request_id}")
361
364
  result['message'] = "request_id '#{request_id}' has already been created"
362
365
  status 409
366
+ metrics.increment('ondemandrequest.generate.duplicaterequests')
363
367
  return result
364
368
  end
365
369
 
@@ -383,6 +387,7 @@ module Vmpooler
383
387
 
384
388
  result['domain'] = config['domain'] if config['domain']
385
389
  result[:ok] = true
390
+ metrics.increment('ondemandrequest.generate.success')
386
391
  result
387
392
  end
388
393
 
@@ -974,11 +979,9 @@ module Vmpooler
974
979
 
975
980
  if request_hash['status'] == 'ready'
976
981
  result['ready'] = true
977
- platform_parts = request_hash['requested'].split(',')
978
- platform_parts.each do |platform|
979
- pool_alias, pool, _count = platform.split(':')
980
- instances = backend.smembers("vmpooler__#{request_id}__#{pool_alias}__#{pool}")
981
- result[pool_alias] = { 'hostname': instances }
982
+ Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, _count|
983
+ instances = backend.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
984
+ result[platform_alias] = { 'hostname': instances }
982
985
  end
983
986
  result['domain'] = config['domain'] if config['domain']
984
987
  status 200
@@ -989,11 +992,9 @@ module Vmpooler
989
992
  result['message'] = 'The request has been deleted'
990
993
  status 200
991
994
  else
992
- platform_parts = request_hash['requested'].split(',')
993
- platform_parts.each do |platform|
994
- pool_alias, pool, count = platform.split(':')
995
- instance_count = backend.scard("vmpooler__#{request_id}__#{pool_alias}__#{pool}")
996
- result[pool_alias] = {
995
+ Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, count|
996
+ instance_count = backend.scard("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
997
+ result[platform_alias] = {
997
998
  'ready': instance_count.to_s,
998
999
  'pending': (count.to_i - instance_count.to_i).to_s
999
1000
  }
@@ -1017,12 +1018,11 @@ module Vmpooler
1017
1018
  else
1018
1019
  backend.hset("vmpooler__odrequest__#{request_id}", 'status', 'deleted')
1019
1020
 
1020
- platforms.split(',').each do |platform|
1021
- pool_alias, pool, _count = platform.split(':')
1022
- backend.smembers("vmpooler__#{request_id}__#{pool_alias}__#{pool}")&.each do |vm|
1021
+ Parsing.get_platform_pool_count(platforms) do |platform_alias, pool, _count|
1022
+ backend.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")&.each do |vm|
1023
1023
  backend.smove("vmpooler__running__#{pool}", "vmpooler__completed__#{pool}", vm)
1024
1024
  end
1025
- backend.del("vmpooler__#{request_id}__#{pool_alias}__#{pool}")
1025
+ backend.del("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
1026
1026
  end
1027
1027
  backend.expire("vmpooler__odrequest__#{request_id}", 129_600_0)
1028
1028
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'vmpooler/providers'
4
+ require 'vmpooler/util/parsing'
4
5
  require 'spicy-proton'
5
6
  require 'resolv' # ruby standard lib
6
7
 
@@ -1500,9 +1501,7 @@ module Vmpooler
1500
1501
  def vms_ready?(request_id, redis)
1501
1502
  catch :request_not_ready do
1502
1503
  request_hash = redis.hgetall("vmpooler__odrequest__#{request_id}")
1503
- requested_platforms = request_hash['requested'].split(',')
1504
- requested_platforms.each do |platform|
1505
- platform_alias, pool, count = platform.split(':')
1504
+ Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, count|
1506
1505
  pools_filled = redis.scard("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
1507
1506
  throw :request_not_ready unless pools_filled.to_i == count.to_i
1508
1507
  end
@@ -1554,9 +1553,7 @@ module Vmpooler
1554
1553
 
1555
1554
  def remove_vms_for_failed_request(request_id, expiration_ttl, redis)
1556
1555
  request_hash = redis.hgetall("vmpooler__odrequest__#{request_id}")
1557
- requested_platforms = request_hash['requested'].split(',')
1558
- requested_platforms.each do |platform|
1559
- platform_alias, pool, _count = platform.split(':')
1556
+ Parsing.get_platform_pool_count(request_hash['requested']) do |platform_alias, pool, _count|
1560
1557
  pools_filled = redis.smembers("vmpooler__#{request_id}__#{platform_alias}__#{pool}")
1561
1558
  redis.pipelined do
1562
1559
  pools_filled&.each do |vm|
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # utility class shared between apps
4
+ module Vmpooler
5
+ class Parsing
6
+ def self.get_platform_pool_count(requested, &_block)
7
+ requested_platforms = requested.split(',')
8
+ requested_platforms.each do |platform|
9
+ platform_alias, pool, count = platform.split(':')
10
+ raise ArgumentError if platform_alias.nil? || pool.nil? || count.nil?
11
+
12
+ yield platform_alias, pool, count
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vmpooler
4
- VERSION = '0.13.2'
4
+ VERSION = '0.13.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmpooler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-05 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pickup
@@ -229,6 +229,7 @@ files:
229
229
  - lib/vmpooler/public/lib/jquery.min.js
230
230
  - lib/vmpooler/public/vmpooler.css
231
231
  - lib/vmpooler/statsd.rb
232
+ - lib/vmpooler/util/parsing.rb
232
233
  - lib/vmpooler/version.rb
233
234
  - lib/vmpooler/views/dashboard.erb
234
235
  - lib/vmpooler/views/layout.erb
@@ -251,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  - !ruby/object:Gem::Version
252
253
  version: '0'
253
254
  requirements: []
254
- rubygems_version: 3.0.6
255
+ rubygems_version: 3.0.8
255
256
  signing_key:
256
257
  specification_version: 4
257
258
  summary: vmpooler provides configurable pools of instantly-available (running) virtual