Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36064 - Don't try to assign empty CV/LCE to a cloned host #10448

Merged
merged 1 commit into from
Mar 15, 2023

Conversation

jeremylenz
Copy link
Member

What are the changes introduced in this pull request?

Host cloning was broken! In hosts_and_hostgroups_helper, the kickstart_repository_options method was taking the original host's content view and lifecycle environment and assigning it to the cloned host, without first checking to see if the original host even had a CVE assigned. Now, it skips cloning the CVE if the original host doesn't have one.

Considerations taken when implementing this change?

Currently only works for single-environment hosts. I didn't cover multi-environment hosts because we haven't yet adapted anything else for multi-environment hosts. But we'll have to do that eventually.

For now, for a multi-environment host it just wouldn't clone the multiple CVEs and your cloned host would be left with no CVE. But at least you won't get a Rails error.

What are the testing steps for this pull request?

Try, from either the old or new host UI, to clone a host that doesn't have a LCE/CV assigned.

@theforeman-bot
Copy link

Issues: #36064

@ares
Copy link
Contributor

ares commented Feb 13, 2023

Hmmm, it does not seem to solve the issue for me.

foreman-rake errors:fetch_log request_id=571f8784
WARNING: Sidekiq::Web.sessions= is no longer relevant and will be removed in Sidekiq 7.0. /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/web.rb:75:in `set'
Foreman version: 3.6.0-develop
Plugins: 
 - foreman-tasks 7.2.0
 - foreman_ansible 11.0.0
 - foreman_azure_rm 2.2.9
 - foreman_bootdisk 21.0.3
 - foreman_discovery 22.0.2
 - foreman_google 1.0.1
 - foreman_leapp 0.1.12
 - foreman_openscap 5.2.2
 - foreman_puppet 5.0.0
 - foreman_remote_execution 9.0.1
 - foreman_templates 9.3.0
 - foreman_virt_who_configure 0.5.12
 - foreman_webhooks 3.0.5
 - katello 4.8.0.pre.master

2023-02-13T09:32:01 [I|app|571f8784] Started GET "/hosts/cesar-bevis.example.com/clone" for 192.168.22.15 at 2023-02-13 09:32:01 -0500
2023-02-13T09:32:01 [I|app|571f8784] Processing by HostsController#clone as HTML
2023-02-13T09:32:01 [I|app|571f8784]   Parameters: {"id"=>"cesar-bevis.example.com"}
2023-02-13T09:32:03 [W|app|571f8784] Scoped order is ignored, it's forced to be batch order.
2023-02-13T09:32:03 [W|app|571f8784] Not queueing Host::Managed: ["Name can't be blank", "Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123"]
2023-02-13T09:32:03 [W|app|571f8784] Not queueing Host::Managed: ["Name can't be blank", "Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123"]
2023-02-13T09:32:03 [W|app|571f8784] Not queueing Host::Managed: ["Name can't be blank", "Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123"]
2023-02-13T09:32:03 [W|app|571f8784] Not queueing Discovery reboot: Name can't be blank and Name hostname can contain only lowercase letters, numbers, dashes and dots according to RFC921, RFC952 and RFC1123
2023-02-13T09:32:03 [I|app|571f8784] Deface: [WARNING] No :original defined for 'add_execution_interface_js', you should change its definition to include:
 571f8784 |  :original => '0a2ee13f9e5015cf251e632e8bfed6b826128792' 
2023-02-13T09:32:03 [I|app|571f8784] Deface: [WARNING] No :original defined for 'ansible_roles_tab', you should change its definition to include:
 571f8784 |  :original => '8c63c5282ee199068bfd65475e13066ee981089a' 
2023-02-13T09:32:03 [I|app|571f8784] Deface: [WARNING] No :original defined for 'ansible_roles_tab_content', you should change its definition to include:
 571f8784 |  :original => '0a2ee13f9e5015cf251e632e8bfed6b826128792' 
2023-02-13T09:32:03 [I|app|571f8784] Deface: [WARNING] No :original defined for 'add_execution_interface', you should change its definition to include:
 571f8784 |  :original => 'dbe1da973bfb251a74b994e7ae11bc8d11502c97' 
2023-02-13T09:32:04 [I|app|571f8784] Deface: [WARNING] No :original defined for 'hosts_select_media_type', you should change its definition to include:
 571f8784 |  :original => '2d9ab0e830d51c8cd4271ea3f3ade95cfbf3de75' 
2023-02-13T09:32:04 [I|app|571f8784] Deface: [WARNING] No :original defined for 'hosts_select_synced_content', you should change its definition to include:
 571f8784 |  :original => '2d9ab0e830d51c8cd4271ea3f3ade95cfbf3de75' 
2023-02-13T09:32:04 [I|app|571f8784]   Rendered hosts/clone.html.erb within layouts/application (Duration: 573.3ms | Allocations: 315545)
2023-02-13T09:32:04 [I|app|571f8784]   Rendered layout layouts/application.html.erb (Duration: 573.5ms | Allocations: 315608)
2023-02-13T09:32:04 [W|app|571f8784] Lifecycle environment must be specified
2023-02-13T09:32:04 [I|app|571f8784] Backtrace for 'Lifecycle environment must be specified' error (ActionView::Template::Error): Lifecycle environment must be specified
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/app/models/katello/host/content_facet.rb:99:in `assign_single_environment'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/app/helpers/katello/hosts_and_hostgroups_helper.rb:350:in `hostgroup_content_facet'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/app/helpers/katello/hosts_and_hostgroups_helper.rb:212:in `kickstart_repository_options'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/app/helpers/katello/hosts_and_hostgroups_helper.rb:37:in `kickstart_repository_id'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/app/helpers/katello/hosts_and_hostgroups_helper.rb:27:in `use_install_media'
 571f8784 | /usr/share/foreman/app/views/common/os_selection/_operatingsystem.html.erb:2:in `block in _df0912664e609b418b3de3420b9079d5'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/capture_helper.rb:45:in `block in capture'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/capture_helper.rb:209:in `with_output_buffer'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/capture_helper.rb:45:in `capture'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/form_helper.rb:1004:in `fields_for'
 571f8784 | /usr/share/foreman/app/views/common/os_selection/_operatingsystem.html.erb:1:in `_df0912664e609b418b3de3420b9079d5'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `public_send'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `_run'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:154:in `block in render'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:205:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:345:in `instrument_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:152:in `render'
 571f8784 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/rendering_helper.rb:45:in `render'
 571f8784 | /usr/share/foreman/app/views/hosts/provision_method/build/_form.html.erb:6:in `_e5167ab368d77d0761cd0ed31dfa7893'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `public_send'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `_run'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:154:in `block in render'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:205:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:345:in `instrument_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:152:in `render'
 571f8784 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/rendering_helper.rb:45:in `render'
 571f8784 | /usr/share/foreman/app/views/hosts/_operating_system.html.erb:20:in `block in _aec22c7cd0ec77d3232111e664b55af2'
 571f8784 | /usr/share/foreman/app/views/hosts/_operating_system.html.erb:18:in `each'
 571f8784 | /usr/share/foreman/app/views/hosts/_operating_system.html.erb:18:in `_aec22c7cd0ec77d3232111e664b55af2'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `public_send'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `_run'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:154:in `block in render'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:205:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:345:in `instrument_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:152:in `render'
 571f8784 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/rendering_helper.rb:45:in `render'
 571f8784 | /usr/share/foreman/app/views/hosts/_unattended.html.erb:6:in `_62ae52dc6dd1ff19c76ef4d2327c6fe4'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `public_send'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `_run'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:154:in `block in render'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:205:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:345:in `instrument_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:152:in `render'
 571f8784 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:53:in `render_partial'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/rendering_helper.rb:45:in `render'
 571f8784 | /usr/share/foreman/app/views/hosts/_form.html.erb:125:in `block (2 levels) in _d265b30b3eece93393c17c865da9e119'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/capture_helper.rb:45:in `block in capture'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/capture_helper.rb:209:in `with_output_buffer'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/capture_helper.rb:45:in `capture'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/form_helper.rb:450:in `form_for'
 571f8784 | /usr/share/foreman/app/helpers/form_helper.rb:286:in `form_for'
 571f8784 | /usr/share/foreman/app/views/hosts/_form.html.erb:7:in `block in _d265b30b3eece93393c17c865da9e119'
 571f8784 | /usr/share/foreman/app/models/taxonomy.rb:80:in `block (2 levels) in as_taxonomy'
 571f8784 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:195:in `as_location'
 571f8784 | /usr/share/foreman/app/models/taxonomy.rb:79:in `block in as_taxonomy'
 571f8784 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:154:in `as_org'
 571f8784 | /usr/share/foreman/app/models/taxonomy.rb:78:in `as_taxonomy'
 571f8784 | /usr/share/foreman/app/views/hosts/_form.html.erb:6:in `_d265b30b3eece93393c17c865da9e119'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `public_send'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `_run'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:154:in `block in render'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:205:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:345:in `instrument_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:152:in `render'
 571f8784 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/partial_renderer.rb:271:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:27:in `render_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:22:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/rendering_helper.rb:38:in `block in render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:273:in `in_rendering_context'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/helpers/rendering_helper.rb:34:in `render'
 571f8784 | /usr/share/foreman/app/views/hosts/clone.html.erb:3:in `_3b4d1536b7b888a644f074a86a9cf444'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `public_send'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:247:in `_run'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:154:in `block in render'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:205:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:345:in `instrument_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/template.rb:152:in `render'
 571f8784 | /usr/share/gems/gems/deface-1.5.3/lib/deface/action_view_extensions.rb:43:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/template_renderer.rb:61:in `block (2 levels) in render_template'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/template_renderer.rb:56:in `block in render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/template_renderer.rb:71:in `block in render_with_layout'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/template_renderer.rb:55:in `render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/template_renderer.rb:11:in `render'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/renderer/renderer.rb:29:in `render_to_object'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/rendering.rb:117:in `block in _render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/base.rb:273:in `in_rendering_context'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/rendering.rb:116:in `_render_template'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/streaming.rb:218:in `_render_template'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/rendering.rb:103:in `render_to_body'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/abstract_controller/rendering.rb:25:in `render'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/rendering.rb:36:in `render'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
 571f8784 | /usr/share/ruby/benchmark.rb:308:in `realtime'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/core_ext/benchmark.rb:14:in `ms'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/instrumentation.rb:46:in `block in render'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
 571f8784 | /usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/instrumentation.rb:45:in `render'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/implicit_render.rb:35:in `default_render'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/abstract_controller/base.rb:228:in `process_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/rendering.rb:30:in `process_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 571f8784 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 571f8784 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 571f8784 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 571f8784 | /usr/share/gems/gems/audited-5.2.0/lib/audited/sweeper.rb:16:in `around'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 571f8784 | /usr/share/gems/gems/audited-5.2.0/lib/audited/sweeper.rb:16:in `around'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:137:in `run_callbacks'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/abstract_controller/callbacks.rb:41:in `process_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/rescue.rb:22:in `process_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `block in instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/notifications.rb:203:in `instrument'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 571f8784 | /usr/share/gems/gems/activerecord-6.1.7.2/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/abstract_controller/base.rb:165:in `process'
 571f8784 | /usr/share/gems/gems/actionview-6.1.7.2/lib/action_view/rendering.rb:39:in `process'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal.rb:190:in `dispatch'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_controller/metal.rb:254:in `dispatch'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/journey/router.rb:32:in `each'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/journey/router.rb:32:in `serve'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/routing/route_set.rb:842:in `call'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/lib/katello/middleware/event_daemon.rb:10:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 571f8784 | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/static_dispatcher.rb:68:in `call'
 571f8784 | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/extractor/recorder.rb:137:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/static.rb:24:in `call'
 571f8784 | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 571f8784 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 571f8784 | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/tempfile_reaper.rb:15:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/etag.rb:27:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/conditional_get.rb:27:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/head.rb:12:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 571f8784 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/session/abstract/id.rb:266:in `context'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/session/abstract/id.rb:260:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/cookies.rb:697:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/callbacks.rb:98:in `run_callbacks'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 571f8784 | /usr/share/gems/gems/railties-6.1.7.2/lib/rails/rack/logger.rb:37:in `call_app'
 571f8784 | /usr/share/gems/gems/railties-6.1.7.2/lib/rails/rack/logger.rb:28:in `call'
 571f8784 | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 571f8784 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 571f8784 | /usr/share/gems/gems/katello-4.8.0.pre.master/lib/katello/prevent_json_parsing.rb:12:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/method_override.rb:24:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/runtime.rb:22:in `call'
 571f8784 | /usr/share/gems/gems/activesupport-6.1.7.2/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/executor.rb:14:in `call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/sendfile.rb:110:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 571f8784 | /usr/share/gems/gems/actionpack-6.1.7.2/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 571f8784 | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in `call'
 571f8784 | /usr/share/gems/gems/railties-6.1.7.2/lib/rails/engine.rb:539:in `call'
 571f8784 | /usr/share/gems/gems/railties-6.1.7.2/lib/rails/railtie.rb:207:in `public_send'
 571f8784 | /usr/share/gems/gems/railties-6.1.7.2/lib/rails/railtie.rb:207:in `method_missing'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/urlmap.rb:74:in `block in call'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/urlmap.rb:58:in `each'
 571f8784 | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/urlmap.rb:58:in `call'
 571f8784 | /usr/share/gems/gems/puma-5.6.5/lib/puma/configuration.rb:252:in `call'
 571f8784 | /usr/share/gems/gems/puma-5.6.5/lib/puma/request.rb:77:in `block in handle_request'
 571f8784 | /usr/share/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
 571f8784 | /usr/share/gems/gems/puma-5.6.5/lib/puma/request.rb:76:in `handle_request'
 571f8784 | /usr/share/gems/gems/puma-5.6.5/lib/puma/server.rb:443:in `process_client'
 571f8784 | /usr/share/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
 571f8784 | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2023-02-13T09:32:04 [I|app|571f8784]   Rendered common/500.html.erb within layouts/application (Duration: 1.9ms | Allocations: 1259)
2023-02-13T09:32:04 [I|app|571f8784]   Rendered layouts/base.html.erb (Duration: 3.7ms | Allocations: 4583)
2023-02-13T09:32:04 [I|app|571f8784]   Rendered layout layouts/application.html.erb (Duration: 7.1ms | Allocations: 6997)
2023-02-13T09:32:04 [I|app|571f8784] Completed 500 Internal Server Error in 2988ms (Views: 7.8ms | ActiveRecord: 104.0ms | Allocations: 454667)

@jeremylenz
Copy link
Member Author

@ares What are your exact repro steps? I reproduced the error but I did notice the stack was a bit different. And I could only reproduce on a host without content in build mode.

@jeremylenz
Copy link
Member Author

@ares Updated. I wasn't able to reliably reproduce the error, but I think I've fixed the codepath from the error stack you posted.

@sjha4
Copy link
Member

sjha4 commented Mar 9, 2023

The UI issue we saw where the CV is not shown for the hostgroup even if it's present in the backend causes an incorrect patch request to go out with empty CV if we don't re-set it for every edit when using synced content from a kickstart repo in a CV.
This is how the params look like and the error below:

22:03:09 rails.1   | 2023-03-09T22:03:09 [I|app|a16730ef] Started PATCH "/hostgroups/1-test-group" for 192.168.122.1 at 2023-03-09 22:03:09 +0000
22:03:09 rails.1   | 2023-03-09T22:03:09 [I|app|a16730ef] Processing by HostgroupsController#update as HTML
22:03:09 rails.1   | 2023-03-09T22:03:09 [I|app|a16730ef]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"iKhUBMDeKJYsLo3IRFcRTc4hgrtQofwad1nF56SrFE5JCltS7aAWboWw5FJwf14anLB8gk5jTzKCzVVTc4ES/A==", "hostgroup"=>{"parent_id"=>"", "name"=>"test-group", "description"=>"", "lifecycle_environment_id"=>"2", "content_view_id"=>"", "content_source_id"=>"1", "compute_resource_id"=>"", "domain_id"=>"1", "realm_id"=>"", "architecture_id"=>"1", "operatingsystem_id"=>"1", "medium_id"=>"", "ptable_id"=>"134", "pxe_loader"=>"PXELinux BIOS", "root_pass"=>"[FILTERED]", "location_ids"=>["2", ""], "organization_ids"=>["1", ""], "id"=>"1"}, "commit"=>"Submit", "id"=>"1-test-group"}
22:03:09 rails.1   | 2023-03-09T22:03:09 [E|app|a16730ef] Failed to save: Kickstart repository The selected kickstart repository is not part of the assigned content view, lifecycle environment, content source, operating system, and architecture

@jeremylenz
Copy link
Member Author

The UI issue we saw where the CV is not shown for the hostgroup even if it's present in the backend causes an incorrect patch request to go out

This is a separate issue and I'm hoping it will be corrected when #10380 is ready..

Copy link
Member

@sjha4 sjha4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI issue we saw where the CV is not shown for the hostgroup even if it's present in the backend causes an incorrect patch request to go out

This is a separate issue and I'm hoping it will be corrected when #10380 is ready..

Ack..Remember or remind me to test this on that PR..
This PR looks good. Was able to reproduce the error and the stacktrace in different flows. This patch fixes it. 👍🏼

@jeremylenz jeremylenz merged commit 870746d into Katello:master Mar 15, 2023
lfu pushed a commit to lfu/katello that referenced this pull request Mar 16, 2023
lfu pushed a commit that referenced this pull request Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants