-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http[s] proxy support #204
Conversation
@iancward Here's the PR for the http proxy work. It will take some time as I have to make this work for the installation scripts and download features. Super rough now, but it'll get there. |
9fe0f80
to
6fac3d0
Compare
Net::HTTP.new(uri.host, nil, proxy_uri.host, proxy_uri.port, use_ssl: use_ssl).start do |http| | ||
response = http.request(request) | ||
end | ||
rescue SocketError => e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may need to add ConnectionError to this as well...
f6b471d
to
3b33a1b
Compare
029982e
to
0fad8c2
Compare
@smurawski @mwrock - I added you to get your 👀 on the powershell proxy changes. |
@chef/engineering-services |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small suggestion but looks good!
lib/mixlib/install.rb
Outdated
@@ -64,11 +64,13 @@ def available_versions | |||
# | |||
# @return [Array<String>] list of available versions for the given | |||
# product_name and channel. | |||
def self.available_versions(product_name, channel) | |||
def self.available_versions(product_name, channel, https_proxy = nil, http_proxy = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it makes sense to make the 3rd parameter an opts hash? This would allow easy adding of more options in the future:
#
# List available versions
#
# @param [String] product name
#
# @param [String, Symbol] channel
#
# @param [Hash] opts
# @option opts [String] :https_proxy
# @option opts [String] :http_proxy
#
# @return [Array<String>] list of available versions for the given
# product_name and channel.
def self.available_versions(product_name, channel, opts = {})
Backend.available_versions(
Mixlib::Install::Options.new(
product_name: product_name,
channel: channel.to_sym,
https_proxy: opts[:https_proxy],
http_proxy: opts[:http_proxy]
)
)
end
Signed-off-by: Patrick Wright <patrick@chef.io>
@iancward Any chance that you could try out this brach and see if the http proxy options behave as you would expect? |
@wrightp wow, I didn't realize how extensive a change like this would be. The first thing I noticed is that it appears that if you don't specify a URI scheme with the http_proxy (or https_proxy), it defaults to https. I had actually put I was able to get the list versions feature to work both via pry/irb and the CLI (which I wish was documented a bit better in the README); however, when I attempted to use the CLI to download the artifact, it failed. It was able to identify what to download (it fetched the latest version just fine), but it looks like the actual download method just uses I was able to use I have a windows machine accessible to me; however, trying to test this there is proving challenging. (yay for trying to use ruby, bundler, chef, and git on windows). I'll keep working at it and try to give you a response by early next week. |
@iancward Thank you for the response! Incredibly valuable! I'll try to structure my response as best as I can. URI scheme requirement:The way the code is currently written the URI scheme ( CLI download commandI totally missed that part! This bit of code is removed from the rest of the application (and in fact the only place we download anything.) I will fix that as well. My tests missed it because my test proxy server catches the metadata query, but has free access to the internet to download :/ CLI docsWe were hoping the help command would be sufficient, but in reality the tool has grown much in complexity since inception. We could certainly add docs for it's capabilities. http vs https proxy combinationsI mimicked much of how the chef client uses proxies. Which may not be the same functionality we really need. There could be an inherent design issue more than a bug itself. See the section below for how I think I need to fix this moving forward. My thoughts on splitting proxy setting responsibilitiesI think something that I may just have to give up on is trying to get the proxy options for the API to also magically work for the scripts. Round peg, square hole kind of thing. I'm thinking moving forward the proxy options will have to be set differently for API vs install script generation. The http_proxy: "pserver:80" # API
install_command_options: { http_proxy: "pserver:80" } # Install script param/var I'm worried that this will feel like double-setting a value when in fact they are quite different. Perhaps good documentation would solve the issue. |
Is When I used the |
I upgraded chefdk to 1.0.3 on a windows machine to get the required version of ruby for chefstyle (I was hoping to have Mixlib::Install update it for me), and I was able to run However, when I tried to use I found a few issues for test kitchen regarding similar errors; however, I'm running the mixlib-install bits directly on the server. The I'm also unable to run the |
Ah I see. There are existing I suppose there may also be a scenario where someone would want to use both a web proxy and override the download URL (probably unlikely, since the overridden download URL is probably used where packages.chef.io is unreachable; however, a possibility nonetheless). |
This PR is not the correct solution. It seemed straight forward at first, but has become convoluted Before trying to work this further I'm going create a design doc with requirements and go from there. |
@wrightp thanks for the update. Please let me know if there's any assistance I can provide in terms of requirements, etc. |
tl;dr add http and https proxy support to mixlib install api.
See Readme updates for how the options interact with different aspects of the application.
Proxy unit and functional tests run against a mock http proxy server.
The windows powershell changes were tested manually using Fiddler.
This change only includes http and https proxy settings. It does not include the full proxy gambit of passing credentials or ftp proxies. This can always be added later.
To add automated acceptance tests a proxy server will need to be provisioned for each proxy test (windows and linux). Let's get this out in the field and think about the best approach for proxy acceptance tests.
Signed-off-by: Patrick Wright patrick@chef.io