Bug #36975
closedImport\refresh of manifest fails with error undefined method `last' for #<ActiveSupport::HashWithIndifferentAccess:0x000055a95852d580> (NoMethodError)
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=2253621
Description of problem:
For some reason, Importing a manifest in Katello 4.11 fails with this error.
undefined method `last' for #<ActiveSupport::HashWithIndifferentAccess:0x000055a95852d580> (NoMethodError)
I assumed perhaps the zip being imported is perhaps old and something may have changed with the subs allocation itself but that is not the case.
Whether i impory a newly exported zip or refresh the manifest, The result remains same.
Version-Release number of selected component (if applicable):- rpm -q katello rubygem-katello candlepin
katello-4.11.0-0.2.rc1.el8sat.noarch
rubygem-katello-4.11.0-0.5.rc1.el8sat.noarch
candlepin-4.3.1-1.el8sat.noarch
How reproducible:
always
Steps to Reproduce:
1. Install Katello 4.11 (nightly/master)
2. Try to import the manifest_Anaconda-sat_20230616T101313Z.zip or manifest_Anaconda-sat_20231208T090222Z.zip manifest ( present in the reproducer system )
3. Try refreshing the manifest
Actual results:
first import attempt of manifest_Anaconda-sat_20230616T101313Z.zip
2023-12-08T12:11:59 [I|app|7cd4836c] Started POST "/katello/api/v2/organizations/1/subscriptions/upload" for X.X.X.X at 2023-12-08 12:11:59 +0530
2023-12-08T12:11:59 [I|app|7cd4836c] Processing by Katello::Api::V2::SubscriptionsController#upload as JSON
2023-12-08T12:11:59 [I|app|7cd4836c] Parameters: {"content"=>#<ActionDispatch::Http::UploadedFile:0x000055d4c744e098 @tempfile=#<Tempfile:/tmp/RackMultipart20231208-17661-gg6md9.zip>, @original_filename="manifest_Anaconda-sat_20230616T101313Z.zip", @content_type="application/zip", @headers="Content-Disposition: form-data; name=\"content\"; filename=\"manifest_Anaconda-sat_20230616T101313Z.zip\"\r\nContent-Type: application/zip\r\n">, "api_version"=>"v2", "organization_id"=>"1"}
2023-12-08T12:11:59 [I|bac|7cd4836c] Task {label: , execution_plan_id: 08f35c35-dd57-4354-9efa-494e5a5b1fec} state changed: pending
2023-12-08T12:11:59 [I|bac|7cd4836c] Task {label: Actions::Katello::Organization::ManifestImport, id: bad4bd7b-4597-48d7-a783-ba48b6936310, execution_plan_id: 08f35c35-dd57-4354-9efa-494e5a5b1fec} state changed: planning
2023-12-08T12:11:59 [I|bac|7cd4836c] Task {label: Actions::Katello::Organization::ManifestImport, id: bad4bd7b-4597-48d7-a783-ba48b6936310, execution_plan_id: 08f35c35-dd57-4354-9efa-494e5a5b1fec} state changed: planned
2023-12-08T12:11:59 [I|bac|7cd4836c] Task {label: Actions::Katello::Organization::ManifestImport, id: bad4bd7b-4597-48d7-a783-ba48b6936310, execution_plan_id: 08f35c35-dd57-4354-9efa-494e5a5b1fec} state changed: running
2023-12-08T12:11:59 [I|app|7cd4836c] Rendered /usr/share/gems/gems/katello-4.11.0.rc1/app/views/katello/api/v2/common/async.json.rabl within katello/api/v2/layouts/resource (Duration: 11.7ms | Allocations: 8282)
2023-12-08T12:11:59 [I|app|7cd4836c] Rendered layout /usr/share/gems/gems/katello-4.11.0.rc1/app/views/katello/api/v2/layouts/resource.json.erb (Duration: 12.5ms | Allocations: 8549)
2023-12-08T12:11:59 [I|app|7cd4836c] Completed 202 Accepted in 130ms (Views: 12.9ms | ActiveRecord: 15.9ms | Allocations: 52299)
2023-12-08T12:12:13 [I|app|dc895f80] import candlepin pool cp_id=8aca4d5f8c458b7f018c48298fad54ba success=false duration=352.28
2023-12-08T12:12:13 [W|app|dc895f80] Unable to import pool. It will likely be created by another process.
2023-12-08T12:12:13 [I|kat|dc895f80] candlepin event handled success=true subject=pool.created entity_id=8aca4d5f8c458b7f018c48298fad54ba duration=352.8
2023-12-08T12:12:13 [I|app|dc895f80] import candlepin pool cp_id=8aca4d5f8c458b7f018c48298fad54bd success=false duration=220.54
2023-12-08T12:12:13 [W|app|dc895f80] Unable to import pool. It will likely be created by another process.
2023-12-08T12:12:13 [I|kat|dc895f80] candlepin event handled success=true subject=pool.created entity_id=8aca4d5f8c458b7f018c48298fad54bd duration=221.0
2023-12-08T12:12:15 [I|app|dc895f80] import candlepin pool cp_id=8aca4d5f8c458b7f018c48298fae54c0 success=true duration=2008.46
2023-12-08T12:12:15 [I|kat|dc895f80] candlepin event handled success=true subject=pool.created entity_id=8aca4d5f8c458b7f018c48298fae54c0 duration=2008.9
2023-12-08T12:12:16 [I|app|7cd4836c] Imported 306 products success=true duration=896.05
2023-12-08T12:12:16 [I|app|dc895f80] import candlepin pool cp_id=8aca4d5f8c458b7f018c48298fae54c3 success=true duration=1160.44
2023-12-08T12:12:16 [I|kat|dc895f80] candlepin event handled success=true subject=pool.created entity_id=8aca4d5f8c458b7f018c48298fae54c3 duration=1160.89
2023-12-08T12:12:17 [I|app|7cd4836c] Imported product content success=false duration=1120.1
2023-12-08T12:12:17 [E|bac|7cd4836c] undefined method `last' for #<ActiveSupport::HashWithIndifferentAccess:0x000055a95852d580> (NoMethodError)
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:81:in `block in find_product_for_content'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `each'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `find'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `find_product_for_content'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:108:in `block in handle_product_moves'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:105:in `each'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:105:in `handle_product_moves'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:126:in `block in import'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:125:in `each'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:125:in `import'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/models/katello/glue/provider.rb:135:in `block in import_products_from_cp'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/katello/logging.rb:8:in `time'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/models/katello/glue/provider.rb:134:in `import_products_from_cp'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:13:in `block (2 levels) in run'
7cd4836c | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
7cd4836c | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:12:in `block in run'
7cd4836c | /usr/share/gems/gems/audited-5.4.2/lib/audited/auditor.rb:448:in `without_auditing'
7cd4836c | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:11:in `run'
7cd4836c | /usr/share/gems/gems/dynflow-1.8.2/lib/dynflow/action.rb:589:in `block (3 levels) in execute_run'
Next , tried to refresh the manifest in satellite:
2023-12-08T12:15:10 [I|app|d6183da0] Started PUT "/katello/api/v2/organizations/1/subscriptions/refresh_manifest" for X.X.X.X at 2023-12-08 12:15:10 +0530
2023-12-08T12:15:10 [I|app|d6183da0] Processing by Katello::Api::V2::SubscriptionsController#refresh_manifest as JSON
2023-12-08T12:15:10 [I|app|d6183da0] Parameters: {"api_version"=>"v2", "organization_id"=>"1", "subscription"=>{}}
2023-12-08T12:15:11 [I|bac|d6183da0] Task {label: , execution_plan_id: 68b796db-5ca9-48d0-8b46-6f344535736d} state changed: pending
2023-12-08T12:15:11 [I|bac|d6183da0] Task {label: Actions::Katello::Organization::ManifestRefresh, id: c578f4c2-c2ce-49e7-938c-81633e10b2b8, execution_plan_id: 68b796db-5ca9-48d0-8b46-6f344535736d} state changed: planning
2023-12-08T12:15:11 [I|bac|d6183da0] Task {label: Actions::Katello::Organization::ManifestRefresh, id: c578f4c2-c2ce-49e7-938c-81633e10b2b8, execution_plan_id: 68b796db-5ca9-48d0-8b46-6f344535736d} state changed: planned
2023-12-08T12:15:12 [I|app|d6183da0] Rendered /usr/share/gems/gems/katello-4.11.0.rc1/app/views/katello/api/v2/common/async.json.rabl within katello/api/v2/layouts/resource (Duration: 15.3ms | Allocations: 14839)
2023-12-08T12:15:12 [I|app|d6183da0] Rendered layout /usr/share/gems/gems/katello-4.11.0.rc1/app/views/katello/api/v2/layouts/resource.json.erb (Duration: 16.8ms | Allocations: 17496)
2023-12-08T12:15:12 [I|app|d6183da0] Completed 202 Accepted in 1156ms (Views: 15.7ms | ActiveRecord: 16.8ms | Allocations: 92753)
2023-12-08T12:15:12 [I|bac|d6183da0] Task {label: Actions::Katello::Organization::ManifestRefresh, id: c578f4c2-c2ce-49e7-938c-81633e10b2b8, execution_plan_id: 68b796db-5ca9-48d0-8b46-6f344535736d} state changed: running
2023-12-08T12:15:50 [I|app|d6183da0] Imported 318 products success=true duration=465.74
2023-12-08T12:15:51 [I|app|d6183da0] Imported product content success=false duration=821.69
2023-12-08T12:15:51 [E|bac|d6183da0] undefined method `last' for #<ActiveSupport::HashWithIndifferentAccess:0x000055a9575ed688> (NoMethodError)
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:81:in `block in find_product_for_content'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `each'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `find'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `find_product_for_content'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:108:in `block in handle_product_moves'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:105:in `each'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:105:in `handle_product_moves'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:126:in `block in import'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:125:in `each'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:125:in `import'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/models/katello/glue/provider.rb:135:in `block in import_products_from_cp'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/katello/logging.rb:8:in `time'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/models/katello/glue/provider.rb:134:in `import_products_from_cp'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:13:in `block (2 levels) in run'
d6183da0 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
d6183da0 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:12:in `block in run'
d6183da0 | /usr/share/gems/gems/audited-5.4.2/lib/audited/auditor.rb:448:in `without_auditing'
d6183da0 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:11:in `run'
d6183da0 | /usr/share/gems/gems/dynflow-1.8.2/lib/dynflow/action.rb:589:in `block (3 levels) in execute_run'
Next, exported a new zip of the same old manifest i.e. manifest_Anaconda-sat_20231208T090222Z.zip and trying to imoprt it :
2023-12-08T14:34:09 [I|app|8d8a1e19] Started POST "/katello/api/v2/organizations/1/subscriptions/upload" for X.X.X.X at 2023-12-08 14:34:09 +0530
2023-12-08T14:34:09 [I|app|8d8a1e19] Processing by Katello::Api::V2::SubscriptionsController#upload as JSON
2023-12-08T14:34:09 [I|app|8d8a1e19] Parameters: {"content"=>#<ActionDispatch::Http::UploadedFile:0x00005589f66487c0 @tempfile=#<Tempfile:/tmp/RackMultipart20231208-33518-y557bw.zip>, @original_filename="manifest_Anaconda-sat_20231208T090222Z.zip", @content_type="application/zip", @headers="Content-Disposition: form-data; name=\"content\"; filename=\"manifest_Anaconda-sat_20231208T090222Z.zip\"\r\nContent-Type: application/zip\r\n">, "api_version"=>"v2", "organization_id"=>"1"}
2023-12-08T14:34:09 [I|bac|8d8a1e19] Task {label: , execution_plan_id: 63899698-460d-4875-8b59-b65ec6e580e6} state changed: pending
2023-12-08T14:34:09 [I|bac|8d8a1e19] Task {label: Actions::Katello::Organization::ManifestImport, id: bf77189d-3469-4895-9bd3-cbcde89fbbc6, execution_plan_id: 63899698-460d-4875-8b59-b65ec6e580e6} state changed: planning
2023-12-08T14:34:09 [I|bac|8d8a1e19] Task {label: Actions::Katello::Organization::ManifestImport, id: bf77189d-3469-4895-9bd3-cbcde89fbbc6, execution_plan_id: 63899698-460d-4875-8b59-b65ec6e580e6} state changed: planned
2023-12-08T14:34:09 [I|app|8d8a1e19] Rendered /usr/share/gems/gems/katello-4.11.0.rc1/app/views/katello/api/v2/common/async.json.rabl within katello/api/v2/layouts/resource (Duration: 15.0ms | Allocations: 7844)
2023-12-08T14:34:09 [I|app|8d8a1e19] Rendered layout /usr/share/gems/gems/katello-4.11.0.rc1/app/views/katello/api/v2/layouts/resource.json.erb (Duration: 15.8ms | Allocations: 8117)
2023-12-08T14:34:09 [I|app|8d8a1e19] Completed 202 Accepted in 410ms (Views: 13.2ms | ActiveRecord: 172.9ms | Allocations: 75519)
2023-12-08T14:34:09 [I|bac|8d8a1e19] Task {label: Actions::Katello::Organization::ManifestImport, id: bf77189d-3469-4895-9bd3-cbcde89fbbc6, execution_plan_id: 63899698-460d-4875-8b59-b65ec6e580e6} state changed: running
2023-12-08T14:34:13 [I|app|8d8a1e19] Imported 318 products success=true duration=408.5
2023-12-08T14:34:15 [I|app|8d8a1e19] Imported product content success=false duration=1419.1
2023-12-08T14:34:15 [E|bac|8d8a1e19] undefined method `last' for #<ActiveSupport::HashWithIndifferentAccess:0x00007fd0e8cd6430> (NoMethodError)
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:81:in `block in find_product_for_content'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `each'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `find'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:80:in `find_product_for_content'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:108:in `block in handle_product_moves'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:105:in `each'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:105:in `handle_product_moves'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:126:in `block in import'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:125:in `each'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/services/katello/product_content_importer.rb:125:in `import'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/models/katello/glue/provider.rb:135:in `block in import_products_from_cp'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/katello/logging.rb:8:in `time'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/models/katello/glue/provider.rb:134:in `import_products_from_cp'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:13:in `block (2 levels) in run'
8d8a1e19 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
8d8a1e19 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:12:in `block in run'
8d8a1e19 | /usr/share/gems/gems/audited-5.4.2/lib/audited/auditor.rb:448:in `without_auditing'
8d8a1e19 | /usr/share/gems/gems/katello-4.11.0.rc1/app/lib/actions/candlepin/owner/import_products.rb:11:in `run'
Expected results:
No such errors or
Additional info:
I can import the same manifests in a Satellite 6.14 without any issues. So this seems to be some sort of regression here.
On non-working satellite:
hammer shows:
- hammer subscription list --organization-id 1
---|----------------------------------|--------------|----------|----------|---------|--------------|---------------------|---------------------|----------|---------
ID | UUID | NAME | TYPE | CONTRACT | ACCOUNT | SUPPORT | START DATE | END DATE | QUANTITY | CONSUMED
---|----------------------------------|--------------|----------|----------|---------|--------------|---------------------|---------------------|----------|---------
4 | 8aca4d5f8c458b7f018c48298fae54c0 | Employee SKU | Physical | 12864984 | 540155 | Self-Support | 2022/01/01 05:00:00 | 2027/01/01 04:59:59 | 1 | 0
---|----------------------------------|--------------|----------|----------|---------|--------------|---------------------|---------------------|----------|---------
The actual manifest has:
- rct cat-manifest Downloads/manifest_Anaconda-sat_20231208T090222Z.zip | grep "Quantity:"
B2 -A15 ✔ 0.41 L 56.17G RAM 14:45:07
Subscription:
Name: Employee SKU
Quantity: 1
Created: 2022-05-07T14:28:59.000+00:00
Start Date: 2022-01-01T05:00:00.000+00:00
End Date: 2027-01-01T04:59:59.000+00:00
Service Level: Self-Support
Service Type: L1-L3
Architectures: aarch64,ia64,ppc,ppc64,ppc64le,s390,s390x,x86,x86_64
SKU: ES0113909
Contract: 12864984
Order: 40575425
Account: 540155
Virt Limit: unlimited
Requires Virt-who: True
Entitlement File: export/entitlements/0ceac4de490b47dfb9fd1a6abf75f610.json
Certificate File: export/entitlement_certificates/8182309875088279090.pem
Certificate Version: 3.4
-
Subscription:
Name: High Availability
Quantity: 1
Created: 2022-05-07T14:28:58.000+00:00
Start Date: 2022-01-01T05:00:00.000+00:00
End Date: 2027-01-01T04:59:59.000+00:00
Service Level: Layered
Service Type: L1-L3
Architectures: ia64,ppc,ppc64,x86,x86_64
SKU: RH00025
Contract: 12864984
Order: 40575425
Account: 540155
Virt Limit:
Requires Virt-who: False
Entitlement File: export/entitlements/94bf39b5366a455eb33d98538773ef8d.json
Certificate File: export/entitlement_certificates/2466116886395581057.pem
Certificate Version: 3.4
--
Subscription:
Name: Red Hat Satellite Employee Subscription
Quantity: 1
Created: 2022-05-07T14:29:03.000+00:00
Start Date: 2022-01-01T05:00:00.000+00:00
End Date: 2027-01-01T04:59:59.000+00:00
Service Level: Self-Support
Service Type: L1-L3
Architectures: aarch64,ia64,ppc,ppc64,ppc64le,s390,s390x,x86,x86_64
SKU: SER0232US
Contract: 12864984
Order: 40575425
Account: 540155
Virt Limit:
Requires Virt-who: False
Entitlement File: export/entitlements/e77fff5531a84b8c9ac12fb7c2a5b543.json
Certificate File: export/entitlement_certificates/8096354114307944831.pem
Certificate Version: 3.4