From 713a4a2c9d5f304b43a626020d139d4596018726 Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Thu, 2 Mar 2023 11:27:55 -0800 Subject: [PATCH 1/4] (maint) Use timeout builtin to TCPSocket when opening sockets. --- lib/vmpooler/providers/vsphere.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/vmpooler/providers/vsphere.rb b/lib/vmpooler/providers/vsphere.rb index c572d48..e76e972 100644 --- a/lib/vmpooler/providers/vsphere.rb +++ b/lib/vmpooler/providers/vsphere.rb @@ -632,15 +632,13 @@ module Vmpooler # This should supercede the open_socket method in the Pool Manager def open_socket(host, domain = nil, timeout = 5, port = 22, &_block) - Timeout.timeout(timeout) do - target_host = host - target_host = "#{host}.#{domain}" if domain - sock = TCPSocket.new target_host, port - begin - yield sock if block_given? - ensure - sock.close - end + target_host = host + target_host = "#{host}.#{domain}" if domain + sock = TCPSocket.new(target_host, port, connect_timeout: timeout) + begin + yield sock if block_given? + ensure + sock.close end end From 5e1891b990dd72ae6210ffae7fa3148243ea7847 Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Thu, 2 Mar 2023 11:38:53 -0800 Subject: [PATCH 2/4] (maint) Update to jruby-9.4.1.0. --- .github/workflows/release.yml | 2 +- .github/workflows/testing.yml | 6 ++---- Gemfile.lock | 24 ++++++++++++------------ update-gemfile-lock | 4 ++-- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2251c3f..0761b75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,7 +73,7 @@ jobs: - name: Install Ruby jruby-9.3.6.0 uses: ruby/setup-ruby@v1 with: - ruby-version: 'jruby-9.3.6.0' + ruby-version: 'jruby-9.4.1.0' - name: Build gem run: gem build *.gemspec diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 86955f6..eac55b3 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -18,8 +18,7 @@ jobs: strategy: matrix: ruby-version: - - 'jruby-9.3.6.0' - - 'jruby-9.4.0.0' + - 'jruby-9.4.1.0' steps: - uses: actions/checkout@v3 - name: Set up Ruby @@ -35,8 +34,7 @@ jobs: strategy: matrix: ruby-version: - - 'jruby-9.3.6.0' - - 'jruby-9.4.0.0' + - 'jruby-9.4.1.0' steps: - uses: actions/checkout@v3 - name: Set up Ruby diff --git a/Gemfile.lock b/Gemfile.lock index d12cb1d..1821170 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,11 +9,11 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) - bindata (2.4.14) + bindata (2.4.15) builder (3.2.4) climate_control (1.2.0) coderay (1.1.3) - concurrent-ruby (1.2.0) + concurrent-ruby (1.2.2) connection_pool (2.3.0) deep_merge (1.2.2) diff-lcs (1.5.0) @@ -33,7 +33,7 @@ GEM ruby2_keywords (~> 0.0.1) net-ldap (0.17.1) nio4r (2.5.8-java) - nokogiri (1.13.10-java) + nokogiri (1.14.2-java) racc (~> 1.4) opentelemetry-api (1.1.0) opentelemetry-common (0.19.6) @@ -74,7 +74,7 @@ GEM opentelemetry-api (~> 1.0) optimist (3.0.1) parallel (1.22.1) - parser (3.2.0.0) + parser (3.2.1.0) ast (~> 2.4.1) pickup (0.0.11) prometheus-client (2.1.0) @@ -97,14 +97,14 @@ GEM json (~> 2.3) nokogiri (~> 1.12, >= 1.12.5) optimist (~> 3.0) - redis (4.8.0) - regexp_parser (2.6.2) + redis (4.8.1) + regexp_parser (2.7.0) rexml (3.2.5) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) rspec-mocks (~> 3.12.0) - rspec-core (3.12.0) + rspec-core (3.12.1) rspec-support (~> 3.12.0) rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) @@ -122,9 +122,9 @@ GEM rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.24.1) - parser (>= 3.1.1.0) - ruby-progressbar (1.11.0) + rubocop-ast (1.27.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.12.0) ruby2_keywords (0.0.5) simplecov (0.22.0) docile (~> 1.1) @@ -143,8 +143,8 @@ GEM ffi statsd-ruby (1.5.0) thor (1.2.1) - thrift (0.17.0) - tilt (2.0.11) + thrift (0.18.1) + tilt (2.1.0) unicode-display_width (2.4.2) vmpooler (2.4.0) concurrent-ruby (~> 1.1) diff --git a/update-gemfile-lock b/update-gemfile-lock index 74e9c78..c1f2491 100755 --- a/update-gemfile-lock +++ b/update-gemfile-lock @@ -3,5 +3,5 @@ # The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment docker run -it --rm \ -v $(pwd):/app \ - jruby:9.3.6-jdk \ - /bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends make git && cd /app && gem install bundler && bundle install --jobs 3 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"' + jruby:9.4.1.0-jdk8 \ + /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=$?"' From 0fb77b917d8caba64bbf46680cfa907cffd99529 Mon Sep 17 00:00:00 2001 From: isaac-hammes Date: Thu, 2 Mar 2023 11:50:06 -0800 Subject: [PATCH 3/4] (maint) Update spec tests for timeout change. --- spec/unit/providers/vsphere_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/unit/providers/vsphere_spec.rb b/spec/unit/providers/vsphere_spec.rb index f2a1975..14d9097 100644 --- a/spec/unit/providers/vsphere_spec.rb +++ b/spec/unit/providers/vsphere_spec.rb @@ -1399,44 +1399,44 @@ EOT end it 'opens socket with defaults' do - expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket) + expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 5}).and_return(socket) expect(subject.open_socket(hostname)).to eq(nil) end it 'yields the socket if a block is given' do - expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket) + expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: nil}).and_return(socket) expect{ |socket| subject.open_socket(hostname,nil,nil,default_socket,&socket) }.to yield_control.exactly(1).times end it 'closes the opened socket' do - expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_return(socket) + expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 5}).and_return(socket) expect(socket).to receive(:close) expect(subject.open_socket(hostname)).to eq(nil) end it 'opens a specific socket' do - expect(TCPSocket).to receive(:new).with(hostname,80).and_return(socket) + expect(TCPSocket).to receive(:new).with(hostname,80,{connect_timeout: nil}).and_return(socket) expect(subject.open_socket(hostname,nil,nil,80)).to eq(nil) end it 'uses a specific domain with the hostname' do - expect(TCPSocket).to receive(:new).with("#{hostname}.#{domain}",default_socket).and_return(socket) + expect(TCPSocket).to receive(:new).with("#{hostname}.#{domain}",default_socket,{connect_timeout: 5}).and_return(socket) expect(subject.open_socket(hostname,domain)).to eq(nil) end it 'raises error if host is not resolvable' do - expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_raise(SocketError,'getaddrinfo: No such host is known') + expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 1}).and_raise(SocketError,'getaddrinfo: No such host is known') expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError) end it 'raises error if socket is not listening' do - expect(TCPSocket).to receive(:new).with(hostname,default_socket).and_raise(SocketError,'No connection could be made because the target machine actively refused it') + expect(TCPSocket).to receive(:new).with(hostname,default_socket,{connect_timeout: 1}).and_raise(SocketError,'No connection could be made because the target machine actively refused it') expect { subject.open_socket(hostname,nil,1) }.to raise_error(SocketError) end From abeabe5a429af114ac1addc969202fc39f533677 Mon Sep 17 00:00:00 2001 From: Jake Spain Date: Fri, 3 Mar 2023 22:01:40 -0500 Subject: [PATCH 4/4] Bump to java 11 --- update-gemfile-lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update-gemfile-lock b/update-gemfile-lock index c1f2491..46c4873 100755 --- a/update-gemfile-lock +++ b/update-gemfile-lock @@ -3,5 +3,5 @@ # The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment docker run -it --rm \ -v $(pwd):/app \ - jruby:9.4.1.0-jdk8 \ + jruby:9.4.1.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 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'