Bug #10256
closedGET on SmartProxy 'unattended/built' throwing error 500
Description
I'm getting an error response from the SmartProxy when my host is telling the SmartProxy to finish the build sequence.
E, [2015-04-23T15:35:34.941419 #9366] ERROR -- : Failed to retrieve built template for : undefined method `encoding' for nil:NilClass
172.16.17.42 - - [23/Apr/2015 15:35:34] "GET /unattended/built HTTP/1.1" 500 84 0.0023
Updated by Dominic Cleal almost 9 years ago
- Project changed from Foreman to Smart Proxy
- Category changed from Smart Proxy to Templates
- Status changed from New to Need more information
Could you please set :log_level to DEBUG in /etc/foreman-proxy/settings.yml, restart foreman-proxy and try again? It should log a full stack trace in the logs then, which will be useful to track down the issue.
Please also check /var/log/foreman/production.log to see if the request made it to Foreman, and that it completed successfully.
Lastly, which OS/packages are you using?
Updated by Dominic Cleal almost 9 years ago
- Has duplicate Bug #10265: Smart-Proxy Template error for built complete added
Updated by Dominic Cleal almost 9 years ago
Linked ticket shows it under 1.8.0-RC3 on EL7 with no production.log entry.
Updated by Anonymous almost 9 years ago
Might be useful to get log from the foreman side too.
Updated by Jared Baker almost 9 years ago
Platform: CentOS 7.1.1503 (Core)
Foreman-proxy package: foreman-proxy-1.8.0-0.1.RC3.el7.noarch
Set Foreman & Foreman-proxy to debugging. Foreman does not log anything during the wget or curl request for unattended/built but the Foreman-proxy only logs what I've pasted already which is:
E, [2015-04-24T10:55:29.926208 #11222] ERROR -- : Failed to retrieve built template for : undefined method `encoding' for nil:NilClass
172.16.17.42 - - [24/Apr/2015 10:55:29] "GET /unattended/built HTTP/1.1" 500 84 0.0018
Updated by Darcy Hodgson almost 9 years ago
Installed a 1.8 RC3 smart proxy on CentOS 6.6
[root@sp3 foreman-proxy]# curl --insecure -XGET https://sp3.lab.local:8443/unattended/built
Failed to retrieve built template for : private method `gsub' called for nil:NilClass
Output from the processsp3.lab.local - - [24/Apr/2015:12:56:53 EDT] "GET /unattended/built HTTP/1.1" 500 85
- -> /unattended/built
Smart-Proxy logs the sameE, [2015-04-24T13:10:18.678849 #20837] ERROR -- : Failed to retrieve built template for : private method `gsub' called for nil:NilClass
172.16.17.41 - - [24/Apr/2015 13:10:18] "GET /built HTTP/1.1" 500 85 0.0018
No logs on foreman in the production.log file.
Updated by Darcy Hodgson almost 9 years ago
I performed an strace on the smart-proxy process and found this line to be interesting.
stat("/usr/share/foreman-proxy/public/built", 0x7fffcbf87e80) = -1 ENOENT (No such file or directory)
I created this file with nothing in it and get a 200 return afterwards.
172.16.17.219 - - [24/Apr/2015 13:53:04] "GET /built HTTP/1.1" 200 - 0.0158
But that doesn't solve the problem, seems like I'm still missing some piece of communication between the smart-proxy and foreman that would handle creating this template file and reporting back to foreman that the host build is complete.
Updated by Ohad Levy almost 9 years ago
i wonder if it actually reaches foreman, and since foreman does not respond with any body (it only return headers) this fails parsing by sinatra?
is there a way to show if the request went from the proxy to foreman?
Updated by Dominic Cleal almost 9 years ago
- Status changed from Need more information to New
- translation missing: en.field_release changed from 28 to 50
Updated by Shlomi Zadok almost 9 years ago
- Status changed from New to Need more information
I've investigated this a little.
Foreman is expecting for the host's token in order to process the request.
The Proxy is also expecting the token parameter, and upon failing to pass the token in throws the error above.
Can you please try passing the host's token to the proxy and see if it works?
http://<my.proxy.url>:8443/unattended/built?token=<host.token>
to find the host's token:
foreman-rake console (or rails console on dev machine)
(console loads...)
Host.find('<my.host.name>').token
Updated by Darcy Hodgson almost 9 years ago
I have tested this and I works. I didn't know that the smart proxy needs the token.
Here is a link to the relevant information. http://projects.theforeman.org/projects/foreman/wiki/Unattended_installations
Updated by Dominic Cleal almost 9 years ago
- Status changed from Need more information to Feedback
- translation missing: en.field_release deleted (
50)
Jared, please check that you have tokens enabled under Administer > Settings > Provisioning, where token_duration should be a non-zero value. If this still isn't working, please post back and we'll re-open. Thanks for the report.
Updated by Vladimir Stackov over 8 years ago
I've faced same error.
Client side:
# curl -v http://sccm-hq1.***:8000/unattended/PXELinux * About to connect() to sccm-hq1.*** port 8000 (#0) * Trying 10.8.54.140... connected * Connected to sccm-hq1.*** (10.8.54.140) port 8000 (#0) > GET /unattended/PXELinux HTTP/1.1 > User-Agent: curl/7.19.7 (i686-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: sccm-hq1.***:8000 > Accept: */* > < HTTP/1.1 500 Internal Server Error < Content-Type: application/json;charset=utf-8 < Content-Length: 87 < Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-11-13) OpenSSL/1.0.1e < Date: Thu, 17 Sep 2015 13:24:56 GMT < Connection: Keep-Alive < * Connection #0 to host sccm-hq1.*** left intact * Closing connection #0 Failed to retrieve PXELinux template for : undefined method `encoding' for nil:NilClass
Foreman proxy (
/var/log/foreman-proxy/proxy.log):
E, [2015-09-17T16:25:50.973137 #9929] ERROR -- : Failed to retrieve PXELinux template for : undefined method `encoding' for nil:NilClass D, [2015-09-17T16:25:50.973434 #9929] DEBUG -- : /usr/share/ruby/cgi/util.rb:7:in `escape' /usr/share/foreman-proxy/lib/proxy/request.rb:13:in `block in query_string' /usr/share/foreman-proxy/lib/proxy/request.rb:13:in `each' /usr/share/foreman-proxy/lib/proxy/request.rb:13:in `map' /usr/share/foreman-proxy/lib/proxy/request.rb:13:in `query_string' /usr/share/foreman-proxy/lib/proxy/request.rb:18:in `create_get' /usr/share/foreman-proxy/modules/templates/handler.rb:15:in `get_template' /usr/share/foreman-proxy/modules/templates/handler.rb:26:in `get_template' /usr/share/foreman-proxy/modules/templates/templates_api.rb:18:in `block (2 levels) in <class:TemplatesApi>' /usr/share/foreman-proxy/lib/proxy/helpers.rb:14:in `log_halt' /usr/share/foreman-proxy/modules/templates/templates_api.rb:17:in `block in <class:TemplatesApi>' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:1292:in `call' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:1292:in `block in compile!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:860:in `[]' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:860:in `block (3 levels) in route!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:876:in `route_eval' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:860:in `block (2 levels) in route!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:897:in `block in process_route' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:895:in `catch' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:895:in `process_route' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:859:in `block in route!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:858:in `each' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:858:in `route!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:963:in `block in dispatch!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:946:in `block in invoke' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:946:in `catch' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:946:in `invoke' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:960:in `dispatch!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:794:in `block in call!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:946:in `block in invoke' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:946:in `catch' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:946:in `invoke' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:794:in `call!' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:780:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:161:in `call' /usr/share/foreman-proxy/lib/proxy/log.rb:35:in `call' /usr/share/gems/gems/rack-protection-1.3.2/lib/rack/protection/xss_header.rb:27:in `call' /usr/share/gems/gems/rack-protection-1.3.2/lib/rack/protection/path_traversal.rb:16:in `call' /usr/share/gems/gems/rack-protection-1.3.2/lib/rack/protection/json_csrf.rb:17:in `call' /usr/share/gems/gems/rack-protection-1.3.2/lib/rack/protection/base.rb:48:in `call' /usr/share/gems/gems/rack-protection-1.3.2/lib/rack/protection/base.rb:48:in `call' /usr/share/gems/gems/rack-protection-1.3.2/lib/rack/protection/xss_header.rb:27:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/head.rb:11:in `call' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/showexceptions.rb:21:in `call' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:124:in `call' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:1417:in `block in call' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:1499:in `synchronize' /usr/share/gems/gems/sinatra-1.3.5/lib/sinatra/base.rb:1417:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call' /usr/share/gems/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each' /usr/share/gems/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call' /usr/share/gems/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service' /usr/share/ruby/webrick/httpserver.rb:138:in `service' /usr/share/ruby/webrick/httpserver.rb:94:in `run' /usr/share/ruby/webrick/server.rb:295:in `block in start_thread' 10.110.8.42 - - [17/Sep/2015 16:25:50] "GET /unattended/PXELinux HTTP/1.1" 500 87 0.0017
And no log related records on Foreman side.
If I'll add "?token=***" then everything works smoothly but as I'm using external TFTP and DNS/DHCP infrastructure I think there should be a way to pass client from foreman-proxy to foreman instead of using tokens.
Updated by Vladimir Stackov over 8 years ago
Package versions:
ruby193-rubygem-foreman_templates-2.0.0-1.el7.noarch
foreman-proxy-1.9.1-1.el7.noarch
ruby193-rubygem-foreman-tasks-0.7.3-1.fm1_9.el7.noarch
foreman-1.9.1-1.el7.noarch
foreman-selinux-1.9.1-1.el7.noarch
foreman-debug-1.9.1-1.el7.noarch
Updated by Anonymous almost 7 years ago
- Status changed from Feedback to Resolved
should be resolved by now