From 42fdb4e85c02bc12e81b4141cb1af44f33ed0617 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Wed, 14 Feb 2024 07:04:43 -0800 Subject: [PATCH] Drop stomp gem from pdk The stomp gem used to be an mcollective dependency. We stopped shipping mco a long time ago. This only affects the pdk, as the other runtimes already dropped the stomp gem, see 64f4aecc46446cec1e5bbccaddba8255a39c47f1. --- configs/components/_base-ruby-stomp.rb | 54 -------- configs/components/ruby-2.7-stomp.rb | 18 --- configs/components/ruby-stomp.rb | 3 - configs/projects/_pdk-components.rb | 2 - .../connection_loss_reconnect_fix.patch | 125 ------------------ 5 files changed, 202 deletions(-) delete mode 100644 configs/components/_base-ruby-stomp.rb delete mode 100644 configs/components/ruby-2.7-stomp.rb delete mode 100644 configs/components/ruby-stomp.rb delete mode 100644 resources/patches/ruby-stomp/connection_loss_reconnect_fix.patch diff --git a/configs/components/_base-ruby-stomp.rb b/configs/components/_base-ruby-stomp.rb deleted file mode 100644 index b87d36996..000000000 --- a/configs/components/_base-ruby-stomp.rb +++ /dev/null @@ -1,54 +0,0 @@ -# This file is a basis for multiple versions/targets of ruby-stomp. -# It should not be included as a component; Instead other components should -# load it with instance_eval. See ruby-x.y-stomp.rb configs. -# - -# These can be overridden by the including component. -ruby_version ||= settings[:ruby_version] -ruby_bindir ||= settings[:ruby_bindir] -gem_home ||= settings[:gem_home] -gem_install ||= settings[:gem_install] - -# Projects may define a :ruby_stomp_version setting, or we use 1.4.4 by default: -version = settings[:ruby_stomp_version] || '1.4.4' -pkg.version version - -case version -when '1.4.4' - pkg.md5sum "1224b9efe7381cea25c506c9c6e28373" -when '1.3.3' - pkg.md5sum "50a2c1b66982b426d67a83f56f4bc0e2" -else - raise "ruby-stomp version #{version} has not been configured; Cannot continue." -end - -pkg.url "https://rubygems.org/downloads/stomp-#{pkg.get_version}.gem" -pkg.mirror "#{settings[:buildsources_url]}/stomp-#{pkg.get_version}.gem" - -pkg.build_requires "ruby-#{ruby_version}" - -# Because we are cross-compiling on sparc, we can't use the rubygems we just built. -# Instead we use the host gem installation and override GEM_HOME. Yay? -pkg.environment "GEM_HOME", gem_home - -if platform.is_windows? - pkg.environment "PATH", "$(shell cygpath -u #{settings[:gcc_bindir]}):$(shell cygpath -u #{ruby_bindir}):$(shell cygpath -u #{settings[:bindir]}):/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0" -end - -# PA-25 in order to install gems in a cross-compiled environment we need to -# set RUBYLIB to include puppet and hiera, so that their gemspecs can resolve -# hiera/version and puppet/version requires. Without this the gem install -# will fail by blowing out the stack. -if settings[:ruby_vendordir] - pkg.environment "RUBYLIB", "#{settings[:ruby_vendordir]}:$(RUBYLIB)" -end - -if version == '1.3.3' - base = 'resources/patches/ruby-stomp' - pkg.apply_patch "#{base}/verify_client_certs.patch", destination: "#{gem_home}/gems/stomp-#{pkg.get_version}", after: "install" - pkg.apply_patch "#{base}/connection_loss_reconnect_fix.patch", destination: "#{gem_home}/gems/stomp-#{pkg.get_version}", after: "install" -end - -pkg.install do - ["#{gem_install} stomp-#{pkg.get_version}.gem"] -end diff --git a/configs/components/ruby-2.7-stomp.rb b/configs/components/ruby-2.7-stomp.rb deleted file mode 100644 index bef8250ea..000000000 --- a/configs/components/ruby-2.7-stomp.rb +++ /dev/null @@ -1,18 +0,0 @@ -component 'ruby-2.7-stomp' do |pkg, settings, platform| - expected_ruby_version = '2.7.8' - - unless settings[:ruby_version] == expected_ruby_version - unless settings.key?(:additional_rubies) && settings[:additional_rubies].key?(expected_ruby_version) - raise "No config found for Ruby #{expected_ruby_version} in settings[:additional_rubies]" - end - - ruby_settings = settings[:additional_rubies][expected_ruby_version] - - ruby_version = ruby_settings[:ruby_version] - ruby_bindir = ruby_settings[:ruby_bindir] - gem_home = ruby_settings[:gem_home] - gem_install = ruby_settings[:gem_install] - end - - instance_eval File.read('configs/components/_base-ruby-stomp.rb') -end diff --git a/configs/components/ruby-stomp.rb b/configs/components/ruby-stomp.rb deleted file mode 100644 index 50270c4f1..000000000 --- a/configs/components/ruby-stomp.rb +++ /dev/null @@ -1,3 +0,0 @@ -component "ruby-stomp" do |pkg, settings, platform| - instance_eval File.read('configs/components/_base-ruby-stomp.rb') -end diff --git a/configs/projects/_pdk-components.rb b/configs/projects/_pdk-components.rb index 8d347e202..4bc31801e 100644 --- a/configs/projects/_pdk-components.rb +++ b/configs/projects/_pdk-components.rb @@ -27,7 +27,6 @@ proj.component 'ruby-augeas' unless platform.is_windows? proj.component 'ruby-selinux' if platform.is_el? || platform.is_fedora? -proj.component 'ruby-stomp' # Additional Rubies if proj.respond_to?(:additional_rubies) @@ -43,7 +42,6 @@ proj.component "ruby-#{ruby_minor}-augeas" unless platform.is_windows? proj.component "ruby-#{ruby_minor}-selinux" if platform.is_el? || platform.is_fedora? - proj.component "ruby-#{ruby_minor}-stomp" proj.component "post-additional-rubies" end end diff --git a/resources/patches/ruby-stomp/connection_loss_reconnect_fix.patch b/resources/patches/ruby-stomp/connection_loss_reconnect_fix.patch deleted file mode 100644 index bf742fb60..000000000 --- a/resources/patches/ruby-stomp/connection_loss_reconnect_fix.patch +++ /dev/null @@ -1,125 +0,0 @@ -From ed5da4d1d857c427bf995e50c9baa25befaa3175 Mon Sep 17 00:00:00 2001 -From: Reid Vandewiele -Date: Thu, 1 Jun 2017 16:22:08 -0700 -Subject: [PATCH] Ensure IO#gets exits in a reasonable time - -According to the notes on heartbeats, `max_hbrlck_fails` should be -enabled in order to determine when heartbeats stop arriving. This is -required because the receive thread of the MCO daemon spends most of its -time waiting for something to come in over the wire. That ties up the -"read lock" used to provide exclusive access to the underlying network -socket. - -However, the blocking receive should consume heartbeats and update the -"last received" timestamp (`@lr`). The heartbeat read thread also -consumes pings coming in over the wire in case the process is not -blocking on receive. - -Normal operation means that a missed hbrlck is normal, but two in a row -should be abnormal (the heartbeat thread may try to read and get locked, -but the receive thread should read the heartbeat before the heartbeat -thread resumes - networking timing could impact this in bad ways - and -reset the "last received" timestamp which will trigger resetting the -`read_lock_count` and `lock_fail_count` the next time the heartbeat -thread wakes). - -When the `lock_fail_count` exceeds `@max_hbrlck_fails`, the heartbeat -thread closes the socket and kills the heartbeat threads. The -expectation is that this should cause the `IO#gets` call in the receive -call to return. That doesn't happen until TCP timeouts occur, which can -take minutes or hours. When the TCP timeout occurs, it appears to leave -the main thread in an unexpected state that sometimes results in SIGABRT -and is unreachable via the broker. - -To exit `gets` early, trigger an exception in the `receive` thread. -That interrupts the `gets` call and is caught in the `transmit` or -`__old_receive` method and initiates a reconnect. ---- - lib/connection/heartbeats.rb | 6 +++--- - lib/connection/netio.rb | 19 +++++++++++++++---- - lib/stomp/connection.rb | 1 + - 3 files changed, 19 insertions(+), 7 deletions(-) - -diff --git a/lib/connection/heartbeats.rb b/lib/connection/heartbeats.rb -index ae350dd..dc0cb15 100644 ---- a/lib/connection/heartbeats.rb -+++ b/lib/connection/heartbeats.rb -@@ -232,9 +232,9 @@ module Stomp - # Retry on max lock fails. Different logic in order to avoid a deadlock. - if (@max_hbrlck_fails > 0 && lock_fail_count >= @max_hbrlck_fails) - # This is an attempt at a connection retry. -- begin -- @socket.close # Attempt a forced close -- rescue -+ @gets_semaphore.synchronize do -+ @getst.raise(Errno::EBADF.new) if @getst rescue nil # kill the socket reading thread if exists -+ @socket.close rescue nil # Attempt a forced close - end - @st.kill if @st # Kill the sender thread if one exists - Thread.exit # This receiver thread is done -diff --git a/lib/connection/netio.rb b/lib/connection/netio.rb -index f9e84be..d0e2d2f 100644 ---- a/lib/connection/netio.rb -+++ b/lib/connection/netio.rb -@@ -11,6 +11,17 @@ module Stomp - - private - -+ def _interruptible_gets(read_socket) -+ # The gets thread may be interrupted by the heartbeat thread. Ensure that -+ # if so interrupted, a new gets cannot start until after the heartbeat -+ # thread finishes its work. This is PURELY to avoid a segfault bug -+ # involving OpenSSL::Buffer. -+ @gets_semaphore.synchronize { @getst = Thread.current } -+ read_socket.gets -+ ensure -+ @gets_semaphore.synchronize { @getst = nil } -+ end -+ - # Really read from the wire. - def _receive(read_socket, connread = false) - @read_semaphore.synchronize do -@@ -40,7 +51,7 @@ module Stomp - message_header = '' - begin - message_header += line -- line = read_socket.gets -+ line = _interruptible_gets(read_socket) - # p [ "wiredatain_02", line ] - raise Stomp::Error::StompServerError if line.nil? - line = _normalize_line_end(line) if @protocol >= Stomp::SPL_12 -@@ -382,16 +393,16 @@ module Stomp - if @jruby - # Handle JRuby specific behavior. - while true -- line = read_socket.gets # Data from wire -+ line = _interruptible_gets(read_socket) # Data from wire - break unless line == "\n" - line = '' - end - else -- line = read_socket.gets # The old way -+ line = _interruptible_gets(read_socket) # The old way - end - else # We are >= 1.1 *AND* receiving heartbeats. - while true -- line = read_socket.gets # Data from wire -+ line = _interruptible_gets(read_socket) # Data from wire - break unless line == "\n" - line = '' - @lr = Time.now.to_f -diff --git a/lib/stomp/connection.rb b/lib/stomp/connection.rb -index bd690f0..729fc95 100644 ---- a/lib/stomp/connection.rb -+++ b/lib/stomp/connection.rb -@@ -135,6 +135,7 @@ module Stomp - @transmit_semaphore = Mutex.new - @read_semaphore = Mutex.new - @socket_semaphore = Mutex.new -+ @gets_semaphore = Mutex.new - - @subscriptions = {} - @failure = nil --- -2.13.1 -