Katello: Puppet classes disappear after promoting content view

Problem:
We have an organization TEST with a specific location. This location has two environments Library and DEV.

Then we have a capsule/smartproxy for only DEV.

When I promote a content view from Library to DEV all my puppet classes are gone in that puppet environment (KT_TEST_DEV_CentOS7_Base_20) and I have to import them again from the capsule/smartproxy. The import then has all the modules with Add:.

After that all my smart class parameter overrides are gone and puppet fails. I can then fill them all in again but this will only hold until the next content view promotion.

Expected outcome:
To keep the puppet classes and parameters.

Foreman and Proxy versions:
Katello 3.12, foreman and proxy version 1.22

I see a lot of this in the log:

 517092 2019-07-30T15:32:08 [D|app|79a6dbf0] Body: [{"search_params":{"type":"task","task_id":"8d23ab4a-2e3f-486e-95c6-c2f04b88f575","search_id":"5"},"results":[{"id":"8d23ab4a-2e3f-486e-95c6-c2f04b88f575","label":"Actions::Katello::ContentView::Promote","pending":true,"action":"Promote content view 'CentOS7_Base'; organization '****'","username":"****","started_at":"2019-07-30T15:30:44.000+02:00","ended_at":null,"state":"running","result":"pending","progress":        0.9024390243902439,"input":{"content_view":{"id":20,"name":"CentOS7_Base","label":"CentOS7_Base"},"organization":{"id":7,"name":"****","label":"****"},"environments":["DEV"],"services_checked":["pulp","pulp_auth","candlepin","ca        ndlepin_auth"],"current_request_id":null,"current_timezone":"Europe/Amsterdam","current_user_id":4,"current_organization_id":7,"current_location_id":6},"output":{},"humanized":{"action":"Promote","input":[["content_view",{"text":"        content view 'CentOS7_Base'","link":"/content_views/20/versions"}],["organization",{"text":"organization '****'","link":"/organizations/7/edit"}]],"output":"","errors":[]},"cli_example":null}]}]
 517093 2019-07-30T15:32:08 [I|app|79a6dbf0] Completed 200 OK in 159ms (Views: 1.9ms | ActiveRecord: 10.8ms)
 517094 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on default_value ${postgresql::params::service_name}
 517095 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on path
 517096 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on description
 517097 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on validator_type
 517098 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on validator_rule
 517099 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on key_type string
 517100 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on override false
 517101 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on required false
 517102 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on merge_overrides false
 517103 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on avoid_duplicates false
 517104 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on omit
 517105 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on merge_default false
 517106 2019-07-30T15:32:06 [I|aud|] PuppetclassLookupKey (4351) destroy event on hidden_value false
 517107 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on key service_manage
 517108 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on puppetclass_id
 517109 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on default_value ${postgresql::params::service_manage}
 517110 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on path
 517111 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on description
 517112 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on validator_type
 517113 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on validator_rule
 517114 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on key_type string
 517115 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on override false
 517116 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on required false
 517117 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on merge_overrides false
 517118 2019-07-30T15:32:08 [I|aud|] PuppetclassLookupKey (4350) destroy event on avoid_duplicates false
 517392 2019-07-30T15:32:10 [I|aud|] LookupValue (48) destroy event on match domain=idiot.local
 517393 2019-07-30T15:32:10 [I|aud|] LookupValue (48) destroy event on value {"zabbix-agent"=>{"ensure"=>"present", "zone"=>"internal", "source"=>"10.104.104.23/32", "service"=>"zabbix-agent", "action"=>"accept"}}
 517394 2019-07-30T15:32:10 [I|aud|] LookupValue (48) destroy event on lookup_key_id 3969
 517395 2019-07-30T15:32:10 [I|aud|] LookupValue (48) destroy event on omit false

Some extra info:

2019-07-31T11:33:56 [E|app|77b1b3f6] You may not destroy KT_TEST_Library_CentOS7_Base_20 as it is in use!
2019-07-31T12:52:20 [E|app|] You may not destroy firewalld as it is in use!
2019-07-31T12:52:22 [E|app|] You may not destroy freeipa as it is in use!
2019-07-31T12:52:28 [E|app|] You may not destroy ovirt_guest_agent as it is in use!
2019-07-31T12:52:31 [E|app|] You may not destroy postgresql::server as it is in use!
2019-07-31T12:52:35 [E|app|] You may not destroy zabbix::agent as it is in use!
2019-07-31T12:52:36 [E|app|] You may not destroy zabbix::proxy as it is in use!
2019-07-31T13:25:19 [E|app|3f7e3b42] You may not destroy KT_TEST_Library_CentOS7_Base_20 as it is in use!

When I import the classes from the smartproxy it tries to remove KT_TEST_Library_CentOS7_Base_20, but it is in use.

I then look at where it is in use and it is in use on the primary HostGroup TEST and there are nested groups below it.

When I try to remove or change the Lifecycle Environment, Content View or puppet environment I get the following error:

Oops, we’re sorry but something went wrong tried to flatten recursive array

ArgumentError
tried to flatten recursive array
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/errors.rb:180:in `flatten'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/errors.rb:180:in `size'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/errors.rb:210:in `empty?'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/validations.rb:410:in `run_validations!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/validations/callbacks.rb:118:in `block in run_validations!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:132:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:816:in `_run_validation_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/validations/callbacks.rb:118:in `run_validations!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/validations.rb:339:in `valid?'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/validations.rb:67:in `valid?'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/validations.rb:84:in `perform_validations'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/validations.rb:46:in `save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:310:in `block (2 levels) in save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:252:in `transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:310:in `block in save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:325:in `rollback_active_record_state!'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:309:in `save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/suppressor.rb:44:in `save'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/persistence.rb:428:in `block in update'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:387:in `block in with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `block in transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:239:in `block in within_new_transaction'
/opt/rh/rh-ruby25/root/usr/share/ruby/monitor.rb:226:in `mon_synchronize'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/transaction.rb:236:in `within_new_transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:254:in `transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/transactions.rb:385:in `with_transaction_returning_status'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/persistence.rb:426:in `update'
/usr/share/foreman/app/controllers/hostgroups_controller.rb:65:in `update'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.7.1/lib/audited/sweeper.rb:14:in `around'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.7.1/lib/audited/sweeper.rb:14:in `around'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `block in instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `instrument'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:134:in `process'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionview-5.2.1/lib/action_view/rendering.rb:32:in `process'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal.rb:191:in `dispatch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal.rb:252:in `dispatch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:34:in `serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:52:in `block in serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `serve'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:840:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.14/lib/apipie/static_dispatcher.rb:65:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.14/lib/apipie/extractor/recorder.rb:137:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-rails-0.5.14/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
/usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/tempfile_reaper.rb:15:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/etag.rb:25:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/conditional_get.rb:38:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
/usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:232:in `context'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:226:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/rack/logger.rb:28:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
/usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.1/lib/katello/prevent_json_parsing.rb:12:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/runtime.rb:22:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/engine.rb:524:in `call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/urlmap.rb:68:in `block in call'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/urlmap.rb:53:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/rack-2.0.6/lib/rack/urlmap.rb:53:in `call'
/usr/share/passenger/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
/usr/share/passenger/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
/usr/share/passenger/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
/usr/share/passenger/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context' 

The issue with " tried to flatten recursive array" is not related, I removed this parent hostgroup and the problem with the puppet classes still occurs

@Netbulae1: So the issue you are seeing is that a puppet class in the library CV is not present in the promoted Dev CV? Could you provide the logs for the task promoting the CV from Library > Dev… Do you see any errors in the task?

The class is there, it’s just not assigned to the Puppet environment on the smartproxy. Then I have to reimport it and lose all the parameters I’ve set before.

The logs for this are quite big as it takes a while, I can see no errors but I see lot’s of “PuppetclassLookupKey destroy events” and create events when I import them again.

This is what I see after all the Puppetclass destroy events. Also I’ve now added and synched the Library environment to the proxy, but this puppet environment for this also has the same issue with the classes being removed. But also only on promotion not the first Library publish.

2019-08-01T11:00:42 [I|app|9462b42c] Processing by PuppetclassesController#index as HTML
Response: 200: [{"scratchpad": {"checksum_type": "sha256"}, "display_name": "CentOS-7_sclo x86_64 rh", "description": null, "last_unit_added": "2019-07-29T09:38:03Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 8373}, "_ns": "repos", "_id": {"$oid": "5d3ebb04eb12d86db2e9f042"}, "id": "7-CentOS7_Base-DEV-d91dd7f5-1f06-44fa-90d4-ae45077aed3b", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-d91dd7f5-1f06-44fa-90d4-ae45077aed3b/"}, {"scratchpad": {"checksum_type": "sha1"}, "display_name": "Puppet 6", "description": null, "last_unit_added": "2019-07-29T10:28:19Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 106}, "_ns": "repos", "_id": {"$oid": "5d3ebb02eb12d86db3931445"}, "id": "7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "CentOS-7_updates x86_64", "description": null, "last_unit_added": "2019-07-29T10:44:18Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 2303}, "_ns": "repos", "_id": {"$oid": "5d3ebb06eb12d86db2e9f045"}, "id": "7-CentOS7_Base-DEV-c7935819-6a03-42a9-a14b-9985123c0f85", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-c7935819-6a03-42a9-a14b-9985123c0f85/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "CentOS-7_os x86_64", "description": null, "last_unit_added": "2019-07-29T10:08:01Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"package_group": 88, "distribution": 1, "rpm": 10019}, "_ns": "repos", "_id": {"$oid": "5d3ebb05eb12d86db393144d"}, "id": "7-CentOS7_Base-DEV-c6c07d48-646f-4ead-865d-1d00bdc22e75", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-c6c07d48-646f-4ead-865d-1d00bdc22e75/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "Foreman client 1.22 x86_64", "description": null, "last_unit_added": "2019-07-29T09:25:00Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"package_group": 1, "rpm": 10}, "_ns": "repos", "_id": {"$oid": "5d3ebb02eb12d86db2e9f03f"}, "id": "7-CentOS7_Base-DEV-9eedc3c1-c4eb-4ee0-bf4e-b2fd04d3accd", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-9eedc3c1-c4eb-4ee0-bf4e-b2fd04d3accd/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "CentOS-7_sclo x86_64 sclo", "description": null, "last_unit_added": "2019-07-29T10:45:13Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 786}, "_ns": "repos", "_id": {"$oid": "5d3ebb04eb12d86db19dfe9e"}, "id": "7-CentOS7_Base-DEV-68cb8112-fd0f-48b1-8887-c044aa5cf767", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-68cb8112-fd0f-48b1-8887-c044aa5cf767/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "CentOS-7_extras x86_64", "description": null, "last_unit_added": "2019-07-29T09:24:52Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 419}, "_ns": "repos", "_id": {"$oid": "5d3ebb02eb12d86db3931444"}, "id": "7-CentOS7_Base-DEV-5f2ea244-ed1d-4483-baeb-a787926fdb30", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-5f2ea244-ed1d-4483-baeb-a787926fdb30/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "CentOS-7_configmanagement x86_64 ansible27", "description": null, "last_unit_added": "2019-07-29T09:28:04Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 9}, "_ns": "repos", "_id": {"$oid": "5d3ebb03eb12d86db393144a"}, "id": "7-CentOS7_Base-DEV-5b7bde62-06c8-4023-a058-e4f817e4477b", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-5b7bde62-06c8-4023-a058-e4f817e4477b/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "Zabbix 4.2 rhel 7 x86_64", "description": null, "last_unit_added": "2019-07-29T09:27:54Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 79}, "_ns": "repos", "_id": {"$oid": "5d3ebb02eb12d86db19dfe9b"}, "id": "7-CentOS7_Base-DEV-13c733e4-1c79-4c96-a992-f084abc3668b", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-13c733e4-1c79-4c96-a992-f084abc3668b/"}, {"scratchpad": {"checksum_type": "sha256"}, "display_name": "Epel_7", "description": null, "last_unit_added": "2019-07-31T11:05:17Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": "2019-07-31T11:02:52Z", "content_unit_counts": {"package_group": 33, "rpm": 13328, "erratum": 4328}, "_ns": "repos", "_id": {"$oid": "5d3ebb06eb12d86db19dfea1"}, "id": "7-CentOS7_Base-DEV-0cbe31d4-d40d-4f25-9842-e3d57e27b02f", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-0cbe31d4-d40d-4f25-9842-e3d57e27b02f/"}]
Response: 200: [{"scratchpad": {}, "display_name": "CentOS7_Base Puppet Environment", "description": null, "last_unit_added": "2019-07-30T12:14:49Z", "notes": {"_repo-type": "puppet-repo"}, "last_unit_removed": null, "content_unit_counts": {"puppet_module": 12}, "_ns": "repos", "_id": {"$oid": "5d3ebb06eb12d86db19dfea4"}, "id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/"}]
2019-08-01T11:00:50 [I|app|2a288f2e] Processing by PuppetclassesController#index as HTML
Response: 200: {"scratchpad": {"checksum_type": "sha1"}, "display_name": "Puppet 6", "description": null, "distributors": [{"repo_id": "7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703", "last_updated": "2019-07-29T09:23:14Z", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703/distributors/7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703/", "last_override_config": {}, "last_publish": "2019-07-31T22:27:33Z", "distributor_type_id": "yum_distributor", "auto_publish": true, "scratchpad": {}, "_ns": "repo_distributors", "_id": {"$oid": "5d3ebb02eb12d86db3931449"}, "config": {"protected": true, "http": true, "https": true, "relative_url": "TEST/DEV/CentOS7_Base/custom/Puppet/Puppet_6"}, "id": "7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703"}], "last_unit_added": "2019-07-29T10:28:19Z", "notes": {"_repo-type": "rpm-repo"}, "last_unit_removed": null, "content_unit_counts": {"rpm": 106}, "_ns": "repos", "importers": [{"repo_id": "7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703", "last_updated": "2019-07-29T09:23:14Z", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703/importers/yum_importer/", "_ns": "repo_importers", "importer_type_id": "yum_importer", "last_override_config": {}, "last_sync": "2019-07-31T21:44:29Z", "scratchpad": {"repomd_revision": 1564394535, "repomd_checksum": "c8f91f672f85b95f361e9e6bcfe9de08b83816baaafd04d10ae33588044796b3"}, "_id": {"$oid": "5d3ebb02eb12d86db3931447"}, "config": {"feed": "https://***.****.***/pulp/repos/TEST/DEV/CentOS7_Base/custom/Puppet/Puppet_6/", "ssl_ca_cert": "Certificate: ***** -----END RSA PRIVATE KEY-----\n"}, "id": "yum_importer"}], "locally_stored_units": 1, "_id": {"$oid": "5d3ebb02eb12d86db3931445"}, "total_repository_units": 106, "id": "7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-cf2b657c-c824-4af3-8350-0555a4964703/"}
Response: 200: {"scratchpad": {}, "display_name": "CentOS7_Base Puppet Environment", "description": null, "distributors": [{"repo_id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920", "last_updated": "2019-07-29T09:23:18Z", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/distributors/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920_puppet/", "last_override_config": {}, "last_publish": "2019-07-31T22:42:05Z", "distributor_type_id": "puppet_distributor", "auto_publish": true, "scratchpad": {}, "_ns": "repo_distributors", "_id": {"$oid": "5d3ebb06eb12d86db19dfea6"}, "config": {"serve_https": true, "serve_http": false}, "id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920_puppet"}, {"repo_id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920", "last_updated": "2019-07-29T09:23:18Z", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/distributors/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/", "last_override_config": {}, "last_publish": "2019-07-31T22:42:06Z", "distributor_type_id": "puppet_install_distributor", "auto_publish": true, "scratchpad": {}, "_ns": "repo_distributors", "_id": {"$oid": "5d3ebb06eb12d86db19dfea7"}, "config": {"install_path": "/etc/puppetlabs/code/environments/KT_TEST_DEV_CentOS7_Base_20", "subdir": "modules"}, "id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920"}], "last_unit_added": "2019-07-30T12:14:49Z", "notes": {"_repo-type": "puppet-repo"}, "last_unit_removed": null, "content_unit_counts": {"puppet_module": 12}, "_ns": "repos", "importers": [{"repo_id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920", "last_updated": "2019-07-29T09:23:18Z", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/importers/puppet_importer/", "_ns": "repo_importers", "importer_type_id": "puppet_importer", "last_override_config": {}, "last_sync": "2019-07-31T22:41:45Z", "scratchpad": null, "_id": {"$oid": "5d3ebb06eb12d86db19dfea5"}, "config": {"feed": "https://***.****.***/pulp/puppet/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/", "ssl_ca_cert": "Certificate:\n ***-----END RSA PRIVATE KEY-----\n"}, "id": "puppet_importer"}], "locally_stored_units": 12, "_id": {"$oid": "5d3ebb06eb12d86db19dfea4"}, "total_repository_units": 12, "id": "7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920", "_href": "/pulp/api/v2/repositories/7-CentOS7_Base-DEV-puppet-d4c00915-ac1c-4306-a151-c4d0191bf920/"}

This is being tracked in Bug #27483: Promoting a Content View removes all puppet classes and parameters from Environment - Katello - Foreman and is on the sprint board for the team.