Bug #17450
closedSalt facts not working after upgrade to tfm-rubygem-foreman_salt-7.0.1-1.fm1_13.el7.noarch
Description
Executing salt-call --grains on minion or /usr/bin/foreman-node sltest from salt master
production log:
2016-11-22 16:02:49 7c8df5e6 [app] [I] Processing by Api::V2::HostsController#facts as JSON
2016-11-22 16:02:49 7c8df5e6 [app] [I] Parameters: {"name"=>"sltest1", "facts"=>"[FILTERED]", "apiv"=>"v2", :host=>{"name"=>"sltest"}}
2016-11-22 16:02:49 7c8df5e6 [app] [W] Action failed
| NoMethodError: undefined method `pluck' for {}:Hash
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb:56:in `facts_to_create'
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb:48:in `add_fact'
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb:42:in `block in add_missing_facts'
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb:26:in `each'
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb:26:in `add_missing_facts'
| /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb:21:in `add_new_facts'
| /usr/share/foreman/app/services/fact_importer.rb:41:in `import!'
| /usr/share/foreman/app/models/host/base.rb:123:in `import_facts'
| /usr/share/foreman/app/models/host/managed.rb:306:in `import_facts'
| /usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:240:in `facts'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/abstract_controller/base.rb:198:in `process_action'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/action_controller/metal/rendering.rb:10:in `process_action'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/actionpack-4.2.5.1/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:117:in `call'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:505:in `call'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:313:in `call'
| /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
| /usr/share/foreman/app/controllers/api/v2/base_controller.rb:152:in `disable_json_root'
Updated by Anonymous over 7 years ago
Could you try to revert https://github.com/theforeman/foreman_salt/commit/0c33e2b58e68903df4fb7dd0cc2d5434db8e8b0b.diff, restart httpd on the Foreman server and try again?
Updated by Anonymous over 7 years ago
- Project changed from Foreman to Salt
- Category set to Foreman Integration
Updated by Joe Collette over 7 years ago
Michael Moll wrote:
Could you try to revert https://github.com/theforeman/foreman_salt/commit/0c33e2b58e68903df4fb7dd0cc2d5434db8e8b0b.diff, restart httpd on the Foreman server and try again?
I've only reverted the fact_importer.rb from that commit an also used the latest commit for the file host_managed_extensions.rb.
https://github.com/theforeman/foreman_salt/blob/7ce37bfc7376e05620f7deeba630a867b7b2d761/app/models/foreman_salt/concerns/host_managed_extensions.rb
diff host_managed_extensions.rb.bak host_managed_extensions.rb
105a106,109
class ::Host::Managed::Jail < Safemode::Jail
allow :salt_environment
end
diff /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_salt-7.0.1/app/services/foreman_salt/fact_importer.rb /tmp/fact_importer.rb
56c56
< @facts_to_create ||= facts.keys - db_facts.keys
---
@facts_to_create ||= facts.keys - db_facts.pluck('fact_names.name')
Will do some more testing, but this seems to work.
salt-call --grains
016-11-22 18:52:23 98fd91fd [app] [I] Import facts for 'sesaltm1.x.pdtpartners.com' completed. Added: 0, Updated: 1, Deleted 0 facts
2016-11-22 18:52:23 98fd91fd [app] [I] Completed 201 Created in 685ms (Views: 13.9ms | ActiveRecord: 54.0ms)
2016-11-22 18:52:25 0793decb [app] [I] Started GET "/salt/node/sesaltm1.x.pdtpartners.com?format=yml" for * at 2016-11-22 18:52:25 -0500
2016-11-22 18:52:25 0793decb [app] [I] Processing by ForemanSalt::MinionsController#node as YML
2016-11-22 18:52:25 0793decb [app] [I] Parameters: {"id"=>"sesaltm1.x.pdtpartners.com"}
2016-11-22 18:52:25 0793decb [app] [I] Rendered text template (0.0ms)
2016-11-22 18:52:25 0793decb [app] [I] Completed 200 OK in 245ms (Views: 3.9ms | ActiveRecord: 47.9ms
Updated by Anonymous over 7 years ago
could you please revert the whole commit? and also test if that fixes your other issue you opened? it's not really possible for me to cut a new release with a half-reverted commit that may introduce other problems.
Updated by Anonymous over 7 years ago
basically you could install the 7.0.0 RPM of the plugin, that's what would need testing on 1.13 with your two issues.
Updated by Joe Collette over 7 years ago
Michael Moll wrote:
basically you could install the 7.0.0 RPM of the plugin, that's what would need testing on 1.13 with your two issues.
Reverting to 7.0.0 works fixes the fact import issue. 7.0.0 also introduces the bug found here http://projects.theforeman.org/issues/17203, which we need to apply the workaround for.
The salt environment issue is not resolved in any release. I have even tried a fresh foreman install of 1.13.1 and the states do not work in the create host, create hostgroup and discovery menu.
Updated by Anonymous over 7 years ago
- Status changed from New to Closed
- Assignee set to Anonymous
This specific bug here with 1.13 will be resolved by 7.0.2 (hopefully in the APT/YUM repos soon).
https://github.com/theforeman/foreman_salt/commit/6bf4e68600b7749b9aad6c7b7f95c1b563b95829