Internal error when upload cookbook

Hello,
I followed tutorial to install chef server and upload cookbooks, but I used my own server (on Amazon EC2).
When I try knife cookbook upload learn_chef_apache2, I have this message :
Uploading learn_chef_apache2 [0.2.1]
ERROR: Server returned error 500 for https://<IP_ADDRESS>/organizations/adreactive/sandboxes/dd147b0a2ba9b4a5edf47ffcc447737b, retrying 1/5 in 4s

With verbose mode :
DEBUG: ---- HTTP Request Header Data: ----
DEBUG: Content-Type: application/json
DEBUG: Accept: application/json
DEBUG: Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
DEBUG: X-OPS-SIGN: algorithm=sha1;version=1.0;
DEBUG: X-OPS-USERID: amoussard
DEBUG: X-OPS-TIMESTAMP: 2015-12-10T19:35:36Z
DEBUG: X-OPS-CONTENT-HASH: oMRtV6loUDnbKJuGcW6nqBbF8ww=
DEBUG: X-OPS-AUTHORIZATION-1: V69wv8C5A46c9Hak9wF7G5E8LzEc0ouvuVbTQ8UH2KsKcQqVdYV5WG4bXC8G
DEBUG: X-OPS-AUTHORIZATION-2: hl66ZwD18JziTji+gnmpgzADkMiU696QdnF6XlEjTe3FllTZtArNsd1IqAb8
DEBUG: X-OPS-AUTHORIZATION-3: 2UcmGhL0ElWZH3A3rPyU67NfmCACFUfAEiWWPq5QHHZ80pbiktJYgUS40/w9
DEBUG: X-OPS-AUTHORIZATION-4: SMSybzM/mDjtS4VP3Pv3ZRqlxB9iLbr6stQ0twHCU2lW67aEYpo9XCp7rEP2
DEBUG: X-OPS-AUTHORIZATION-5: yHnYl9zRcZRgqH5giNUsvlEFvnEhoEjhaWyVqGB+s6JDDb6JZOfhct+I7lOA
DEBUG: X-OPS-AUTHORIZATION-6: Ispxdn/2+U41SSFRYJRoldqfLKgdRU4mgf2xQzfZhw==
DEBUG: HOST: <IP_ADDRESS>:443
DEBUG: X-Ops-Server-API-Version: 1
DEBUG: X-REMOTE-REQUEST-ID: 256de2e3-f990-48d8-80c7-7466260bb505
DEBUG: Content-Length: 21
DEBUG: ---- End HTTP Request Header Data ----
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 500 Internal Server Error
DEBUG: server: openresty/<IP_ADDRESS>
DEBUG: date: Thu, 10 Dec 2015 19:35:42 GMT
DEBUG: content-type: application/json
DEBUG: content-length: 36
DEBUG: connection: close
DEBUG: x-ops-server-api-version: {"min_version":"0","max_version":"1","request_version":"1","response_version":"1"}
DEBUG: x-ops-api-info: flavor=cs;version=12.0.0;oc_erchef=12.3.1
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: ---- HTTP Response Body ----
DEBUG: {"error":["internal service error"]}
DEBUG: ---- End HTTP Response Body -----
DEBUG: ---- HTTP Request Body ----
DEBUG: {"is_completed":true}
DEBUG: ---- End HTTP Request Body ----
ERROR: Server returned error 500 for https://<IP_ADDRESS>/organizations/adreactive/sandboxes/dd147b0a2ba9e907df5ded253271e361, retrying 1/5 in 4s

On the server, I haven't seen anormal things, only in /var/log/opscode/opscode-erchef/current :
2015-12-10_19:35:42.09233
2015-12-10_19:35:42.09427 [error] Checking presence of checksum: <<"03485640b005eb1083c76518764053dd">> for org <<"6b11ba36a1a51f7e4110dd147b0a2ba9">> from bucket "bookshelf" has taken longer than 5000 ms
2015-12-10_19:35:42.09428
2015-12-10_19:35:42.09642 [error] Checking presence of checksum: <<"1324837367c70bc449de8598f69cd132">> for org <<"6b11ba36a1a51f7e4110dd147b0a2ba9">> from bucket "bookshelf" has taken longer than 5000 ms
2015-12-10_19:35:42.09643
2015-12-10_19:35:42.09847 [error] Checking presence of checksum: <<"b73f1cbab0b53887d9e293ee6986ae8f">> for org <<"6b11ba36a1a51f7e4110dd147b0a2ba9">> from bucket "bookshelf" has taken longer than 5000 ms
2015-12-10_19:35:42.09848
2015-12-10_19:35:42.10047 [error] Checking presence of checksum: <<"0338b44cfb1aab65622a99100d576821">> for org <<"6b11ba36a1a51f7e4110dd147b0a2ba9">> from bucket "bookshelf" has taken longer than 5000 ms
2015-12-10_19:35:42.10048
2015-12-10_19:35:42.10255 [error] {<<"method=PUT; path=/organizations/adreactive/sandboxes/dd147b0a2ba9e907df5ded253271e361; status=500; ">>,{error,{throw,{checksum_check_error,8},[{chef_wm_named_sandbox,validate_checksums_uploaded,2,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/oc_chef_wm/src/chef_wm_named_sandbox.erl"},{line,144}]},{chef_wm_named_sandbox,from_json,2,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/oc_chef_wm/src/chef_wm_named_sandbox.erl"},{line,97}]},{webmachine_resource,resource_call,3,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/webmachine/src/webmachine_resource.erl"},{line,184}]},{webmachine_resource,do,3,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/webmachine/src/webmachine_resource.erl"},{line,140}]},{webmachine_decision_core,resource_call,1,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/webmachine/src/webmachine_decision_core.erl"},{line,48}]},{webmachine_decision_core,accept_helper,1,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/webmachine/src/webmachine_decision_core.erl"},{line,616}]},{webmachine_decision_core,decision,1,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/webmachine/src/webmachine_decision_core.erl"},{line,521}]},{webmachine_decision_core,handle_request,2,[{file,"/var/cache/omnibus/src/oc_erchef/_build/default/lib/webmachine/src/webmachine_decision_core.erl"},{line,33}]}]}}}

Chef Server Version : 12.5.1
Knife Version : 12.5.1
Any idea why I have those errors ?
Thank you !

The most likely problem is that your FQDN isn't resolvable.  Erchef talks to bookshelf (the cookbook storage service) over the configured api_fqdn.  If that isn't resolvable via DNS, erchef will timeout trying to do the resolution.

Thank you for you quick answer.
I have opened all the port to anywhere and it works.
However, where I can find this environment variable ?

However, where I can find this environment variable ?

Apologies, I'm not following what your question is here?  Happy to help if you don't mind expanding your question a bit.

I got same errors.
Chef Server Version : 12.5.1
Knife Version : 12.5.1
/etc/hosts
192.168.x.x     chef.server.local    chef
/root/chef-repo/.chef/knife.rb
/root/chef-repo/cookbooks
When I try "knife cookbook upload mysql yum-mysql-community -VV", I've got same error patterns.
DEBUG: ---- HTTP Request Body ----
DEBUG: {"is_completed":true}
DEBUG: ---- End HTTP Request Body ----
ERROR: Server returned error 500 for https://chef.server.local:11218/organizations/admin/sandboxes/3d7e16c33d53984f6cedc99bd428ed23, retrying 3/5 in 9s
DEBUG: Initiating PUT to https://chef.server.local:11218/organizations/admin/sandboxes/3d7e16c33d53984f6cedc99bd428ed23
and here's my knife.rb env.
log_level                :debug
log_location             STDOUT
node_name                'admin'
client_key               '/root/chef-repo/.chef/admin.pem'
validation_client_name   'admin-validator'
validation_key           '/root/chef-repo/.chef/admin-validator.pem'
chef_server_url          'https://chef.server.local:11218/organizations/admin'
syntax_check_cache_path  '/root/chef-repo/.chef/syntax_check_cache'
cookbook_path [ '/root/chef-repo/cookbooks' ]
cache_type               'BasicFile'
/etc/opscode/chef.server.rb
lb['api_fqdn'] = "chef.server.local"
nginx['enable_non_ssl'] = true
nginx['non_ssl_port'] = 4000
nginx['ssl_port'] = 11218

knife ssl check
Connecting to host chef.server.local:11218
Successfully verified certificates from `chef.server.local'

I can't fix this errors..

I had a similar issue to this and found that it was a bad /etc/hosts entry on the Chef server, so it wasn't able to communicate with bookshelf.

@stormerider
I had the same error and modifying my /etc/hosts on my chef-server resolved the issue as well!

hello i have the same issue on my Chef workstation, all settings seems to be ok..,i do not have a DNS Server on my Lab i just edit /etc/hosts,and entries looks fins..,but wheni try to upload my cookbook from my workstation  i have this error : Server resturned error 500 for HTTPS://MYCHEFSERVER .

I'm having this issue quite regularly, usually 2nd attempt is successful.
api_fqdn = 'chef.shared.internal'
in /etc/hosts I have
<IP_ADDRESS> localhost chef.shared.internal
So it is very unlikely FQDN resolution issue.
I suspect this is due to
bookshelf['storage_type'] = :sql
and external SQL DB (RDS instance) is too slow. Is there a possibility to increase this standard timeout of 5000ms?

@voroniys Same issue here with RDS Aurora backend.
Trying to figure it out.


Memory leak (loop was never GCed)

Compiled luv.so with CLANG's address sanitizer, and run the unit tests, and found lots of leaks.
Troubleshooted a bit and found that the luv.c:loop_gc() was never triggered.
The issue seems started from revision db55f6bd.
lua_pushstring(L, "_loop");
loop = (uv_loop_t*)lua_newuserdata(L, sizeof(*loop));
lua_rawset(L, -3);  // ref to loop, avoid __gc early

If remove the pushstring and rawset, loop_gc would be invoked too early, just as the comment says. However, with that, it was never called.

Found the problem: uv_loop.meta is being set on the table returned from require (i.e. getmetatable(require('luv')).__gc), not the loop userdata. Will create a PR with the fix in a second.
Thanks for finding a reporting this @vanc ! If feasible, we should definitely try to include checks like this into our CI.