Foreman 1.19 failing to delete hosts

Problem: When I delete a host from the foreman gui, where it is supposed to go to puppetdb and delete the host and from foreman, it spews out a method_missing error

Expected outcome: Deletes the host from puppetdb and foreman

Foreman and Proxy versions: 1.19

Foreman and Proxy plugin versions: 1.19

Other relevant data:
puppetdb version = 5.2.4-1
ruby-puppetdb-foreman version = 4.0.0-1

2018-10-16T18:27:44 [I|app|] Started DELETE "/hosts/foobar.example.com" for 10.14.1.209 at 2018-10-16 18:27:44 +0100
2018-10-16T18:27:44 [I|app|d8dde] Processing by HostsController#destroy as HTML
2018-10-16T18:27:44 [I|app|d8dde]   Parameters: {"authenticity_token"=>"oKM11C2H6srdPaaabRoJtw9nBxmqFTc4GzbnDEn8ZVXqwT/Hg/PD4490Ln7HbK4gs+cNd7HRyRCbOAv5AuFXyA==", "id"=>"foobar.example.com"}
2018-10-16T18:27:44 [I|app|d8dde] Current user set to admin (admin)
2018-10-16T18:27:44 [I|aud|d8dde] destroy event for Nic::Bond with id 6145
2018-10-16T18:27:44 [I|aud|d8dde] destroy event for Nic::Managed with id 6146
2018-10-16T18:27:44 [I|aud|d8dde] destroy event for Nic::Managed with id 6144
2018-10-16T18:27:44 [I|aud|d8dde] destroy event for Nic::Managed with id 6147
2018-10-16T18:27:44 [I|aud|d8dde] destroy event for Host::Base with id 795
2018-10-16T18:27:44 [W|not|d8dde] Invalid owner for foobar.example.com, unable to send notifications
2018-10-16T18:27:44 [I|app|] Started GET "/notification_recipients" for 10.10.10.10 at 2018-10-16 18:27:44 +0100
2018-10-16T18:27:44 [I|app|8b686] Processing by NotificationRecipientsController#index as JSON
2018-10-16T18:27:44 [I|app|8b686] Current user set to admin (admin)
2018-10-16T18:27:44 [I|app|8b686] Completed 200 OK in 12ms (Views: 0.2ms | ActiveRecord: 4.1ms)
2018-10-16T18:27:44 [W|app|d8dde] Action failed
 | NameError: undefined local variable or method `queue' for #<Host::Managed:0x006ea85bfc9168>
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activemodel-5.1.6/lib/active_model/attribute_methods.rb:432:in `method_missing'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/auditor.rb:99:in `method_missing'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/puppetdb_foreman-4.0.0/app/models/concerns/orchestration/puppetdb.rb:13:in `queue_puppetdb_destroy'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:413:in `block in make_lambda'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:197:in `block (2 levels) in halting'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:601:in `block (2 levels) in default_terminator'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:600:in `catch'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:600:in `block in default_terminator'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:198:in `block in halting'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:507:in `block in invoke_before'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:507:in `each'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:507:in `invoke_before'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:130:in `run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:827:in `_run_destroy_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/callbacks.rb:321:in `destroy'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/transactions.rb:303:in `block in destroy'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/transactions.rb:384:in `block in with_transaction_returning_status'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `block in transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:194:in `block in within_new_transaction'
 | /usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/transaction.rb:191:in `within_new_transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/database_statements.rb:235:in `transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/transactions.rb:210:in `transaction'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/transactions.rb:381:in `with_transaction_returning_status'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/transactions.rb:303:in `destroy'
 | /usr/share/foreman/app/controllers/hosts_controller.rb:134:in `destroy'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/abstract_controller/base.rb:186:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal/rendering.rb:30:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
 | /usr/share/foreman/app/controllers/concerns/application_shared.rb:15:in `set_timezone'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/sweeper.rb:14:in `around'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/sweeper.rb:14:in `around'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:135:in `run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/abstract_controller/callbacks.rb:19:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal/rescue.rb:20:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/notifications.rb:166:in `block in instrument'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/notifications.rb:166:in `instrument'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/railties/controller_runtime.rb:22:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/abstract_controller/base.rb:124:in `process'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionview-5.1.6/lib/action_view/rendering.rb:30:in `process'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal.rb:189:in `dispatch'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal.rb:253:in `dispatch'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:31:in `serve'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/journey/router.rb:33:in `each'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/journey/router.rb:33:in `serve'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:844:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.10/lib/apipie/static_dispatcher.rb:65:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.10/lib/apipie/extractor/recorder.rb:136:in `call'
 | /usr/share/foreman/lib/middleware/telemetry.rb:9:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.10/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 | /usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:8:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/etag.rb:25:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/conditional_get.rb:38:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
 | /usr/share/foreman/lib/middleware/logging_context.rb:23:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:in `context'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/cookies.rb:613:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:97:in `run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/callbacks.rb:24:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:36:in `call_app'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:26:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/request_id.rb:25:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/static.rb:125:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/secure_headers-5.0.5/lib/secure_headers/middleware.rb:13:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.6/lib/rails/engine.rb:522:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.6/lib/rails/railtie.rb:185:in `public_send'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.6/lib/rails/railtie.rb:185:in `method_missing'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/urlmap.rb:68:in `block in call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `each'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/urlmap.rb:53:in `call'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in `service'
 | /usr/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
 | /usr/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
 | /usr/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
 | /usr/share/foreman/vendor/ruby/2.3.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2018-10-16T18:27:44 [I|app|d8dde]   Rendering common/500.html.erb within layouts/application
2018-10-16T18:27:44 [I|app|d8dde]   Rendered common/500.html.erb within layouts/application (2.0ms)
2018-10-16T18:27:44 [I|app|d8dde]   Rendered layouts/_application_content.html.erb (1.4ms)
2018-10-16T18:27:44 [I|app|d8dde]   Rendering layouts/base.html.erb
2018-10-16T18:27:44 [I|app|d8dde]   Rendered layouts/base.html.erb (1.9ms)
2018-10-16T18:27:44 [I|app|d8dde] Completed 500 Internal Server Error in 490ms (Views: 7.2ms | ActiveRecord: 193.0ms)

** puppetdb plugin settings**:

Name Value Description
PuppetDB API Version v4: PuppetDB 4.0, 4.1, 4.2, 4.3 Foreman will use this PuppetDB API version
puppetdb_dashboard_address http://puppetdb.example.com:8080/pdb/dashboard/ Foreman will proxy PuppetDB Performance Dashboard requests to this address
puppetdb_ssl_private_key /etc/puppetlabs/puppet/ssl/private_keys/foreman.example.pem Foreman will send PuppetDB requests with this key file
puppetdb_ssl_ca_file /etc/puppetlabs/puppet/ssl/certs/ca.pem Foreman will send PuppetDB requests with this CA file
puppetdb_ssl_certificate /etc/puppetlabs/puppet/ssl/certs/foreman.example.pem Foreman will send PuppetDB requests with this certificate file
puppetdb_address http://puppetdb.example.com:8080/pdb/cmd/v1 Foreman will send PuppetDB requests to this address
puppetdb_enabled Yes Integration with PuppetDB, enabled will deactivate a host in PuppetDB when it’s deleted in Foreman

Any help is appreciated

We aren’t seeing any regressions with the plugin and 1.19 and the stack trace looks odd.
The method that is supposed to be missing is defined here. This needs more investigation.

Is it possible you have unattended: false in your settings? if so it may be similar to Bug #23536: apipie:cache:index NoMethodError when unattended=false - Foreman

1 Like

We do have unattended: false set and when I turn it to true, it is happy again.
Shall I put in an issue in the tracker?

1 Like

I think the issue here is in the puppetdb plugin which doesn’t take into account the possibility of that setting (which disables orchestration of hosts), so it should be reported to the issue tracker for the plugin on github.

Ah brilliant thanks for this. Will report it on their plugin. Thank you very much :slight_smile: