Description of problem: Changing the name of a category via API, has broken the ability to edit chargeback assignments. Changing the category name back to the original name has not corrected the issue. POST https://hostname/api/categories/1000000000146 { "action" : "edit", "resource" : { "name" : "instance_flavor" } } The log lines from production.log shows: [----] I, [2017-08-20T18:02:17.015059 #21073:16070c4] INFO -- : Started POST "/chargeback/tree_select/?id=xx-Comput e" for 127.0.0.1 at 2017-08-20 18:02:17 -0300 [----] I, [2017-08-20T18:02:17.017851 #21073:16070c4] INFO -- : Processing by ChargebackController#tree_select as J S [----] I, [2017-08-20T18:02:17.017947 #21073:16070c4] INFO -- : Parameters: {"id"=>"xx-Compute"} [----] F, [2017-08-20T18:02:17.622228 #21073:16070c4] FATAL -- : Error caught: [NoMethodError] undefined method `[]' for nil:NilClass /var/www/miq/vmdb/app/controllers/chargeback_controller.rb:746:in `block in cb_assign_set_form_vars' /var/www/miq/vmdb/app/controllers/chargeback_controller.rb:742:in `each' /var/www/miq/vmdb/app/controllers/chargeback_controller.rb:742:in `cb_assign_set_form_vars' /var/www/miq/vmdb/app/controllers/chargeback_controller.rb:439:in `get_node_info' /var/www/miq/vmdb/app/controllers/chargeback_controller.rb:40:in `tree_select' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/abstract_controller/base.rb:188:in `process_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal/rendering.rb:30:in `process_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/abstract_controller/callbacks.rb:20:in `block in process_action' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:126:in `call' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:455:in `call' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:101:in `__run_callbacks__' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:90:in `run_callbacks' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/abstract_controller/callbacks.rb:19:in `process_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal/rescue.rb:20:in `process_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/notifications.rb:164:in `block in instrument' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/notifications.rb:164:in `instrument' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal/instrumentation.rb:30:in `process_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal/params_wrapper.rb:248:in `process_action' /opt/rh/cfme-gemset/gems/activerecord-5.0.2/lib/active_record/railties/controller_runtime.rb:18:in `process_action' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/abstract_controller/base.rb:126:in `process' /opt/rh/cfme-gemset/gems/actionview-5.0.2/lib/action_view/rendering.rb:30:in `process' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal.rb:190:in `dispatch' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_controller/metal.rb:262:in `dispatch' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:50:in `dispatch' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:32:in `serve' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/journey/router.rb:39:in `block in serve' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/journey/router.rb:26:in `each' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/journey/router.rb:26:in `serve' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:725:in `call' /opt/rh/cfme-gemset/gems/secure_headers-3.0.3/lib/secure_headers/middleware.rb:10:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/etag.rb:25:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/conditional_get.rb:38:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/head.rb:12:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:222:in `context' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:216:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/cookies.rb:613:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:97:in `__run_callbacks__' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:750:in `_run_call_callbacks' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/callbacks.rb:90:in `run_callbacks' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/callbacks.rb:36:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/remote_ip.rb:79:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/rack/logger.rb:36:in `call_app' /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/rack/logger.rb:26:in `call' /opt/rh/cfme-gemset/gems/request_store-1.3.2/lib/request_store/middleware.rb:9:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/request_id.rb:24:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/method_override.rb:22:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call' /opt/rh/cfme-gemset/gems/activesupport-5.0.2/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' /opt/rh/cfme-gemset/gems/actionpack-5.0.2/lib/action_dispatch/middleware/executor.rb:12:in `call' /opt/rh/cfme-gemset/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call' /opt/rh/cfme-gemset/gems/railties-5.0.2/lib/rails/engine.rb:522:in `call' /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.3.0/lib/puma/configuration.rb:224:in `call' /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.3.0/lib/puma/server.rb:561:in `handle_request' /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.3.0/lib/puma/server.rb:406:in `process_client' /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.3.0/lib/puma/server.rb:271:in `block in run' /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.3.0/lib/puma/thread_pool.rb:111:in `block in spawn_thread' Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Looking at the error and investigating the DB it looks like there was a tag that was referenced in a chargeback rate assignment that was deleted without removing the corresponding assignment. The tag that was deleted is "rhev_teste_tipo1" and it was under the category named "Instance Flavor" To fix this the customer can just add it back using the admin UI as follows - 1. Navigate to "Configuration / Region 1 [1] and click the "My Company Tags" tab. 2. On that page select the category "Instance Flavor" 3. Add a new entry with the name and description of "rhev_teste_tipo1" That should fix the chargeback rate assignment editor. I followed these steps with the customer's DB and I was able to see the assigned compute rates. The reason why the API request caused this still needs to be investigated. I see the request above in the description but it looks like it's incomplete. Can you please ask for the the full contents of the request? If that is the full request please ask what were they expecting to update?
https://github.com/ManageIQ/manageiq/pull/16039
New commit detected on ManageIQ/manageiq/master: https://github.com/ManageIQ/manageiq/commit/dba7bf9ac937db7bfe5c002dfa37365389ae6562 commit dba7bf9ac937db7bfe5c002dfa37365389ae6562 Author: Gregg Tanzillo <gtanzill> AuthorDate: Mon Sep 25 17:55:24 2017 -0400 Commit: Gregg Tanzillo <gtanzill> CommitDate: Fri Sep 29 11:15:22 2017 -0400 Delete tag assignments when deleting a tag that is referenced in an assignment Eg. - Tag to be deleted - /managed/environment/any1 - Referenced in assignment by the tag /chargeback_rate/assigned_to/vm/tag/managed/environment/any1. Which means that a chargeback rate (tagged with the latter) is assigned to any Vm tagged with environment/any1. Should also be deleted https://bugzilla.redhat.com/show_bug.cgi?id=1483365 app/models/classification.rb | 16 +++++++-- app/models/mixins/assignment_mixin.rb | 11 +++++- spec/models/classification_spec.rb | 56 +++++++++++++++++++++++++---- spec/models/mixins/assignment_mixin_spec.rb | 18 ++++++++++ 4 files changed, 91 insertions(+), 10 deletions(-)
Before fix: 1)Create a custom category, cat1.Add a tag, tag1 for the category. 2)Assign tag1 to a VM 3)Chargeback assignments , make these selections: Assign to: Tagged VMs and instances Tag Category: cat1 Selections Name: tag11; rate: Default 4)Delete tag1 5)Unable to edit chargeback assignments and error message in logs: After fix 1)Create a custom category, cat1.Add a tag, tag1 for the category. 2)Assign tag1 to a VM 3)Chargeback assignments , make these selections: Assign to: Tagged VMs and instances Tag Category: cat1 Selections Name: tag1; rate: Default 4)Delete tag1 5)No errors in logs and it should be possible to edit chargeback assignments
Verified in 5.9.0.8