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 prerelease: false
# This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment # 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 uses: ruby/setup-ruby@v1
with: with:
ruby-version: 'jruby-9.3.6.0' ruby-version: 'jruby-9.4.1.0'
- name: Build gem - name: Build gem
run: gem build *.gemspec run: gem build *.gemspec

View file

@ -18,8 +18,7 @@ jobs:
strategy: strategy:
matrix: matrix:
ruby-version: ruby-version:
- 'jruby-9.3.6.0' - 'jruby-9.4.1.0'
- 'jruby-9.4.0.0'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby
@ -35,8 +34,7 @@ jobs:
strategy: strategy:
matrix: matrix:
ruby-version: ruby-version:
- 'jruby-9.3.6.0' - 'jruby-9.4.1.0'
- 'jruby-9.4.0.0'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby

View file

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

View file

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

View file

@ -540,17 +540,15 @@ module Vmpooler
}, },
kind: :client kind: :client
) do ) do
Timeout.timeout(timeout) do target_host = host
target_host = host target_host = "#{host}.#{domain}" if domain
target_host = "#{host}.#{domain}" if domain span = OpenTelemetry::Trace.current_span
span = OpenTelemetry::Trace.current_span span.set_attribute('net.peer.name', target_host)
span.set_attribute('net.peer.name', target_host) sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
sock = TCPSocket.new target_host, port begin
begin yield sock if block_given?
yield sock if block_given? ensure
ensure sock.close
sock.close
end
end end
end end
end end

View file

@ -3,5 +3,5 @@
# 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
docker run -it --rm \ docker run -it --rm \
-v $(pwd):/app \ -v $(pwd):/app \
jruby:9.3.6-jdk \ jruby:9.4.1.0-jdk11 \
/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=$?"' /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=$?"'