Skip to content

Commit 05937d2

Browse files
authored
Merge pull request #681 from puppetlabs/P4DEVOPS-6096
(P4DEVOPS-6096) Include VMs that have been requested but not moved to pending when getting queue metrics
2 parents 713d2c9 + 49adcfd commit 05937d2

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ jobs:
7070
prerelease: false
7171

7272
# This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
73-
- name: Install Ruby jruby-9.4.3.0
73+
- name: Install Ruby jruby-9.4.12.1
7474
uses: ruby/setup-ruby@v1
7575
with:
76-
ruby-version: 'jruby-9.4.3.0'
76+
ruby-version: 'jruby-9.4.12.1'
7777

7878
- name: Build gem
7979
run: gem build *.gemspec

.github/workflows/testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
ruby-version:
21-
- 'jruby-9.4.3.0'
21+
- 'jruby-9.4.12.1'
2222
steps:
2323
- uses: actions/checkout@v4
2424
- name: Set up Ruby
@@ -34,7 +34,7 @@ jobs:
3434
strategy:
3535
matrix:
3636
ruby-version:
37-
- 'jruby-9.4.3.0'
37+
- 'jruby-9.4.12.1'
3838
steps:
3939
- uses: actions/checkout@v4
4040
- name: Set up Ruby

Gemfile.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ GEM
187187
PLATFORMS
188188
arm64-darwin-22
189189
universal-java-11
190+
universal-java-17
190191
x86_64-darwin-22
191192
x86_64-linux
192193

lib/vmpooler/api/helpers.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ def get_capacity_metrics(pools, backend)
289289
def get_queue_metrics(pools, backend)
290290
tracer.in_span("Vmpooler::API::Helpers.#{__method__}") do
291291
queue = {
292+
requested: 0,
292293
pending: 0,
293294
cloning: 0,
294295
booting: 0,
@@ -298,6 +299,8 @@ def get_queue_metrics(pools, backend)
298299
total: 0
299300
}
300301

302+
queue[:requested] = get_total_across_pools_redis_scard(pools, 'vmpooler__provisioning__request', backend) + get_total_across_pools_redis_scard(pools, 'vmpooler__provisioning__processing', backend) + get_total_across_pools_redis_scard(pools, 'vmpooler__odcreate__task', backend)
303+
301304
queue[:pending] = get_total_across_pools_redis_scard(pools, 'vmpooler__pending__', backend)
302305
queue[:ready] = get_total_across_pools_redis_scard(pools, 'vmpooler__ready__', backend)
303306
queue[:running] = get_total_across_pools_redis_scard(pools, 'vmpooler__running__', backend)
@@ -306,7 +309,7 @@ def get_queue_metrics(pools, backend)
306309
queue[:cloning] = backend.get('vmpooler__tasks__clone').to_i + backend.get('vmpooler__tasks__ondemandclone').to_i
307310
queue[:booting] = queue[:pending].to_i - queue[:cloning].to_i
308311
queue[:booting] = 0 if queue[:booting] < 0
309-
queue[:total] = queue[:pending].to_i + queue[:ready].to_i + queue[:running].to_i + queue[:completed].to_i
312+
queue[:total] = queue[:requested] + queue[:pending].to_i + queue[:ready].to_i + queue[:running].to_i + queue[:completed].to_i
310313

311314
queue
312315
end

release-prep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Update Gemfile.lock
66
docker run -t --rm \
77
-v $(pwd):/app \
8-
jruby:9.4.3.0-jdk11 \
8+
jruby:9.4.12.1-jdk11 \
99
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
1010

1111
# Update Changelog

spec/unit/api/helpers_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class TestHelpers
116116
allow(redis).to receive(:pipelined).with(no_args).and_return [0]
117117
allow(redis).to receive(:get).and_return 0
118118

119-
expect(subject.get_queue_metrics([], redis)).to eq({pending: 0, cloning: 0, booting: 0, ready: 0, running: 0, completed: 0, total: 0})
119+
expect(subject.get_queue_metrics([], redis)).to eq({requested: 0, pending: 0, cloning: 0, booting: 0, ready: 0, running: 0, completed: 0, total: 0})
120120
end
121121

122122
it 'adds pool queues correctly' do
@@ -128,7 +128,7 @@ class TestHelpers
128128
allow(redis).to receive(:pipelined).with(no_args).and_return [1,1]
129129
allow(redis).to receive(:get).and_return(1,0)
130130

131-
expect(subject.get_queue_metrics(pools, redis)).to eq({pending: 2, cloning: 1, booting: 1, ready: 2, running: 2, completed: 2, total: 8})
131+
expect(subject.get_queue_metrics(pools, redis)).to eq({requested: 6, pending: 2, cloning: 1, booting: 1, ready: 2, running: 2, completed: 2, total: 14})
132132
end
133133

134134
it 'sets booting to 0 when negative calculation' do
@@ -140,7 +140,7 @@ class TestHelpers
140140
allow(redis).to receive(:pipelined).with(no_args).and_return [1,1]
141141
allow(redis).to receive(:get).and_return(5,0)
142142

143-
expect(subject.get_queue_metrics(pools, redis)).to eq({pending: 2, cloning: 5, booting: 0, ready: 2, running: 2, completed: 2, total: 8})
143+
expect(subject.get_queue_metrics(pools, redis)).to eq({requested: 6, pending: 2, cloning: 5, booting: 0, ready: 2, running: 2, completed: 2, total: 14})
144144
end
145145
end
146146

update-gemfile-lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
44
docker run -it --rm \
55
-v $(pwd):/app \
6-
jruby:9.4.3.0-jdk11 \
6+
jruby:9.4.12.1-jdk11 \
77
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'

0 commit comments

Comments
 (0)