Not able to edit hosts

Problem:
The error messages below occurred when I edited a host and submitted.
Oops, we’re sorry but something went wrong PG::UniqueViolation: ERROR: duplicate key value violates unique constraint “index_cve_cp_id” DETAIL: Key (cp_id)=(01cb62225254bca96f7554954b87af2c) already exists.

The issue happens even though I just click edited and submitted without any changes.

Expected outcome:
Changes saved without the error messages.

Foreman and Proxy versions:
Foreman version: 3.7.0
Katello : 4.9.1

Foreman and Proxy plugin versions:

Distribution and version:
Almalinux 8.8

Other relevant data:

#foreman-rake errors:fetch_log request_id=4291b25a
Foreman version: 3.7.0
Plugins:

  • foreman-tasks 8.1.1
  • foreman_bootdisk 21.0.4
  • foreman_remote_execution 10.0.5
  • foreman_salt 15.2.1
  • foreman_setup 8.0.1
  • foreman_templates 9.3.3
  • katello 4.9.1

2023-08-15T18:07:08 [I|app|4291b25a] Started PATCH “/hosts/12” for 10.159.11.74 at 2023-08-15 18:07:08 -0700
2023-08-15T18:07:08 [I|app|4291b25a] Processing by HostsController#update as /
2023-08-15T18:07:08 [I|app|4291b25a] Parameters: {“utf8”=>“✓”, “authenticity_token”=>“jOPb3S5Univ6zOb9H81763ei3yTCc0Dvmp7rb5ohdLk3e2NfMeNZlB4+887gfYVatFYJwovMfYZtN06OB4ttmA==”, “host”=>{“salt_module_ids”=>[“”, “2”], “name”=>“dena-eddens”, “hostgroup_id”=>“3”, “realm_id”=>“1”, “salt_environment_id”=>“1”, “salt_proxy_id”=>“1”, “managed”=>“true”, “progress_report_id”=>“[FILTERED]”, “interfaces_attributes”=>{“0”=>{“_destroy”=>“0”, “mac”=>“08:00:27:c6:1d:25”, “identifier”=>“”, “name”=>“dena-eddens”, “domain_id”=>“1”, “subnet_id”=>“1”, “ip”=>“”, “ip6”=>“”, “managed”=>“1”, “primary”=>“1”, “provision”=>“1”, “execution”=>“1”, “tag”=>“”, “attached_to”=>“”, “id”=>“12”}}, “architecture_id”=>“1”, “operatingsystem_id”=>“2”, “medium_id”=>“”, “content_facet_attributes”=>{“kickstart_repository_id”=>“20”}, “ptable_id”=>“139”, “pxe_loader”=>“PXELinux BIOS”, “disk”=>“”, “host_parameters_attributes”=>{“0”=>{“name”=>“kt_activation_keys”, “parameter_type”=>“string”, “value”=>“[FILTERED]”, “hidden_value”=>“[FILTERED]”, “_destroy”=>“false”, “id”=>“5”}}, “is_owned_by”=>“4-Users”, “enabled”=>“1”, “model_id”=>“”, “comment”=>“”, “overwrite”=>“false”}, “media_selector”=>“synced_content”, “id”=>“12”}
2023-08-15T18:07:08 [I|app|4291b25a] set_up_content_view_environment: cv_id=, env_id=
2023-08-15T18:07:08 [I|app|4291b25a] ContentViewEnvironment not found for content view ‘Default Organization View’ and environment ‘Prod Env’; creating a new one.
2023-08-15T18:07:08 [W|app|4291b25a] PG::UniqueViolation: ERROR: duplicate key value violates unique constraint “index_cve_cp_id”
4291b25a | DETAIL: Key (cp_id)=(01cb62225254bca96f7554954b87af2c) already exists.
4291b25a |
2023-08-15T18:07:08 [I|app|4291b25a] Backtrace for ‘PG::UniqueViolation: ERROR: duplicate key value violates unique constraint “index_cve_cp_id”
4291b25a | DETAIL: Key (cp_id)=(01cb62225254bca96f7554954b87af2c) already exists.
4291b25a | ’ error (ActiveRecord::RecordNotUnique): PG::UniqueViolation: ERROR: duplicate key value violates unique constraint “index_cve_cp_id”
4291b25a | DETAIL: Key (cp_id)=(01cb62225254bca96f7554954b87af2c) already exists.
4291b25a |
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in exec_params' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in block (2 levels) in exec_no_cache’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/dependencies/interlock.rb:48:in block in permit_concurrent_loads' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/share_lock.rb:187:in yield_shares’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/dependencies/interlock.rb:47:in permit_concurrent_loads' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in block in exec_no_cache’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract_adapter.rb:696:in block (2 levels) in log' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in block in synchronize’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in synchronize’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract_adapter.rb:695:in block in log' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in instrument’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract_adapter.rb:687:in log' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:670:in exec_no_cache’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql_adapter.rb:649:in execute_and_clear' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:55:in exec_query’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in exec_insert' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:93:in exec_insert’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/database_statements.rb:171:in insert' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/query_cache.rb:22:in insert’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/persistence.rb:375:in _insert_record' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/persistence.rb:929:in _create_record’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/counter_cache.rb:166:in _create_record' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/locking/optimistic.rb:79:in _create_record’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/attribute_methods/dirty.rb:201:in _create_record' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/callbacks.rb:461:in block in _create_record’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:106:in run_callbacks' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:824:in _run_create_callbacks’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/callbacks.rb:461:in _create_record' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/timestamp.rb:108:in _create_record’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/persistence.rb:900:in create_or_update' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/callbacks.rb:457:in block in create_or_update’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:117:in block in run_callbacks' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/autosave_association.rb:385:in around_save_collection_association’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:137:in run_callbacks’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:824:in _run_save_callbacks' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/callbacks.rb:457:in create_or_update’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/timestamp.rb:126:in create_or_update' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/persistence.rb:474:in save’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/validations.rb:47:in save' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/transactions.rb:298:in block in save’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/transactions.rb:354:in block in with_transaction_returning_status' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in block in transaction’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/transaction.rb:319:in block in within_new_transaction' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in block in synchronize’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in synchronize’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/transaction.rb:317:in within_new_transaction' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in transaction’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/transactions.rb:350:in with_transaction_returning_status' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/transactions.rb:298:in save’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/suppressor.rb:44:in save' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/persistence.rb:38:in create’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:795:in _create' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:99:in block in create’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:406:in block in scoping' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:804:in _scoping’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:406:in scoping' 4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:99:in create’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/relation.rb:119:in first_or_create' 4291b25a | /usr/share/gems/gems/katello-4.9.1/app/models/katello/host/content_facet.rb:109:in assign_single_environment’
4291b25a | /usr/share/gems/gems/katello-4.9.1/app/models/katello/concerns/host_managed_extensions.rb:14:in update' 4291b25a | /usr/share/foreman/app/controllers/hosts_controller.rb:118:in block in update’
4291b25a | /usr/share/foreman/app/models/taxonomy.rb:73:in block in no_taxonomy_scope' 4291b25a | /usr/share/foreman/app/models/taxonomy.rb:80:in block (2 levels) in as_taxonomy’
4291b25a | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:195:in as_location' 4291b25a | /usr/share/foreman/app/models/taxonomy.rb:79:in block in as_taxonomy’
4291b25a | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:154:in as_org' 4291b25a | /usr/share/foreman/app/models/taxonomy.rb:78:in as_taxonomy’
4291b25a | /usr/share/foreman/app/models/taxonomy.rb:72:in no_taxonomy_scope' 4291b25a | /usr/share/foreman/app/controllers/hosts_controller.rb:115:in update’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/basic_implicit_render.rb:6:in send_action' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:228:in process_action’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rendering.rb:30:in process_action' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:42:in block in process_action’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:117:in block in run_callbacks' 4291b25a | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in set_timezone’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks' 4291b25a | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in clear_thread’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks' 4291b25a | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in set_topbar_sweeper_controller’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks' 4291b25a | /usr/share/gems/gems/audited-5.3.3/lib/audited/sweeper.rb:16:in around’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks' 4291b25a | /usr/share/gems/gems/audited-5.3.3/lib/audited/sweeper.rb:16:in around’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:126:in block in run_callbacks' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:137:in run_callbacks’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/callbacks.rb:41:in process_action' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/rescue.rb:22:in process_action’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:34:in block in process_action' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in block in instrument’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications/instrumenter.rb:24:in instrument' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/notifications.rb:203:in instrument’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/instrumentation.rb:33:in process_action' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal/params_wrapper.rb:249:in process_action’
4291b25a | /usr/share/gems/gems/activerecord-6.1.7.3/lib/active_record/railties/controller_runtime.rb:27:in process_action' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/abstract_controller/base.rb:165:in process’
4291b25a | /usr/share/gems/gems/actionview-6.1.7.3/lib/action_view/rendering.rb:39:in process' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:190:in dispatch’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_controller/metal.rb:254:in dispatch' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:50:in dispatch’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:33:in serve' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:50:in block in serve’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in each' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/journey/router.rb:32:in serve’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/routing/route_set.rb:842:in call' 4291b25a | /usr/share/gems/gems/katello-4.9.1/lib/katello/middleware/organization_created_enforcer.rb:18:in call’
4291b25a | /usr/share/gems/gems/katello-4.9.1/lib/katello/middleware/event_daemon.rb:10:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' 4291b25a | /usr/share/gems/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in call’
4291b25a | /usr/share/gems/gems/apipie-rails-1.1.0/lib/apipie/static_dispatcher.rb:68:in call' 4291b25a | /usr/share/gems/gems/apipie-rails-1.1.0/lib/apipie/extractor/recorder.rb:139:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/static.rb:24:in call’
4291b25a | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in call' 4291b25a | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in call’
4291b25a | /usr/share/gems/gems/apipie-rails-1.1.0/lib/apipie/middleware/checksum_in_headers.rb:27:in call' 4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/tempfile_reaper.rb:15:in call’
4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/etag.rb:27:in call' 4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/conditional_get.rb:40:in call’
4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/head.rb:12:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/permissions_policy.rb:22:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/http/content_security_policy.rb:19:in call' 4291b25a | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in call’
4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:266:in context' 4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/session/abstract/id.rb:260:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/cookies.rb:697:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:27:in block in call’
4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/callbacks.rb:98:in run_callbacks' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/callbacks.rb:26:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/debug_exceptions.rb:29:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/show_exceptions.rb:33:in call' 4291b25a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:37:in call_app’
4291b25a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/rack/logger.rb:28:in call' 4291b25a | /usr/share/gems/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in call’
4291b25a | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/remote_ip.rb:81:in call’
4291b25a | /usr/share/gems/gems/request_store-1.5.1/lib/request_store/middleware.rb:19:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/request_id.rb:26:in call’
4291b25a | /usr/share/gems/gems/katello-4.9.1/lib/katello/prevent_json_parsing.rb:12:in call' 4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/method_override.rb:24:in call’
4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/runtime.rb:22:in call' 4291b25a | /usr/share/gems/gems/activesupport-6.1.7.3/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/executor.rb:14:in call' 4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/sendfile.rb:110:in call’
4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/ssl.rb:77:in call' 4291b25a | /usr/share/gems/gems/actionpack-6.1.7.3/lib/action_dispatch/middleware/host_authorization.rb:142:in call’
4291b25a | /usr/share/gems/gems/secure_headers-6.5.0/lib/secure_headers/middleware.rb:11:in call' 4291b25a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/engine.rb:539:in call’
4291b25a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in public_send' 4291b25a | /usr/share/gems/gems/railties-6.1.7.3/lib/rails/railtie.rb:207:in method_missing’
4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/urlmap.rb:74:in block in call' 4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/urlmap.rb:58:in each’
4291b25a | /usr/share/gems/gems/rack-2.2.7/lib/rack/urlmap.rb:58:in call' 4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/configuration.rb:270:in call’
4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/request.rb:98:in block in handle_request' 4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/thread_pool.rb:340:in with_force_shutdown’
4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/request.rb:97:in handle_request' 4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/server.rb:431:in process_client’
4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/server.rb:233:in block in run' 4291b25a | /usr/share/gems/gems/puma-6.2.2/lib/puma/thread_pool.rb:147:in block in spawn_thread’
4291b25a | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context’
2023-08-15T18:07:08 [I|app|4291b25a] Rendered common/500.html.erb (Duration: 2.0ms | Allocations: 884)
2023-08-15T18:07:08 [I|app|4291b25a] Completed 500 Internal Server Error in 46ms (Views: 3.1ms | ActiveRecord: 8.2ms | Allocations: 13465)

Looks like a dupe key in the database. It’s a table used by Katello.

From the looks of it, there’s probably more wrong here than just a “simple” DB dupe.

From the first two lines, you can see that it tries to create a DB record for a match between empty cv_id and empty env_id because it cannot find that (I guess simply due to the fact those probably should not exist). It is then trying to create a new one for “Default Organization View” and “Prod Env”. Not sure if those are your actual names or they are some strange defaults Foreman uses as a fallback here. The creation of this mapping then fails.

I double-checked with our own instance and in fact, the content_facet_attributes of the JSON should contain the fields lifecycle_environment_id, content_view_id and content_source_id, which are all missing from your host data.
Maybe this is some sort of problem with hostgroup inheritance or hosts being in the wrong organization, but that’s just a wild guess. If this only happens for one/a few hosts, the issue is probably related those hosts somehow. If it is broader issue, there is probably something gone wrong at scale.

Has this issue come up after a upgrade of Foreman/Katello or has this just startet randomly? Did you have any major changes to your Foreman system recently/before that startet?

Edit: The Foreman i checked the JSON against is Foreman 3.2/Katello 4.4, so maybe the expected behavior changed in the last view versions, but I at least doubt it.

1 Like

The attributes of content facets changed in Katello 4.8. Under the hood, content_view_id and lifecycle_environment_id are no longer assigned directly on a content facet; instead, a content facet is associated with one or more Katello::ContentViewEnvironments which have those two attributes.

4.9.1 is missing some commits which deal with this more elegantly. In the meantime, does the hostgroup you’re inheriting from have both a content view and LCE assigned? If only one of those, it may help to ensure the hostgroup has both assigned.

1 Like

Thank you all for the quick checking.
The issue didn’t happen on Foreman 3.6 and Katello 4.8.
I reinstalled Foreman and Katello to the latest version last week and the issue happens with any hosts on current Foreman and Katello versions.

I have experienced same issue on
foreman-3.6.1-1.el8.noarch
katello-4.8.4-1.el8.noarch

What helped was changing “Lifecycle environment” in Hostgroup configuration and then removing LCE value completely for given Hostgroup.

Once 4.9.2 / 4.10 is released, I’d be interested to know if the issue is resolved. I think all the issues with editing hosts should be addressed then.

1 Like