Bug #36025
closedSubscription can't be blank, A Pool and its Subscription cannot belong to different organizations
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2153273
Description of problem:
During manifest refresh or foreman-rake katello:reimport error as below appear, full traceback in additional info
Importing Katello::Subscription
Importing Katello::Pool
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Subscription can't be blank, A Pool and its Subscription cannot belong to different organizations
Version-Release number of selected component (if applicable):
satellite-6.12.0-4.el8sat.noarch
How reproducible:
Only with customer data
Steps to Reproduce:
1. foreman-rake katello:reimport
Actual results:
Error appear
Expected results:
reimport successful
Additional info:
Importing Katello::Subscription
Importing Katello::Pool
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Subscription can't be blank, A Pool and its Subscription cannot belong to different organizations
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/validations.rb:80:in `raise_validation_error'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/validations.rb:53:in `save!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/transactions.rb:318:in `block in save!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/transactions.rb:212:in `transaction'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/transactions.rb:318:in `save!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/suppressor.rb:48:in `save!'
/usr/share/gems/gems/katello-4.5.0.20/app/lib/katello/lazy_accessor.rb:67:in `save!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/persistence.rb:55:in `create!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:115:in `block in create!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:407:in `block in scoping'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:787:in `_scoping'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:407:in `scoping'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:115:in `create!'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation.rb:124:in `first_or_create!'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:31:in `block in import_candlepin_record'
/usr/share/gems/gems/katello-4.5.0.20/app/lib/katello/util/support.rb:97:in `active_record_retry'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:30:in `import_candlepin_record'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/pool.rb:66:in `import_candlepin_record'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:17:in `block in import_candlepin_records'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:16:in `each'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:16:in `import_candlepin_records'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:53:in `block in import_all'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
/usr/share/gems/gems/activerecord-6.0.4.7/lib/active_record/relation/delegation.rb:88:in `each'
/usr/share/gems/gems/katello-4.5.0.20/app/models/katello/glue/candlepin/candlepin_object.rb:51:in `import_all'
/usr/share/gems/gems/katello-4.5.0.20/lib/katello/tasks/reimport.rake:27:in `block (3 levels) in <top (required)>'
/usr/share/gems/gems/katello-4.5.0.20/lib/katello/tasks/reimport.rake:25:in `each'
/usr/share/gems/gems/katello-4.5.0.20/lib/katello/tasks/reimport.rake:25:in `block (2 levels) in <top (required)>'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in `synchronize'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/share/gems/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/share/gems/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => katello:reimport
Same error found in upstream community: https://community.theforeman.org/t/activerecord-validation-failed-subscription-cant-be-blank-a-pool-and-its-subscription-cannot-belong-to-different-organizations/30701