Merge pull request #555 from puppetlabs/change_timeout_method

(maint) Use timeout builtin to TCPSocket when opening sockets.
This commit is contained in:
Jake Spain 2023-03-06 13:59:45 -05:00 committed by GitHub
commit 9754c89c92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 63 deletions

View file

@ -70,10 +70,10 @@ jobs:
prerelease: false
# This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
- name: Install Ruby jruby-9.3.6.0
- name: Install Ruby jruby-9.4.1.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

View file

@ -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

View file

@ -27,31 +27,31 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
bindata (2.4.10)
bindata (2.4.15)
builder (3.2.4)
climate_control (1.2.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
connection_pool (2.2.5)
concurrent-ruby (1.2.2)
connection_pool (2.3.0)
deep_merge (1.2.2)
diff-lcs (1.5.0)
docile (1.4.0)
faraday (2.3.0)
faraday-net_http (~> 2.0)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (2.0.3)
faraday-net_http (3.0.2)
ffi (1.15.5-java)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
method_source (1.0.0)
mock_redis (0.32.0)
mock_redis (0.36.0)
ruby2_keywords
mustermann (2.0.2)
ruby2_keywords (~> 0.0.1)
net-ldap (0.17.1)
nio4r (2.5.8)
nio4r (2.5.8-java)
opentelemetry-api (1.0.2)
opentelemetry-api (1.1.0)
opentelemetry-common (0.19.6)
opentelemetry-api (~> 1.0)
opentelemetry-exporter-jaeger (0.20.1)
@ -76,57 +76,57 @@ GEM
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-registry (0.1.0)
opentelemetry-api (~> 1.0.1)
opentelemetry-registry (0.2.0)
opentelemetry-api (~> 1.1)
opentelemetry-resource_detectors (0.19.1)
google-cloud-env
opentelemetry-sdk
opentelemetry-sdk (1.1.0)
opentelemetry-api (~> 1.0)
opentelemetry-sdk (1.2.0)
opentelemetry-api (~> 1.1)
opentelemetry-common (~> 0.19.3)
opentelemetry-registry (~> 0.1)
opentelemetry-registry (~> 0.2)
opentelemetry-semantic_conventions
opentelemetry-semantic_conventions (1.8.0)
opentelemetry-api (~> 1.0)
parallel (1.22.1)
parser (3.1.2.0)
parser (3.2.1.0)
ast (~> 2.4.1)
pickup (0.0.11)
prometheus-client (2.1.0)
pry (0.14.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry (0.14.1-java)
pry (0.14.2-java)
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
puma (5.6.4)
puma (5.6.5)
nio4r (~> 2.0)
puma (5.6.4-java)
puma (5.6.5-java)
nio4r (~> 2.0)
rack (2.2.4)
rack-protection (2.2.2)
rack (2.2.6.2)
rack-protection (2.2.4)
rack
rack-test (2.0.2)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.0.6)
redis (4.7.1)
regexp_parser (2.5.0)
redis (4.8.1)
regexp_parser (2.7.0)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
rspec-mocks (~> 3.11.0)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
rspec-expectations (3.11.0)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 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)
rspec-support (~> 3.11.0)
rspec-mocks (3.11.1)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.28.2)
parallel (~> 1.10)
parser (>= 3.1.0.0)
@ -136,30 +136,30 @@ GEM
rubocop-ast (>= 1.17.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.19.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.21.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinatra (2.2.2)
sinatra (2.2.4)
mustermann (~> 2.0)
rack (~> 2.2)
rack-protection (= 2.2.2)
rack-protection (= 2.2.4)
tilt (~> 2.0)
spicy-proton (2.1.14)
spicy-proton (2.1.15)
bindata (~> 2.3)
spoon (0.0.6)
ffi
statsd-ruby (1.5.0)
thor (1.2.1)
thrift (0.16.0)
tilt (2.0.11)
unicode-display_width (2.2.0)
thrift (0.18.1)
tilt (2.1.0)
unicode-display_width (2.4.2)
yarjuf (2.0.0)
builder
rspec (~> 3)

View file

@ -34,7 +34,7 @@ module Vmpooler
config_string = ENV['VMPOOLER_CONFIG']
# Parse the YAML config into a Hash
# Allow the Symbol class
parsed_config = YAML.safe_load(config_string, [Symbol])
parsed_config = YAML.safe_load(config_string, permitted_classes: [Symbol])
else
# Take the name of the config file either from an ENV variable or from the filepath argument
config_file = ENV['VMPOOLER_CONFIG_FILE'] || filepath

View file

@ -540,12 +540,11 @@ module Vmpooler
},
kind: :client
) do
Timeout.timeout(timeout) do
target_host = host
target_host = "#{host}.#{domain}" if domain
span = OpenTelemetry::Trace.current_span
span.set_attribute('net.peer.name', target_host)
sock = TCPSocket.new target_host, port
sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
begin
yield sock if block_given?
ensure
@ -553,7 +552,6 @@ module Vmpooler
end
end
end
end
def vm_ready?(vm_name, domain = nil)
tracer.in_span("Vmpooler::API::Helpers.#{__method__}") do

View file

@ -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-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=$?"'