Alejandro Falcon wrote:
Every time I try to import the classes the smart-proxy scans all modules and wont use the cache. I have troubleshoot it and found:
-Cache option is enabled by default
-Cache files are created under /usr/foreman-proxy/cache and the content looks right.
-Cache files are loaded fine by the proxy but this condition fails to match for some reason:
[...]
I also noticed this problem and tried to debug it a little, but I know very little ruby so I didn't get far. I assume that this worked for the person who originally added this feature, so I think it might be a problem with older versions of ruby. Our puppet master is running on an old RHEL6 server with ruby v1.8.7. Just like what Alejandro found, one problem is the cache timestamp comparison fails, but if I change that line to this:
if lcache[puppetmodule].has_key?(:timestamp) && Time.parse(lcache[puppetmodule][:timestamp]) >= mtime
then this part works. But then the caching still does not work properly because of symbolized names, so I had to change the JSON.parse on line 61 to:
JSON.parse(File.read(cachefile), {:symbolize_names => true})
Then I got to the problem that the json data in the cache file seems to be missing a lot of information, for example, it only contains the module path & name, timestamp, and list of classes in the module, but all of the parameters and their default values are missing. This information is not written to the cache file, possibly due to the same symbolize_names problem in the data serialization.
Since I am not a ruby expert, this is as far as I was able to get, hopefully someone who knows ruby better can figure this out and get the caching to work. Operating a puppet server with dozens of environments, where each can take 30+ seconds to parse, is very difficult with Foreman that does not have a working cache.