From dbd3741c718d0e8e6aa2aa3b2de4baa61c813e89 Mon Sep 17 00:00:00 2001 From: Jason Vanderhoof Date: Thu, 11 Aug 2022 12:45:22 -0600 Subject: [PATCH 1/2] add logging if send message fails --- app/domain/authentication/authn_k8s/web_socket_client.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/domain/authentication/authn_k8s/web_socket_client.rb b/app/domain/authentication/authn_k8s/web_socket_client.rb index 8ccd1e413b..7617f9a3d9 100644 --- a/app/domain/authentication/authn_k8s/web_socket_client.rb +++ b/app/domain/authentication/authn_k8s/web_socket_client.rb @@ -48,7 +48,7 @@ def connect(url, options = {}) when Resolv::IPv4::Regex, Resolv::IPv6::Regex # don't set SNI, as IP addresses in SNI is not valid # per RFC 6066, section 3. - + # Avoid openssl warning ctx.verify_hostname = false else @@ -113,6 +113,8 @@ def send(data, opt = { type: :text }) begin @socket.write(frame.to_s) rescue Errno::EPIPE => e + Rails.logger.error("Websocket failed to send: '#{data}'") + Rails.logger.error("error: #{e}") @pipe_broken = true emit(:__close, e) end From 8dc2c2df7d317439defe0bedb4587a109b61f28d Mon Sep 17 00:00:00 2001 From: Jason Vanderhoof Date: Thu, 11 Aug 2022 14:25:20 -0600 Subject: [PATCH 2/2] enable logging on rspec tests --- .../authentication/authn_k8s/web_socket_client.rb | 1 + .../authenticate_controller_authn_k8s_spec.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/domain/authentication/authn_k8s/web_socket_client.rb b/app/domain/authentication/authn_k8s/web_socket_client.rb index 7617f9a3d9..2ed6a55835 100644 --- a/app/domain/authentication/authn_k8s/web_socket_client.rb +++ b/app/domain/authentication/authn_k8s/web_socket_client.rb @@ -106,6 +106,7 @@ def connect(url, options = {}) end def send(data, opt = { type: :text }) + puts("Websocket Send: attempting to send: #{data.inspect}") return if !@handshaked || @closed type = opt[:type] diff --git a/spec/controllers/authenticate_controller_authn_k8s_spec.rb b/spec/controllers/authenticate_controller_authn_k8s_spec.rb index b2f73f5102..7fadc66a31 100644 --- a/spec/controllers/authenticate_controller_authn_k8s_spec.rb +++ b/spec/controllers/authenticate_controller_authn_k8s_spec.rb @@ -5,13 +5,13 @@ # Turn on logs to debug # -# Rails.logger.extend(ActiveSupport::Logger.broadcast(ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)))) -# Rails.logger.level = :info -# Audit.logger = Audit::Log::SyslogAdapter.new( -# Logger.new(STDOUT).tap do |logger| -# logger.formatter = Logger::Formatter::RFC5424Formatter -# end -# ) +Rails.logger.extend(ActiveSupport::Logger.broadcast(ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)))) +Rails.logger.level = :info +Audit.logger = Audit::Log::SyslogAdapter.new( + Logger.new(STDOUT).tap do |logger| + logger.formatter = Logger::Formatter::RFC5424Formatter + end +) def set_variable_value(account, resource_id, value) post("/secrets/#{account}/variable/#{resource_id}", env: admin_request_env.merge({ 'RAW_POST_DATA' => value }))