sequencescape icon indicating copy to clipboard operation
sequencescape copied to clipboard

Housekeeping - Remove custom proxy code (C=S, V=2*)

Open JamesGlover opened this issue 3 years ago • 1 comments

🗒️ Some quick and experimental work already done. Needs validation, but may be sufficeint.

Describe the Housekeeping In Sequencescape we have a number of places where we handle proxy servers for we requests. In particular:

  1. In several locations we do something approximating the following:
# rubocop:todo Rails/EnvironmentVariableAccess
    rc = RestClient::Resource.new(URI.parse(url).to_s)
    if configatron.disable_web_proxy == true
      RestClient.proxy = nil
    elsif configatron.fetch(:proxy).present?
      RestClient.proxy = configatron.proxy
      rc.headers['User-Agent'] = 'Internet Explorer 5.0'
    elsif ENV['http_proxy'].present?
      RestClient.proxy = ENV['http_proxy']
    end

    # rubocop:enable Rails/EnvironmentVariableAccess
  1. We also have a horrific proxy monkey patch: config/initializers/ruby_net_http_proxy_hack.rb

The patch deals with a requirement of the Sanger squid proxy to have a user-agent specified on https headers, rather than just within the encrypted body of the request. The rc.headers['User-Agent'] = 'Internet Explorer 5.0' line exists for a similar reason.

*** I believe we can remove all such code. ***

  1. We don't go via the proxy in production, so fall back to default behaviour
  2. HTTP_PROXY et al are standard environmental variables, and as such we should probably support then. But this support is backed into Ruby anyway, so we shouldn't need to do anything.
  3. Which just leaves the Sanger squid proxy specific work arounds - which I'm not sure are even still needed (The proxy doesn't even seem to be configured on my latest mac). While its possible that they may aid a developer who has HTTP_PROXY set to the Sanger proxies, it doesn't seem worth monkey-patching the standard library, when it is easy to unset HTTP_PROXY and bypass the proxy sever. This is especially true as hardly any requests Sequencescape makes will be cached by the proxy anyway.

Blocking issues Describe any other issues or tickets that may be blocking this change.

Additional context Preliminary experimental branch here: https://github.com/JamesGlover/sequencescape/tree/experiment_proxy_removal Needs validation (and probably a rebase by the time this get prioritised)

JamesGlover avatar May 19 '21 08:05 JamesGlover

Experimental branch: https://github.com/JamesGlover/sequencescape/tree/experiment_proxy_removal Repeated here for visibility.

JamesGlover avatar May 19 '21 08:05 JamesGlover