Editing host results in "content_view_id and lifecycle_environment_id must be provided together"

Problem:
I just updated Foreman from 3.5.2 to 3.6.1. When editing a host (even making no changes), an error message is given.

Oops, we’re sorry but something went wrong content_view_id and lifecycle_environment_id must be provided together

Both options are filled provided.

Expected outcome:
Changes (such as puppet environment) should be made

Foreman and Proxy versions:
3.6.1

Foreman and Proxy plugin versions:

 - foreman-tasks 7.2.1
 - foreman_discovery 22.0.4
 - foreman_puppet 5.1.2
 - foreman_remote_execution 9.1.0
 - katello 4.8.1

Distribution and version:
AlmaLinux 8.8

Other relevant data:

2023-06-08T14:00:13 [I|app|bfe8153a] Started PATCH "/hosts/146" for 10.162.0.45 at 2023-06-08 14:00:13 -0700
2023-06-08T14:00:13 [I|app|bfe8153a] Processing by HostsController#update as */*
2023-06-08T14:00:13 [I|app|bfe8153a]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"73qp9gVkYoqhjRxrZL74EzUa2T9HAYlq7CWEPDdVAnlEXyhXgT3I0h9TvdIqgVjMmk7p1oWlIzrPqeQ4AE0BoA==", "host"=>{"name"=>"ca-redis2", "hostgroup_id"=>"11", "content_facet_attributes"=>{"lifecycle_environment_id"=>"1", "content_view_id"=>"11", "content_source_id"=>"1"}, "puppet_attributes"=>{"environment_id"=>"3"}, "puppet_proxy_id"=>"1", "puppet_ca_proxy_id"=>"1", "config_group_ids"=>[""], "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "mac"=>"00:50:56:a0:54:6b", "identifier"=>"ens192", "name"=>"ca-redis2", "domain_id"=>"1", "subnet_id"=>"4", "ip"=>"10.217.124.67", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "execution"=>"1", "tag"=>"", "attached_to"=>"", "id"=>"327"}}, "architecture_id"=>"1", "operatingsystem_id"=>"22", "medium_id"=>"", "ptable_id"=>"", "pxe_loader"=>"PXELinux BIOS", "disk"=>"", "host_parameters_attributes"=>{"0"=>{"name"=>"host_update_packages", "parameter_type"=>"boolean", "value"=>"[FILTERED]", "hidden_value"=>"[FILTERED]", "_destroy"=>"false", "id"=>"215"}}, "is_owned_by"=>"5-Users", "enabled"=>"1", "model_id"=>"1", "comment"=>"", "overwrite"=>"false"}, "id"=>"146"}
2023-06-08T14:00:13 [I|app|bfe8153a] set_up_content_view_environment: cv_id=11, env_id=1
2023-06-08T14:00:13 [I|app|bfe8153a] set_up_content_view_environment: done
2023-06-08T14:00:13 [W|api|bfe8153a] param host[puppetclass_*] has been deprecated in favor of host[puppet_attributes][puppetclass_*]
2023-06-08T14:00:13 [W|api|bfe8153a] param host[config_group_*] has been deprecated in favor of host[puppet_attributes][config_group_*]
2023-06-08T14:00:13 [W|app|bfe8153a] content_view_id and lifecycle_environment_id must be provided together
2023-06-08T14:00:13 [I|app|bfe8153a] Backtrace for 'content_view_id and lifecycle_environment_id must be provided together' error (RuntimeError): content_view_id and lifecycle_environment_id must be provided together
 bfe8153a | /usr/share/gems/gems/katello-4.8.1/app/models/katello/concerns/host_managed_extensions.rb:17:in `update'
 bfe8153a | /usr/share/foreman/app/controllers/hosts_controller.rb:117:in `block in update'
 bfe8153a | /usr/share/foreman/app/models/taxonomy.rb:73:in `block in no_taxonomy_scope'
 bfe8153a | /usr/share/foreman/app/models/taxonomy.rb:80:in `block (2 levels) in as_taxonomy'
 bfe8153a | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:195:in `as_location'
 bfe8153a | /usr/share/foreman/app/models/taxonomy.rb:79:in `block in as_taxonomy'
 bfe8153a | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:154:in `as_org'
 bfe8153a | /usr/share/foreman/app/models/taxonomy.rb:78:in `as_taxonomy'
 bfe8153a | /usr/share/foreman/app/models/taxonomy.rb:72:in `no_taxonomy_scope'
 bfe8153a | /usr/share/foreman/app/controllers/hosts_controller.rb:114:in `update'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:228:in `process_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:30:in `process_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 bfe8153a | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bfe8153a | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bfe8153a | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bfe8153a | /usr/share/gems/gems/audited-5.3.1/lib/audited/sweeper.rb:16:in `around'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bfe8153a | /usr/share/gems/gems/audited-5.3.1/lib/audited/sweeper.rb:16:in `around'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:137:in `run_callbacks'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:41:in `process_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rescue.rb:22:in `process_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `block in instrument'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in `instrument'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
 bfe8153a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:165:in `process'
 bfe8153a | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:39:in `process'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:190:in `dispatch'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:254:in `dispatch'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:50:in `block in serve'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in `each'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in `serve'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:842:in `call'
 bfe8153a | /usr/share/gems/gems/katello-4.8.1/lib/katello/middleware/organization_created_enforcer.rb:18:in `call'
 bfe8153a | /usr/share/gems/gems/katello-4.8.1/lib/katello/middleware/event_daemon.rb:10:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 bfe8153a | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/static_dispatcher.rb:68:in `call'
 bfe8153a | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/extractor/recorder.rb:137:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in `call'
 bfe8153a | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in `call'
 bfe8153a | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 bfe8153a | /usr/share/gems/gems/apipie-rails-0.8.2/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/tempfile_reaper.rb:15:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/etag.rb:27:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/conditional_get.rb:40:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/head.rb:12:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
 bfe8153a | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/session/abstract/id.rb:266:in `context'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/session/abstract/id.rb:260:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/cookies.rb:697:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:98:in `run_callbacks'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 bfe8153a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:37:in `call_app'
 bfe8153a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:28:in `call'
 bfe8153a | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 bfe8153a | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/request_id.rb:26:in `call'
 bfe8153a | /usr/share/gems/gems/katello-4.8.1/lib/katello/prevent_json_parsing.rb:12:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/method_override.rb:24:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/runtime.rb:22:in `call'
 bfe8153a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/executor.rb:14:in `call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/sendfile.rb:110:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/ssl.rb:77:in `call'
 bfe8153a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
 bfe8153a | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in `call'
 bfe8153a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/engine.rb:539:in `call'
 bfe8153a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in `public_send'
 bfe8153a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in `method_missing'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/urlmap.rb:74:in `block in call'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/urlmap.rb:58:in `each'
 bfe8153a | /usr/share/gems/gems/rack-2.2.6.2/lib/rack/urlmap.rb:58:in `call'
 bfe8153a | /usr/share/gems/gems/puma-5.6.5/lib/puma/configuration.rb:252:in `call'
 bfe8153a | /usr/share/gems/gems/puma-5.6.5/lib/puma/request.rb:77:in `block in handle_request'
 bfe8153a | /usr/share/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
 bfe8153a | /usr/share/gems/gems/puma-5.6.5/lib/puma/request.rb:76:in `handle_request'
 bfe8153a | /usr/share/gems/gems/puma-5.6.5/lib/puma/server.rb:443:in `process_client'
 bfe8153a | /usr/share/gems/gems/puma-5.6.5/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
 bfe8153a | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2023-06-08T14:00:13 [I|app|bfe8153a]   Rendered common/500.html.erb (Duration: 4.3ms | Allocations: 6121)
2023-06-08T14:00:13 [I|app|bfe8153a] Completed 500 Internal Server Error in 29ms (Views: 4.7ms | ActiveRecord: 4.1ms | Allocations: 16602)

Hi @clevelas

Thanks for providing the traceback. I think this is a bug that might be happening because the host’s hostgroup doesn’t have both CV and LCE assigned. Is this the case?

If my suspicion is correct, you should be able to edit hosts successfully which are not assigned to a hostgroup, or are assigned to a hostgroup that has both CV and LCE.

I’ve reproduced the above case and opened Bug #36498: Can't edit a host assigned to a hostgroup that has CV or LCE but not both - Katello - Foreman

That is correct. The lifecycle environment is set, but not the content view or content source.

1 Like