Bug #15461
closedSmart-Proxy is unable to retrieve puppet environments due to timeout
Description
The foreman smart-proxy is unable to retrieve environments from a puppetmaster that takes a significant amount of time returning results. From my setup, a successful curl request to https://puppetmaster:8140/puppet/v3/resource_types/*?kind=class&&environment=production takes just over 3 minutes.
When a environment request is made to the smart-proxy via the api (https://puppetserver:8443/puppet/environments/production/classes), the result is:
HTTP/1.1 406 Not Acceptable
Content-Type: application/json;charset=utf-8
Content-Length: 47
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-11-13) OpenSSL/1.0.1e
Date: Mon, 20 Jun 2016 04:19:29 GMT
Connection: Keep-Alive
Failed to show puppet classes: Net::ReadTimeout
This could be because the request to the v3/resource_types via curl returns as:
HTTP/1.1 200 OK
Content-Type: text/pson; charset=ISO-8859-1
X-Puppet-Version: 4.5.1
Transfer-Encoding: chunked
Server: Jetty(9.2.z-SNAPSHOT)
[{"line":1,"file":"/etc.................
Updated by Anonymous over 8 years ago
How many classes do you have in the environment? Does this happen to the first call only, or for subsequent calls too?
Updated by Gino Lisignoli over 8 years ago
Dmitri Dolguikh wrote:
How many classes do you have in the environment? Does this happen to the first call only, or for subsequent calls too?
Unsure on classes, I'll check tomorrow. This happens on all call attempts. I'm pretty sure environment caching is enabled (although I'm unsure how to check).
Updated by Anonymous over 8 years ago
- Related to Feature #15095: Add Puppet server environment_classes API support added
Updated by Gino Lisignoli over 8 years ago
Dmitri Dolguikh wrote:
How many classes do you have in the environment?
- find ./production -type f -iname '*.pp' | wc -l
240
So at most 240, maybe closer to 200 as there could be defined types etc. There are about 60 modules per environment. 4 Environments at the moment.
Discovered that my environment cache was NOT enabled. Enabling it, doing a pre-import curl request to generate the cache and then doing a foreman import will display the class import screen and then import fine.
However:
Even with the environment cache enabled the foreman must attempt to import the environments (and in my case fail) several times (at least once for each environment the that foreman-proxy is unable to import in time).
Updated by Dominic Cleal over 8 years ago
- Status changed from New to Feedback
#15095 (available shortly in nightly) introduces support for using cached results from Puppet Server when using Puppet 4.4 and Puppet Server 2.3 or higher, and caching is enabled.
The caching feature needs enabling in Puppet Server first (see https://docs.puppet.com/puppetserver/2.3/puppet-api/v3/environment_classes.html#headers-and-caching-behavior). Note that enabling caching means the cache needs to be invalidated, see the same docs for info on the API, or restart (HUP) Puppet Server.