Skip to content
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

Berkshelf complains about HTTP -> HTTPS redirection #358

Open
westbywest opened this issue Jul 8, 2014 · 1 comment
Open

Berkshelf complains about HTTP -> HTTPS redirection #358

westbywest opened this issue Jul 8, 2014 · 1 comment

Comments

@westbywest
Copy link

Trying to to download a cookbook from Opscode Community using the berkshelf v1.4.2 gem bundled into ironfan-homebase is now failing on HTTP -> HTTPS direction, e.g.

/Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/open-uri.rb:216:in `open_loop': redirection forbidden: http://cookbooks.opscode.com/api/v1/cookbooks/monit/versions/0.7.1/download -> https://s3.amazonaws.com/community-files.opscode.com/cookbook_versions/tarballs/3587/original/monit.tgz?1367378386 (RuntimeError)
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/open-uri.rb:146:in `open_uri'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/open-uri.rb:678:in `open'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/open-uri.rb:33:in `open'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/community_rest.rb:166:in `block in stream'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/retryable-1.3.5/lib/retryable.rb:17:in `retryable'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/community_rest.rb:165:in `stream'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/community_rest.rb:92:in `download'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/locations/site_location.rb:43:in `download'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/downloader.rb:110:in `block in search_locations'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/downloader.rb:103:in `each'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/downloader.rb:103:in `search_locations'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/downloader.rb:79:in `download'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/resolver.rb:133:in `install_source'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/resolver.rb:53:in `add_source'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/resolver.rb:26:in `block in initialize'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/resolver.rb:25:in `each'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/resolver.rb:25:in `initialize'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/berksfile.rb:368:in `new'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/berksfile.rb:368:in `install'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/cli.rb:160:in `install'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/lib/berkshelf/cli.rb:17:in `dispatch'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/berkshelf-1.4.2/bin/berks:6:in `<top (required)>'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/bin/berks:23:in `load'
    from /Users/mememe/.rbenv/versions/1.9.3-p545/bin/berks:23:in `<main>'

This may have been triggered by the recent launch of supermarket.getchef.com, which is apparently replacing community.opscode.com.

Berkshelf v2 already has a couple PRs filed in response:
berkshelf/berkshelf#1251
berkshelf/berkshelf#1250

What is the hurdle in getting ironfan to work with Berkshelf v2+?

@westbywest
Copy link
Author

To follow up with this, I've had success bumping my local copy of ironfan v6.1.6 up to chef v11 and berkshelf v2.0.18, working around the HTTP -> HTTPS redirection failure. Or more specifically, bumping ironfan up to chef v11 and ironfan-homebase up to berkshelf v2.

The relevant change to my forked copy of the ironfan gem to bump up to chef v11:
https://github.com/splicemachine/ironfan/commit/6442434c3a731acc593907abf60a943a697f9153

Next, the newer berkshelf complains on all instances of "Chef::Config..." or "Chef::Log..." in knife/knife.rb, knife/credentials/knife-org.rb, and knife/credentials/knife-user.rb in your ironfan homebase. A workaround is to wrap those lines in an if clause and scope them explicitly.

That is, replace instances of this:

Chef::Config...

... with this:

if (defined?(::Chef))
  ::Chef::Config...
end

Similar for all instances of "Chef::Log..."

Likewise, change the "load(file)" line in knife/knife.rb with "Kernel.load(file)":

-def load_if_exists(file) ; load(file) if File.exists?(file) ; end
+def load_if_exists(file) ; Kernel.load(file) if File.exists?(file) ; end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant