Bug #25072
closedCant modify hosts with foreman_chef plugin installed.
Description
When i have foreman_chef plugin installed, i can't edit hosts.
This error gets displayed right after that foreman_chef does a select from database, and then the whole transaction is rolled back:
Current location set to none
(0.3ms) BEGIN
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 ORDER BY firstname LIMIT 1
Nic::Base Load (1.2ms) SELECT `nics`.* FROM `nics` WHERE `nics`.`host_id` = 1 ORDER BY `nics`.`identifier` ASC
Setting Load (0.4ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'append_domain_name_for_hosts' ORDER BY `settings`.`name` ASC LIMIT 1
ForemanChef::CachedRunList Load (0.5ms) SELECT `foreman_chef_cached_run_lists`.* FROM `foreman_chef_cached_run_lists` WHERE `foreman_chef_cached_run_lists`.`host_id` = 1 LIMIT 1
(0.3ms) ROLLBACK
Current location set to none
Current organization set to none
Action failed
| RuntimeError: Executing dynflow action inside a transaction is not a good idea
| /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/models/foreman_tasks/concerns/action_triggering.rb:139:in `ensure_not_in_transaction!'
| /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/models/foreman_tasks/concerns/action_triggering.rb:120:in `dynflow_task_wrap'
| /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/models/foreman_tasks/concerns/action_triggering.rb:27:in `save'
So, something is not able to handle the result from the query against foreman_chef_cached_run_lists
, but i can't figure out what. If i uninstall foreman_chef, the editing works fine.
I've seen similar reports regarding this for older version of foreman_chef also:
https://projects.theforeman.org/issues/19486
https://community.theforeman.org/t/executing-dynflow-action-inside-a-transaction-is-not-a-good-idea/6599
I have a test-setup ready, can test/try anything if I get some pointers :-)
Updated by Björn Zettergren almost 6 years ago
Might add, that the sql query works and returns a row:
mysql> SELECT `foreman_chef_cached_run_lists`.* FROM `foreman_chef_cached_run_lists` WHERE `foreman_chef_cached_run_lists`.`host_id` = 1 LIMIT 1 \G *************************** 1. row *************************** id: 3 list: --- - role[default] host_id: 1 1 row in set (0.00 sec)
Updated by Björn Zettergren almost 6 years ago
Whole trace:
2018-09-30T18:48:18 [I|app|] Started PATCH "/hosts/1" for 10.0.2.2 at 2018-09-30 18:48:18 +0000 2018-09-30T18:48:18 [I|app|187d4] Processing by HostsController#update as */* 2018-09-30T18:48:18 [I|app|187d4] Parameters: {"utf8"=>"✓", "authenticity_token"=>"7Zh1km6kJrvjT/TNqGThwHp/FIlDGScTTgtPatOiv5T/WGEro5uBOr0faNB+ruKJmFnoff9Cx4ZMzmIfmsPUuw==", "host"=>{"run_list"=>{"0"=>{"type"=>"role", "name"=>"default"}}, "override_chef_attributes"=>"true", "name"=>"test02", "hostgroup_id"=>"", "environment_id"=>"", "managed"=>"true", "progress_report_id"=>"[FILTERED]", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "mac"=>"02:fb:a8:4c:29:d0", "identifier"=>"enp0s3", "name"=>"", "domain_id"=>"", "subnet_id"=>"", "ip"=>"10.0.2.15", "ip6"=>"", "managed"=>"0", "primary"=>"0", "provision"=>"0", "tag"=>"", "attached_to"=>"", "id"=>"2"}, "1"=>{"_destroy"=>"0", "mac"=>"00:11:22:33:44:55", "identifier"=>"eth0", "name"=>"test02", "domain_id"=>"1", "subnet_id"=>"1", "ip"=>"10.0.0.123", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "tag"=>"", "attached_to"=>"", "id"=>"1"}}, "architecture_id"=>"1", "operatingsystem_id"=>"2", "medium_id"=>"", "ptable_id"=>"", "pxe_loader"=>"Grub UEFI", "disk"=>"", "is_owned_by"=>"4-Users", "enabled"=>"1", "model_id"=>"1", "comment"=>"", "overwrite"=>"false"}, "id"=>"1"} 2018-09-30T18:48:18 [D|sql|187d4] User Load (2.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] AuthSource Load (0.9ms) SELECT `auth_sources`.* FROM `auth_sources` WHERE `auth_sources`.`id` = 1 LIMIT 1 2018-09-30T18:48:18 [I|app|187d4] Current user set to admin (admin) 2018-09-30T18:48:18 [D|app|187d4] Current location set to none 2018-09-30T18:48:18 [D|app|187d4] Current organization set to none 2018-09-30T18:48:18 [D|sql|187d4] (0.6ms) SELECT `taxonomies`.`id` FROM `taxonomies` WHERE `taxonomies`.`type` IN ('Location') LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] (0.4ms) SELECT `taxonomies`.`id` FROM `taxonomies` WHERE `taxonomies`.`type` IN ('Organization') LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] Host::Managed Load (1.6ms) SELECT `hosts`.* FROM `hosts` WHERE `hosts`.`type` IN ('Host::Managed') AND `hosts`.`name` = '1' LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] Host::Managed Load (1.9ms) SELECT `hosts`.* FROM `hosts` WHERE `hosts`.`type` IN ('Host::Managed') AND `hosts`.`id` = 1 LIMIT 1 2018-09-30T18:48:18 [D|app|187d4] Current organization set to none 2018-09-30T18:48:18 [D|app|187d4] Current location set to none 2018-09-30T18:48:18 [D|sql|187d4] (0.9ms) BEGIN 2018-09-30T18:48:18 [D|sql|187d4] User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 ORDER BY firstname LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] Nic::Base Load (1.3ms) SELECT `nics`.* FROM `nics` WHERE `nics`.`host_id` = 1 ORDER BY `nics`.`identifier` ASC 2018-09-30T18:48:18 [D|sql|187d4] Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'append_domain_name_for_hosts' ORDER BY `settings`.`name` ASC LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] ForemanChef::CachedRunList Load (0.9ms) SELECT `foreman_chef_cached_run_lists`.* FROM `foreman_chef_cached_run_lists` WHERE `foreman_chef_cached_run_lists`.`host_id` = 1 LIMIT 1 2018-09-30T18:48:18 [D|sql|187d4] (2.3ms) ROLLBACK 2018-09-30T18:48:18 [D|app|187d4] Current location set to none 2018-09-30T18:48:18 [D|app|187d4] Current organization set to none 2018-09-30T18:48:18 [W|app|187d4] Action failed | RuntimeError: Executing dynflow action inside a transaction is not a good idea | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/models/foreman_tasks/concerns/action_triggering.rb:139:in `ensure_not_in_transaction!' | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/models/foreman_tasks/concerns/action_triggering.rb:120:in `dynflow_task_wrap' | /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman-tasks-0.13.2/app/models/foreman_tasks/concerns/action_triggering.rb:27:in `save' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.6/lib/active_record/persistence.rb:281:in `block in update' | /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/persistence.rb:279:in `update' | /usr/share/foreman/app/controllers/hosts_controller.rb:122:in `block in update' | /usr/share/foreman/app/models/taxonomy.rb:68:in `block in no_taxonomy_scope' | /usr/share/foreman/app/models/taxonomy.rb:75:in `block (2 levels) in as_taxonomy' | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:179:in `as_location' | /usr/share/foreman/app/models/taxonomy.rb:74:in `block in as_taxonomy' | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:142:in `as_org' | /usr/share/foreman/app/models/taxonomy.rb:73:in `as_taxonomy' | /usr/share/foreman/app/models/taxonomy.rb:67:in `no_taxonomy_scope' | /usr/share/foreman/app/controllers/hosts_controller.rb:119:in `update' | /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-09-30T18:48:18 [I|app|187d4] Rendering common/500.html.erb 2018-09-30T18:48:18 [I|app|187d4] Rendered common/500.html.erb (2.0ms) 2018-09-30T18:48:18 [I|app|187d4] Completed 500 Internal Server Error in 144ms (Views: 3.6ms | ActiveRecord: 14.6ms) 2018-09-30T18:48:18 [D|sql|] (0.7ms) BEGIN 2018-09-30T18:48:18 [D|sql|] SQL (1.0ms) UPDATE `sessions` SET `data` = 'BAh7DUkiFG9yZ2FuaXphdGlvbl9pZAY6BkVGSSIABjsAVEkiEGxvY2F0aW9u\nX2lkBjsARkkiAAY7AFRJIgl1c2VyBjsARmkJSSIPZXhwaXJlc19hdAY7AEZs\nKweCKLFbSSISbG9nZ2luZ190b2tlbgY7AFRJIilmNDJhZjk2ZC0zYjMzLTRl\nMzEtOGZmZC0wOWI0YTZjMWRiNzEGOwBGSSILbG9jYWxlBjsARiIHZW5JIhBf\nY3NyZl90b2tlbgY7AEZJIjFFc0FVdWMwL3A0RmVVSndkMXNvRFNlSW0vUFM4\nVytDVkFzVXRkVWxoYXk4PQY7AEZJIhpyZWRpcmVjdF90b191cmxfaG9zdHMG\nOwBUIj5odHRwOi8vbG9jYWxob3N0OjMwMDAvaG9zdHMvdGVzdDAxLnZhZ3Jh\nbnQuemV0dGVyZ3Jlbi5vcmc=\n', `updated_at` = '2018-09-30 18:48:18' WHERE `sessions`.`id` = 27 2018-09-30T18:48:18 [D|sql|] (1.3ms) COMMIT
Updated by The Foreman Bot almost 6 years ago
- Status changed from New to Ready For Testing
- Assignee set to Marek Hulán
- Pull request https://github.com/theforeman/foreman_chef/pull/89 added
Updated by Marek Hulán over 5 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman_chef|d3d2a37add8cbb4f3c5dcc6af6d10a80e8b61bfa.