Compare commits

..

No commits in common. "main" and "3.3.0" have entirely different histories.
main ... 3.3.0

14 changed files with 37 additions and 141 deletions

View file

@ -5,9 +5,3 @@ updates:
schedule: schedule:
interval: weekly interval: weekly
open-pull-requests-limit: 10 open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10

View file

@ -1,12 +0,0 @@
name: Automated release prep
on:
workflow_dispatch:
jobs:
auto_release_prep:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/auto_release_prep.yml@v1
secrets: inherit
with:
project-type: ruby
version-file-path: lib/vmpooler-provider-vsphere/version.rb

View file

@ -1,8 +0,0 @@
name: Dependabot auto-merge
on: pull_request
jobs:
dependabot_merge:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/dependabot_merge.yml@v1
secrets: inherit

View file

@ -1,8 +0,0 @@
name: Ensure label
on: pull_request
jobs:
ensure_label:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1
secrets: inherit

View file

@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'puppetlabs/vmpooler-provider-vsphere' if: github.repository == 'puppetlabs/vmpooler-provider-vsphere'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Get Current Version - name: Get Current Version
uses: actions/github-script@v7 uses: actions/github-script@v6
id: cv id: cv
with: with:
script: | script: |

View file

@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout repo content - name: checkout repo content
uses: actions/checkout@v4 uses: actions/checkout@v3
with: with:
fetch-depth: 1 fetch-depth: 1
- name: setup ruby - name: setup ruby
@ -22,7 +22,7 @@ jobs:
- name: check lock - name: check lock
run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock' run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock'
# install java # install java
- uses: actions/setup-java@v4 - uses: actions/setup-java@v3
with: with:
distribution: 'temurin' # See 'Supported distributions' for available options distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17' java-version: '17'

View file

@ -20,7 +20,7 @@ jobs:
ruby-version: ruby-version:
- 'jruby-9.4.3.0' - 'jruby-9.4.3.0'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
@ -36,7 +36,7 @@ jobs:
ruby-version: ruby-version:
- 'jruby-9.4.3.0' - 'jruby-9.4.3.0'
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:

View file

@ -1,37 +1,5 @@
# Changelog # Changelog
## [3.3.4](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.4) (2023-08-30)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.3...3.3.4)
**Fixed bugs:**
- \(maint\) Convert booleans and Time objects to strings when being added to redis [\#51](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/51) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.3.3](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.3) (2023-08-28)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.2...3.3.3)
**Fixed bugs:**
- \(maint\) Update Gemfile.lock and use block for transaction. [\#49](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/49) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.3.2](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.2) (2023-08-23)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.1...3.3.2)
**Fixed bugs:**
- \(maint\) Increase timeout for cloned vms to obtain IPs. [\#47](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/47) ([isaac-hammes](https://github.com/isaac-hammes))
## [3.3.1](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.1) (2023-08-22)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.3.0...3.3.1)
**Fixed bugs:**
- \(RE-15710\) Fix IP address that is returned and increase timeout [\#44](https://github.com/puppetlabs/vmpooler-provider-vsphere/pull/44) ([yachub](https://github.com/yachub))
## [3.3.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.0) (2023-08-18) ## [3.3.0](https://github.com/puppetlabs/vmpooler-provider-vsphere/tree/3.3.0) (2023-08-18)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.2.0...3.3.0) [Full Changelog](https://github.com/puppetlabs/vmpooler-provider-vsphere/compare/3.2.0...3.3.0)

View file

@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
vmpooler-provider-vsphere (3.3.4) vmpooler-provider-vsphere (3.3.0)
rbvmomi2 (>= 3.1, < 4.0) rbvmomi2 (>= 3.1, < 4.0)
vmpooler (~> 3.0) vmpooler (~> 3.0)
@ -34,11 +34,11 @@ GEM
net-ldap (0.18.0) net-ldap (0.18.0)
nio4r (2.5.9) nio4r (2.5.9)
nio4r (2.5.9-java) nio4r (2.5.9-java)
nokogiri (1.15.4-java) nokogiri (1.15.3-java)
racc (~> 1.4) racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux) nokogiri (1.15.3-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
opentelemetry-api (1.2.2) opentelemetry-api (1.2.1)
opentelemetry-common (0.20.0) opentelemetry-common (0.20.0)
opentelemetry-api (~> 1.0) opentelemetry-api (~> 1.0)
opentelemetry-exporter-jaeger (0.23.0) opentelemetry-exporter-jaeger (0.23.0)
@ -96,9 +96,9 @@ GEM
coderay (~> 1.1) coderay (~> 1.1)
method_source (~> 1.0) method_source (~> 1.0)
spoon (~> 0.0) spoon (~> 0.0)
puma (6.3.1) puma (6.3.0)
nio4r (~> 2.0) nio4r (~> 2.0)
puma (6.3.1-java) puma (6.3.0-java)
nio4r (~> 2.0) nio4r (~> 2.0)
racc (1.7.1) racc (1.7.1)
racc (1.7.1-java) racc (1.7.1-java)
@ -114,10 +114,7 @@ GEM
json (~> 2.3) json (~> 2.3)
nokogiri (~> 1.12, >= 1.12.5) nokogiri (~> 1.12, >= 1.12.5)
optimist (~> 3.0) optimist (~> 3.0)
redis (5.0.7) redis (4.8.1)
redis-client (>= 0.9.0)
redis-client (0.16.0)
connection_pool
regexp_parser (2.8.1) regexp_parser (2.8.1)
rexml (3.2.6) rexml (3.2.6)
rspec (3.12.0) rspec (3.12.0)
@ -166,9 +163,9 @@ GEM
thrift (0.18.1) thrift (0.18.1)
tilt (2.2.0) tilt (2.2.0)
unicode-display_width (2.4.2) unicode-display_width (2.4.2)
vmpooler (3.5.1) vmpooler (3.2.0)
concurrent-ruby (~> 1.1) concurrent-ruby (~> 1.1)
connection_pool (~> 2.4) connection_pool (~> 2.2)
deep_merge (~> 1.2) deep_merge (~> 1.2)
net-ldap (~> 0.16) net-ldap (~> 0.16)
opentelemetry-exporter-jaeger (= 0.23.0) opentelemetry-exporter-jaeger (= 0.23.0)
@ -183,7 +180,7 @@ GEM
puma (>= 5.0.4, < 7) puma (>= 5.0.4, < 7)
rack (>= 2.2, < 4.0) rack (>= 2.2, < 4.0)
rake (~> 13.0) rake (~> 13.0)
redis (~> 5.0) redis (~> 4.1)
sinatra (>= 2, < 4) sinatra (>= 2, < 4)
spicy-proton (~> 2.1) spicy-proton (~> 2.1)
statsd-ruby (~> 1.4) statsd-ruby (~> 1.4)

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
module VmpoolerProviderVsphere module VmpoolerProviderVsphere
VERSION = '3.3.4' VERSION = '3.3.0'
end end

View file

@ -68,14 +68,14 @@ module Vmpooler
try = 0 if try.nil? try = 0 if try.nil?
max_tries = 3 max_tries = 3
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
redis.multi do |transaction| redis.multi
transaction.srem("vmpooler__completed__#{pool}", vm_name) redis.srem("vmpooler__completed__#{pool}", vm_name)
transaction.hdel("vmpooler__active__#{pool}", vm_name) redis.hdel("vmpooler__active__#{pool}", vm_name)
transaction.hset("vmpooler__vm__#{vm_name}", 'destroy', Time.now.to_s) redis.hset("vmpooler__vm__#{vm_name}", 'destroy', Time.now)
# Auto-expire metadata key # Auto-expire metadata key
transaction.expire("vmpooler__vm__#{vm_name}", (data_ttl * 60 * 60)) redis.expire("vmpooler__vm__#{vm_name}", (data_ttl * 60 * 60))
end redis.exec
end end
start = Time.now start = Time.now
@ -599,15 +599,13 @@ module Vmpooler
boottime = vm_object.runtime.bootTime if vm_object.runtime&.bootTime boottime = vm_object.runtime.bootTime if vm_object.runtime&.bootTime
powerstate = vm_object.runtime.powerState if vm_object.runtime&.powerState powerstate = vm_object.runtime.powerState if vm_object.runtime&.powerState
ip_maxloop = 240 ip_maxloop = 60
ip_loop_delay = 1 ip_loop_delay = 1
ip_loop_count = 1 ip_loop_count = 1
ip = nil ip = nil
invalid_addresses = /(0|169)\.(0|254)\.\d+\.\d+/
while ip.nil? while ip.nil?
sleep(ip_loop_delay) sleep(ip_loop_delay)
ip = vm_object.guest_ip ip = vm_object.guest_ip
ip = nil if !ip.nil? && ip.match?(invalid_addresses)
unless ip_maxloop == 0 unless ip_maxloop == 0
break if ip_loop_count >= ip_maxloop break if ip_loop_count >= ip_maxloop
@ -1103,9 +1101,6 @@ module Vmpooler
begin begin
connection = ensured_vsphere_connection(pool_object) connection = ensured_vsphere_connection(pool_object)
vm_hash = get_vm_details(pool_name, vm_name, connection) vm_hash = get_vm_details(pool_name, vm_name, connection)
raise StandardError, 'failed to get vm details. vm is unreachable or no longer exists' if vm_hash.nil?
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
redis.hset("vmpooler__vm__#{vm_name}", 'host', vm_hash['host_name']) redis.hset("vmpooler__vm__#{vm_name}", 'host', vm_hash['host_name'])
migration_count = redis.scard('vmpooler__migration') migration_count = redis.scard('vmpooler__migration')
@ -1140,10 +1135,10 @@ module Vmpooler
target_host_object = find_host_by_dnsname(connection, target_host_name) target_host_object = find_host_by_dnsname(connection, target_host_name)
finish = migrate_vm_and_record_timing(pool_name, vm_name, vm_hash, target_host_object, target_host_name) finish = migrate_vm_and_record_timing(pool_name, vm_name, vm_hash, target_host_object, target_host_name)
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
redis.multi do |transaction| redis.multi
transaction.hset("vmpooler__vm__#{vm_name}", 'host', target_host_name) redis.hset("vmpooler__vm__#{vm_name}", 'host', target_host_name)
transaction.hset("vmpooler__vm__#{vm_name}", 'migrated', 'true') redis.hset("vmpooler__vm__#{vm_name}", 'migrated', true)
end redis.exec
end end
logger.log('s', "[>] [#{pool_name}] '#{vm_name}' migrated from #{vm_hash['host_name']} to #{target_host_name} in #{finish} seconds") logger.log('s', "[>] [#{pool_name}] '#{vm_name}' migrated from #{vm_hash['host_name']} to #{target_host_name} in #{finish} seconds")
ensure ensure
@ -1161,10 +1156,10 @@ module Vmpooler
metrics.increment("migrate_to.#{dest_host_name}") metrics.increment("migrate_to.#{dest_host_name}")
@redis.with_metrics do |redis| @redis.with_metrics do |redis|
checkout_to_migration = format('%<time>.2f', time: Time.now - Time.parse(redis.hget("vmpooler__vm__#{vm_name}", 'checkout'))) checkout_to_migration = format('%<time>.2f', time: Time.now - Time.parse(redis.hget("vmpooler__vm__#{vm_name}", 'checkout')))
redis.multi do |transaction| redis.multi
transaction.hset("vmpooler__vm__#{vm_name}", 'migration_time', finish) redis.hset("vmpooler__vm__#{vm_name}", 'migration_time', finish)
transaction.hset("vmpooler__vm__#{vm_name}", 'checkout_to_migration', checkout_to_migration) redis.hset("vmpooler__vm__#{vm_name}", 'checkout_to_migration', checkout_to_migration)
end redis.exec
end end
finish finish
end end

View file

@ -3,13 +3,13 @@
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment # The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
# #
# Update Gemfile.lock # Update Gemfile.lock
docker run -t --rm \ docker run -it --rm \
-v $(pwd):/app \ -v $(pwd):/app \
jruby:9.4.3.0-jdk11 \ jruby:9.4.3.0-jdk11 \
/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=$?"' /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=$?"'
# Update Changelog # Update Changelog
docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \ docker run -it --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator:1.16.2 \ githubchangeloggenerator/github-changelog-generator:1.16.2 \
github_changelog_generator --future-release $(grep VERSION lib/vmpooler-provider-vsphere/version.rb |rev |cut -d "'" -f2 |rev) github_changelog_generator --future-release $(grep VERSION lib/vmpooler-provider-vsphere/version.rb |rev |cut -d "'" -f2 |rev)

View file

@ -818,7 +818,7 @@ end
def mock_RbVmomi_VIM_VirtualMachine(options = {}) def mock_RbVmomi_VIM_VirtualMachine(options = {})
options[:snapshot_tree] = nil if options[:snapshot_tree].nil? options[:snapshot_tree] = nil if options[:snapshot_tree].nil?
options[:name] = 'VM' + rand(65536).to_s if options[:name].nil? options[:name] = 'VM' + rand(65536).to_s if options[:name].nil?
options[:ip] = '192.168.0.2' if options[:ip].nil? options[:ip] = '169.254.255.255' if options[:ip].nil?
options[:path] = [] if options[:path].nil? options[:path] = [] if options[:path].nil?
mock = MockVirtualMachine.new() mock = MockVirtualMachine.new()

View file

@ -580,41 +580,11 @@ EOT
end end
end end
context 'when VM exists but contains a self assigned ip' do
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname,
:ip => '169.254.255.255',
})
}
it 'should return nil ip' do
allow(subject).to receive(:sleep)
result = subject.get_vm(poolname,vmname)
expect(result['ip']).to eq(nil)
end
end
context 'when VM exists but contains an invalid ip' do
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname,
:ip => '0.0.0.0',
})
}
it 'should return nil for ip' do
allow(subject).to receive(:sleep)
result = subject.get_vm(poolname,vmname)
expect(result['ip']).to eq(nil)
end
end
context 'when VM exists and contains all information' do context 'when VM exists and contains all information' do
let(:vm_hostname) { "#{vmname}.demo.local" } let(:vm_hostname) { "#{vmname}.demo.local" }
let(:boot_time) { Time.now } let(:boot_time) { Time.now }
let(:power_state) { 'MockPowerState' } let(:power_state) { 'MockPowerState' }
let(:ip) { '192.168.0.2' } let(:ip) { '169.254.255.255' }
let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({ let(:vm_object) { mock_RbVmomi_VIM_VirtualMachine({
:name => vmname, :name => vmname,