-
Notifications
You must be signed in to change notification settings - Fork 210
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
Impossible to upload cookbooks if non-standard port is used #50
Comments
@oleg-z Thanks for reporting this. I've confirmed the behavior you are seeing and your root cause is spot on. Below is a slightly more verbose description of what is happening for someone not as familiar with how opscode-omnibus is all tied together. With the following placed in private-chef.rb:
nginx will listen on port 4000 for HTTPS connections and not the default port of 443. During cookbook uploads, the opscode-erchef service talks to bookshelf via the s3_url in its configuration file (/var/opt/opscode/opscode-erchef/etc/app.config). This configuration file is rendered via a template(opscode-omnibus/files/private-chef-cookbooks/private-chef/templates/default/oc_erchef.config.erb), a portion of which looks like:
Thus, the rendered configuration file will have an s3_url like:
Given this configuration, erchef will attempt to contact erchef on port 443, the default HTTPS port. Unfortunately, nothing is listening on 443, the request to bookshelf fails and erchef returns a 500 to the user. An astute user may attempt to set
Unfortunately, this does not work either, since our IPv6 handling code will mangle this into:
which also fails. If you manually edit /var/opt/opscode/opscode-erchef/etc/app.config to make the s3_url line as follows:
and restart opscode-erchef, cookbook uploads will be successful. The code that interprets anything with an ":" as an IPv6 address can be found in opscode-omnibus/files/private-chef-cookbooks/private-chef/libraries/helper.rb:
|
The problem with this solution, as I am sure you already know, is that running chef-server-ctl reconfigure will wipe out the custom modification. Are there any plans to fix this. It seems to me that in reality Chef Server does not really support any other port than 443 in reality |
I met this and it really hurts. This is a bug, right? |
I also hope this gets fixed soon. In the meantime you can also manually edit the template that creates the erchef config file so the modification will survive a Look around line 163 of the file For example, if you want to set then replace the following line:
with this:
Then run |
This is not only a problem with uploading cookbooks. I have found the same sort of issue with trying to get the Chef 12 reporting working for a Chef server on a non-standard port. For reporting, had to resort to manually editing pedant_config.rb.erb and oc_reporting.config.erb under /opt/opscode-reporting/embedded/cookbooks/opscode-reporting/templates/default/ and added
so that the reconfiguration generates the port in the config files. After a reconfigure and restart, reporting seems to be working. Before this, the chef-client would take a while to run on the remote node because it would be getting "500 Internal server errors" and retrying to connect to the reporting server several times before failing. |
Note for people who would stumble on this : this bug also hits when you make nginx listen on a particular IP bookshelf["vip"] = "a.b.c.d" will allow to change the IP that erchef will use to contact bookshelf |
Same problem here, I have to revert back non_ssl_port to 80 to upload cookbooks. |
I also met this problem in open source chef server 12.1.2. In my /etc/opscode/chef-server.rb : After add the ssl port number into s3_url in /var/opt/opscode/opscode-erchef/sys.config and run 'sudo chef-server-ctl restart', the cookbooks are uploaded:
|
+1 faced same issue. |
+1 , bumping as appears to be same issue we are hitting. chef-server-core-12.1.2-1.el5.x86_64.rpm |
Can corroborate here with chef-server-core-12.2.0-1.el6.x86_64. |
Still happening with chef-server-core-12.3.0-1.el6 |
This tests out locally via both manual cookbook upload tests and pedant run: #637 |
Still seeing this with Chef server 12.4.1. As workaround after reading the above comments, changed line 220 in /opt/opscode/embedded/cookbooks/private-chef/templates/default/oc_erchef.config.erb from {s3_url, "<%= node['private_chef']['nginx']['x_forwarded_proto'] %>://<%= @helper.vip_for_uri('bookshelf') %>"}, to {s3_url, "<%= node['private_chef']['nginx']['x_forwarded_proto'] %>://<%= @helper.vip_for_uri('bookshelf') %>:<%= node['private_chef']['nginx']['ssl_port'] %>"}, Additionally, to configure reporting properly, I changed line 36 in chef_server "https://<%= node['private_chef']['lb']['api_fqdn'] %>" to chef_server "https://<%= node['private_chef']['lb']['api_fqdn'] %>:<%= node['private_chef']['nginx']['ssl_port'] %>" and line 91 in {chef_service, [{root_url, "https://<%= node['private_chef']['lb']['vip'] %>"}, to {chef_service, [{root_url, "https://<%= node['private_chef']['lb']['vip'] %>:<%= node['private_chef']['nginx']['ssl_port'] %>"}, |
Just a note for others that might end up here, I had this problem but the fixes weren't fixing the issue completely. If you end up there, make sure your chef-server can resolve its own FQDN as well, that was the extra roadblock in my case. |
I believe #833 has resolved this oleg-z, would you be able to confirm? |
Is this pull request in chef-server-core 12.7.0? The problem still exists in that version. I do notice the changes in oc_erchef.config.erb I suspect the problem now is that the attribute default['private_chef']['bookshelf']['vip_port'] defaults to 443 and as far as I can tell is never set to match the custom nginx port. |
This is absolutely correct. The attribute default['private_chef']['bookshelf']['vip_port'] defaults to 443. nginx['ssl_port'] = 4000 Everything runs fine and cookbooks can be uploaded. |
Not able to login if set custom nginx ssl port number When i login in chef UI i get this error 500Smell something burning?Sorry we have a small fire in the kitchen.An unexpected error has occurred. Our staff are manning the fire extinguishers and have been alerted. |
Just wasted hours on this. Can someone please add the port into the |
Chef uploads cookbooks transactionally by generating a unique sandbox URL to upload all the associated files to using a "POST /organizations/<organization>/sandboxes" operation. This POST operation returns the URL of the sandbox that should then be used to PUT the cookbook's files to. This URL is pre-resolved, based on the configuration of the chef server, which can be different from what is configured in the client. In special cases of network configuration, this discrepancy forces the client to use a URL with a non-resolvable or unreachable host for uploading cookbooks, rather than the scheme/host/port configured with chef_server_url. This change parses the sandbox URL returned by the server, and rewrites it honor the chef_server_url configuration. Semi-Related to: chef/chef-server#50 Signed-off-by: Scott Bowers <[email protected]>
I hope this helps with the original issue and others coming here. After trying everything mentioned here without success (while playing with chef-server installed in a VirtualBox), I was able to fix the issue with this
erchef is the REST API server that knife sends to. When uploading a cookbook it sends erchef a command to create a sandbox, and erchef responds with uri's to call next. By default, these uri's get the host name from the request (not sure why it isn't aware of the custom port), but if More configuration options can be found here: https://docs.chef.io/config_rb_server_optional_settings.html#opscode-erchef I found the solution by adding the very verbose
and then searching for the code that's responsible for the sanboxes route in knife and chef-server: Knife cookbook uploader: Response with uri's:
Building the uri:
render_template function:
base_uri function which uses
|
Upload and login work for me: CHEF_VERSION="15.3.14" /etc/opscode/chef-server.rb nginx['non_ssl_port'] = 8080
nginx['ssl_port'] = 8443
nginx['url'] = 'https://chef-server-01.vb.local:8443/'
nginx['server_name'] = 'chef-server-01.vb.local'
bookshelf['vip_port'] = 8443
bookshelf['external_url'] = 'https://chef-server-01.vb.local:8443'
opscode_erchef['base_resource_url'] = 'https://chef-server-01.vb.local:8443' then chef-server-ctl reconfigure
chef-manage-ctl reconfigure |
In my case, it was related to fips compliance.
To make it work, added Ref - https://docs.chef.io/config_rb_server_optional_settings.html |
My chef-server.rb:
After running chef-server-ctl reconfigure I can't upload cookbook:
Reason:
incorrect erchef template which assumes that default protocol port is used. Attempt to specify vip parameter with port (e.g. 1.1.1.1:4000) causes issue because normalize_host method parses specified string as IPv6
The text was updated successfully, but these errors were encountered: