Bug #13541
closedCreating a puppet content view with the same name as the autogenerated ones causes Exceptions
Description
Good afternoon,
when I tried to setup a complete new content view "line" ( new content view, new host group, new puppet environment, new activation keys ), I got
"undefined method `locations=' for nil:NilClass (NoMethodError)"
This happens, because Katello reuses my manually created KT_#organization)_#stage_#ContentView_#ContentViewId puppet environment,
but that Environment has not set a puppet_environment_id.
this is not checked at app/lib/katello/foreman.rb , therefore
"foreman_environment = content_view_puppet_env.puppet_environment" sets foreman_environment to Nil, which is used without further checks in foreman_environment.locations = locations
2016-02-03 13:00:47 [foreman-tasks/action] [E] undefined method `locations=' for nil:NilClass (NoMethodError) | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/katello/foreman.rb:19:in `update_puppet_environment' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/katello/foreman/content_update.rb:20:in `finalize' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/action.rb:528:in `block (2 levels) in execute_finalize' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware/stack.rb:26:in `call' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware/stack.rb:26:in `pass' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware.rb:16:in `pass' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:20:in `block in finalize' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:46:in `block (2 levels) in as_remote_user' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/katello/util/thread_session.rb:72:in `pulp_config' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:32:in `as_pulp_user' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:45:in `block in as_remote_user' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/katello/util/thread_session.rb:79:in `cp_config' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:27:in `as_cp_user' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:44:in `as_remote_user' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/remote_action.rb:20:in `finalize' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware/stack.rb:22:in `call' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware/stack.rb:26:in `pass' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware.rb:16:in `pass' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/action/progress.rb:30:in `with_progress_calculation' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/action/progress.rb:22:in `finalize' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware/stack.rb:22:in `call' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware/stack.rb:26:in `pass' | /opt/rh/ruby193/root/usr/share/gems/gems/dynflow-0.8.7/lib/dynflow/middleware.rb:16:in `pass' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/keep_locale.rb:15:in `block in finalize' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/keep_locale.rb:22:in `with_locale' | /opt/rh/ruby193/root/usr/share/gems/gems/katello-2.3.1/app/lib/actions/middleware/keep_locale.rb:15:in `finalize'