Bug #10624
closedError importing environments from smart-proxy (([NoMethodError]: undefined method `map' for true:TrueClass) for proxy)
Description
Hey guys,
I'm experiencing an error when importing puppet environments, that started sometime in the last 24 hours. I've done a fair amount of troubleshooting and have hit a wall, I'm hoping someone more experienced would be able to shed some light. Some excerpts from the logs:
Foreman URL called
environments/import_environments?env=development&proxy=1-foreman-prod-internal
/var/log/foreman/production.log
ProxyAPI::ProxyException ERF12-4115 [ProxyAPI::ProxyException]: Unable to get classes from Puppet for development ([NoMethodError]: undefined method `map' for true:TrueClass) for proxy https://foreman.prod.internal:8443/puppet lib/proxy_api/puppet.rb:27:in `rescue in classes' lib/proxy_api/puppet.rb:21:in `classes' app/services/puppet_class_importer.rb:153:in `actual_classes' app/services/puppet_class_importer.rb:77:in `new_classes_for' app/services/puppet_class_importer.rb:38:in `changes' app/controllers/concerns/foreman/controller/environments.rb:11:in `import_environments' app/controllers/concerns/application_shared.rb:13:in `set_timezone' app/models/concerns/foreman/thread_session.rb:32:in `clear_thread' lib/middleware/catch_json_parse_errors.rb:9:in `call'
/var/log/foreman-proxy/proxy.log
D, [2015-05-27T15:52:34.320387 #26219] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T15:52:34.320911 #26219] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T15:52:34.429761 #26219] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
/etc/puppet/puppet.conf
[main] logdir = /var/log/puppet rundir = /var/run/puppet ssldir = $vardir/ssl privatekeydir = $ssldir/private_keys { group = service } hostprivkey = $privatekeydir/$certname.pem { mode = 640 } autosign = $confdir/autosign.conf { mode = 664 } show_diff = false hiera_config = $confdir/hiera.yaml <!-- SNIP AGENT DETAILS --> [master] autosign = $confdir/autosign.conf { mode = 664 } reports = foreman external_nodes = /etc/puppet/node.rb node_terminus = exec ca = true ssldir = /var/lib/puppet/ssl certname = foreman.prod.internal strict_variables = false environmentpath = /etc/puppet/environments basemodulepath = /etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules
/etc/foreman-proxy/settings.yml
:settings_directory: /etc/foreman-proxy/settings.d # SSL Setup :ssl_ca_file: /var/lib/puppet/ssl/certs/ca.pem :ssl_certificate: /var/lib/puppet/ssl/certs/foreman.prod.internal.pem :ssl_private_key: /var/lib/puppet/ssl/private_keys/foreman.prod.internal.pem :trusted_hosts: - foreman.prod.internal :daemon: true :https_port: 8443 # shared options for virsh DNS/DHCP provider :virsh_network: default # Where our proxy log files are stored # filename or STDOUT :log_file: /var/log/foreman-proxy/proxy.log # valid options are # WARN, DEBUG, Error, Fatal, INFO, UNKNOWN :log_level: DEBUG #Ignore puppet.conf and use API :puppet_use_environment_api: true
Updated by Ben Bettridge about 9 years ago
Here's a proxy log of what happens when I attempt to import classes from SmartProxy:
Here's a proxy log of what happens when I attempt to import classes from SmartProxy:
10.2.3.192 - - [27/May/2015 17:12:31] "GET /environments HTTP/1.1" 200 64 16.0269 D, [2015-05-27T17:12:33.589869 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:12:33.590376 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:33.635845 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:34.066871 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:34.117861 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:34.222472 #20264] INFO -- : Running scan_directory on development: /etc/puppet/environments/development/modules I, [2015-05-27T17:12:34.224140 #20264] INFO -- : Scanning class svndeploy I, [2015-05-27T17:12:34.280805 #20264] INFO -- : Scanning class tscapture I, [2015-05-27T17:12:34.309695 #20264] INFO -- : Scanning class epel I, [2015-05-27T17:12:34.401291 #20264] INFO -- : Scanning class pound I, [2015-05-27T17:12:34.532864 #20264] INFO -- : Scanning class bind I, [2015-05-27T17:12:34.615669 #20264] INFO -- : Scanning class hosts <!-- SNIP more classes --> I, [2015-05-27T17:12:48.394887 #20264] INFO -- : Cache file need to be updated for development: /etc/puppet/environments/development/modules I, [2015-05-27T17:12:48.406530 #20264] INFO -- : Cache file updated for development: /etc/puppet/environments/development/modules I, [2015-05-27T17:12:48.406769 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:48.484792 #20264] INFO -- : Running scan_directory on development: /etc/puppet/environments/common I, [2015-05-27T17:12:48.486919 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:48.512516 #20264] INFO -- : Running scan_directory on development: /etc/puppet/modules I, [2015-05-27T17:12:48.513742 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:48.600189 #20264] INFO -- : Running scan_directory on development: /usr/share/puppet/modules 10.2.3.192 - - [27/May/2015 17:12:48] "GET /environments/development/classes HTTP/1.1" 200 101594 15.0302 D, [2015-05-27T17:12:48.689835 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:12:48.690338 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:12:48.787183 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf 10.2.3.192 - - [27/May/2015 17:13:18] "GET /environments HTTP/1.1" 200 64 29.9063 D, [2015-05-27T17:13:23.139503 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:13:23.140019 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:23.249935 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:39.926516 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:40.032536 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:40.132443 #20264] INFO -- : Running scan_directory on uat: /etc/puppet/environments/uat/modules I, [2015-05-27T17:13:40.134154 #20264] INFO -- : Scanning class svndeploy I, [2015-05-27T17:13:40.260854 #20264] INFO -- : Scanning class tscapture I, [2015-05-27T17:13:40.295165 #20264] INFO -- : Scanning class epel I, [2015-05-27T17:13:40.383119 #20264] INFO -- : Scanning class pound I, [2015-05-27T17:13:40.520819 #20264] INFO -- : Scanning class bind <!-- SNIP more classes --> I, [2015-05-27T17:13:53.599953 #20264] INFO -- : Cache file need to be updated for uat: /etc/puppet/environments/uat/modules I, [2015-05-27T17:13:53.611082 #20264] INFO -- : Cache file updated for uat: /etc/puppet/environments/uat/modules I, [2015-05-27T17:13:53.611334 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:53.722072 #20264] INFO -- : Running scan_directory on uat: /etc/puppet/environments/common I, [2015-05-27T17:13:53.724208 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:53.804986 #20264] INFO -- : Running scan_directory on uat: /etc/puppet/modules I, [2015-05-27T17:13:53.806509 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:53.835674 #20264] INFO -- : Running scan_directory on uat: /usr/share/puppet/modules 10.2.3.192 - - [27/May/2015 17:13:53] "GET /environments/uat/classes HTTP/1.1" 200 101594 30.7162 D, [2015-05-27T17:13:54.030908 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:13:54.031515 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:13:54.075384 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf D, [2015-05-27T17:14:58.861686 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:14:58.862237 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:14:58.898490 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:15:53.240825 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:15:53.280674 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:15:53.354169 #20264] INFO -- : Running scan_directory on staging: /etc/puppet/environments/staging/modules I, [2015-05-27T17:15:53.355679 #20264] INFO -- : Scanning class svndeploy I, [2015-05-27T17:15:53.406117 #20264] INFO -- : Scanning class tscapture I, [2015-05-27T17:15:53.431311 #20264] INFO -- : Scanning class epel I, [2015-05-27T17:15:53.509642 #20264] INFO -- : Scanning class pound <!-- SNIP more classes --> I, [2015-05-27T17:16:05.231814 #20264] INFO -- : Cache file need to be updated for staging: /etc/puppet/environments/staging/modules I, [2015-05-27T17:16:05.334248 #20264] INFO -- : Cache file updated for staging: /etc/puppet/environments/staging/modules I, [2015-05-27T17:16:05.334588 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:16:05.363143 #20264] INFO -- : Running scan_directory on staging: /etc/puppet/environments/common I, [2015-05-27T17:16:05.364758 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:16:05.441305 #20264] INFO -- : Running scan_directory on staging: /etc/puppet/modules I, [2015-05-27T17:16:05.442833 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:16:05.512172 #20264] INFO -- : Running scan_directory on staging: /usr/share/puppet/modules 10.2.3.192 - - [27/May/2015 17:16:05] "GET /environments/staging/classes HTTP/1.1" 200 95542 66.6706 D, [2015-05-27T17:16:05.645111 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:16:05.645693 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:16:05.689710 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf D, [2015-05-27T17:17:10.555622 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:17:10.556173 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:17:10.645508 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf D, [2015-05-27T17:18:19.758783 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:18:19.759287 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:18:19.852450 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf D, [2015-05-27T17:19:20.252920 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:19:20.253478 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:19:20.345133 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf 10.2.3.192 - - [27/May/2015 17:19:31] "GET /environments HTTP/1.1" 200 64 10.8903 D, [2015-05-27T17:19:33.092477 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:19:33.092994 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:19:33.195064 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:15.752704 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:15.849253 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:15.917988 #20264] INFO -- : Running scan_directory on development: /etc/puppet/environments/development/modules I, [2015-05-27T17:20:15.920352 #20264] INFO -- : Scanning class svndeploy I, [2015-05-27T17:20:15.975752 #20264] INFO -- : Scanning class tscapture I, [2015-05-27T17:20:16.003040 #20264] INFO -- : Scanning class epel I, [2015-05-27T17:20:16.093204 #20264] INFO -- : Scanning class pound <!-- SNIP more classes --> I, [2015-05-27T17:20:29.538383 #20264] INFO -- : Cache file need to be updated for development: /etc/puppet/environments/development/modules I, [2015-05-27T17:20:29.632716 #20264] INFO -- : Cache file updated for development: /etc/puppet/environments/development/modules I, [2015-05-27T17:20:29.632967 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:29.661088 #20264] INFO -- : Running scan_directory on development: /etc/puppet/environments/common I, [2015-05-27T17:20:29.662725 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:29.739764 #20264] INFO -- : Running scan_directory on development: /etc/puppet/modules I, [2015-05-27T17:20:29.741469 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:29.765698 #20264] INFO -- : Running scan_directory on development: /usr/share/puppet/modules 10.2.3.192 - - [27/May/2015 17:20:29] "GET /environments/development/classes HTTP/1.1" 200 101594 56.7531 D, [2015-05-27T17:20:29.951545 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:20:29.952013 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:20:29.994374 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf D, [2015-05-27T17:21:34.611386 #20264] DEBUG -- : verifying remote client 10.2.3.192 against trusted_hosts foreman.prod.internal I, [2015-05-27T17:21:34.611938 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf I, [2015-05-27T17:21:34.651694 #20264] INFO -- : Initializing from Puppet config file: /etc/puppet/puppet.conf
As you can see it appears to import and scan the environments (Note the 'development' is the first one to be scanned), and after it completes them it starts again. This happens infinitely until the process fails with the map error outline above.
Updated by Dominic Cleal about 9 years ago
The smart proxy logs all look correct to me, and show a good response size back to Foreman.
Only a couple of ideas:
- Foreman 1.8.1 has a fix to stop this page being loaded twice, which might help performance at least.
- Try querying the smart proxy and check for a "true" in the response - if you can pastebin the whole response, even better:
curl --cacert /var/lib/puppet/ssl/certs/ca.pem --key /var/lib/puppet/ssl/private_keys/$(hostname).pem --cert /var/lib/puppet/ssl/certs/$(hostname).pem https://$(hostname):8443/puppet/environments/development/classes