Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Added support for chef-provisioning 1.0 #47

Merged
merged 4 commits into from Jun 8, 2015

Conversation

marc- added 3 commits May 29, 2015 13:32
Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
Addresses
- chef-boneyard#37
- chef-boneyard#24

Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
# FIXME: make a proper fix
if /^chefzero:\/\/localhost/ =~ url
url.gsub!(/^chefzero/, 'http')
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

uri = URI(url)
uri.scheme = 'http'

instead?

ex:

irb(main):001:0> require 'URI'
=> true
irb(main):002:0> require 'socket'
=> true
irb(main):003:0> url = 'chefzero://localhost'
=> "chefzero://localhost"
irb(main):004:0> uri = URI(url)
=> #<URI::Generic chefzero://localhost>
irb(main):005:0> uri.scheme = 'http' unless %w(http https).include?(uri.scheme)
=> "http"
irb(main):006:0> host = Socket.getaddrinfo(uri.host, uri.scheme, nil, :STREAM)[0][3]
=> "::1"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be remote chef-server with https also. Though, I think fix must be made somewhere else, probably on chef-provisioning side. That's why I consider code above as temporal workaround.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I've updated my example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense now. Thank you for reviewing that.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's even better to limit the explicit setting to chefzero:

uri.scheme = 'http' if uri.scheme == 'chefzero' 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: Maksim Chizhov <maksim.chizhov@gmail.com>
@randomcamel
Copy link
Contributor

I used this as an opportunity to write #51, and while the latter doesn't cover everything here, I feel pretty good about it.

👍

@@ -179,11 +179,12 @@ def upload_file(local_path, path)
def make_url_available_to_remote(url)
# The host is already open to the container. Just find out its address and return it!
uri = URI(url)
uri.scheme = 'http' if 'chefzero' == uri.scheme && uri.host == 'localhost'
host = Socket.getaddrinfo(uri.host, uri.scheme, nil, :STREAM)[0][3]
Chef::Log.debug("Making URL available: #{host}")

if host == '127.0.0.1' || host == '::1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about host == 'localhost'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was so for a long time and no bugs were filed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tyler-ball
Copy link
Contributor

This looks good to me (other than a few minor comments). Because I'm so unfamiliar with Docker I am interested in adding good testing to make sure this works. But that won't be a blocker to getting this merged!

@@ -179,11 +179,12 @@ def upload_file(local_path, path)
def make_url_available_to_remote(url)
# The host is already open to the container. Just find out its address and return it!
uri = URI(url)
uri.scheme = 'http' if 'chefzero' == uri.scheme && uri.host == 'localhost'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is now fixed in chef-provisioning 1.2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't work for me with chef-provisioning 1.2 and this line removed. url always comes as chefzero://localhost:8889 if chef zero used as provisioner. Just in case gem list:

chef (12.3.0)
chef-provisioning (1.2.0)
chef-zero (4.2.1)
cheffish (1.2)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we're pretty sure this is necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwrock the fix we added in chef-boneyard/chef-provisioning#337 that was released in chef-provisioning 1.2 applies to the target (guest, VM, etc.) node. It means that chef-client running on that node will be able to talk to the chef-zero server running on the workstation.

This change is different but related. It makes sure the chef-zero server running on the workstation has its port forwarded to the container.

Having said this, if the user wants to run chef-client version 12.3.x or greater on their container they will need to use chef-provisioning ~> 1.2, or use some of the workarounds detailed in chef-boneyard/chef-provisioning#337.

Actually, I would love to see some documentation about this somewhere. I've heard multiple people having issues with the changes introduced in chef-client 12.3. We should at least update https://docs.chef.io/release_notes.html to detail what changed from 12.2 to 12.3 when running chef-client -z.

@randomcamel
Copy link
Contributor

Absent any unanswered concerns, I'll merge this in about an hour.

randomcamel added a commit that referenced this pull request Jun 8, 2015
Added support for chef-provisioning 1.0
@randomcamel randomcamel merged commit 8d30040 into chef-boneyard:master Jun 8, 2015
@tyler-ball
Copy link
Contributor

@randomcamel will you close the 4 related issues listed at the top of this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

7 participants