Bug 1884988

Summary: Inventory Upload fails on QueueForUploadJob
Product: Red Hat Satellite Reporter: Pavel Moravec <pmoravec>
Component: RH Cloud - InventoryAssignee: Shimon Shtein <sshtein>
Status: CLOSED DUPLICATE QA Contact: Mirek Długosz <mzalewsk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.7.0CC: aruzicka, mzalewsk
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 1.0.12 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-13 14:25:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pavel Moravec 2020-10-04 09:55:21 UTC
Description of problem:
Enabling Insights per [1], clicking to Configure > Inventory Upload -> Restart fails in QueueForUploadJob. Each and every time for me. I might click to "Auto upload" before or during the very first Restart action (which can be the trigger here), but even when I disabled this, I constantly get the same error.

[1] https://access.redhat.com/documentation/en-us/red_hat_insights/2020-04/html-single/remediating_issues_across_your_red_hat_satellite_infrastructure_using_red_hat_insights/index#configuring-your-satellite-infrastructure-to-communicate-with-insights


Version-Release number of selected component (if applicable):
satellite-6.7.4 (was .2 during first attempt)


How reproducible:
???


Steps to Reproduce:
No deterministic reproducer known to me.


Actual results:
Restart button fails with backtrace:

rake aborted!

NoMethodError: undefined method `name' for nil:NilClass
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/slice.rb:70:in `block (2 levels) in report_host'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/json_stream.rb:11:in `array'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/json_stream.rb:35:in `array_field'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/slice.rb:64:in `block in report_host'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/json_stream.rb:17:in `object'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/slice.rb:43:in `report_host'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/generators/slice.rb:33:in `block (3 levels) in report_slice'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/delegation.rb:41:in `each'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activerecord-5.2.1/lib/active_record/relation/delegation.rb:41:in `each'
..
Tasks: TOP => foreman_inventory_upload:report:generate
(See full trace by running task with --trace)
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
Must specify either portal_user or organization_id
I, [2020-10-04T11:48:34.254786 #30034] INFO -- : Started generating hosts report in /tmp/d20201004-30034-bq5km8
I, [2020-10-04T11:48:34.335063 #30034] INFO -- : Adding slice 1d605867-7037-42f6-9cba-4a1a5e85ef63


and production.log error:

2020-10-04T11:47:46 [I|app|74d67dec] Performing ForemanInventoryUpload::Async::GenerateReportJob (Job ID: 58ffcd62-6328-447e-a8fb-b72670c0af80) from Dynflow(default) with arguments: "/var/lib/foreman/red_hat_inventory/generated_reports/", "1"
2020-10-04T11:48:36 [I|app|74d67dec] Enqueued ForemanInventoryUpload::Async::QueueForUploadJob (Job ID: 5b99d645-123d-4413-b8b3-0557ac920ef8) to Dynflow(default) with arguments: "/var/lib/foreman/red_hat_inventory/generated_reports/", "report_for_1.tar.gz", "1"
2020-10-04T11:48:36 [I|app|74d67dec] Performed ForemanInventoryUpload::Async::GenerateReportJob (Job ID: 58ffcd62-6328-447e-a8fb-b72670c0af80) from Dynflow(default) in 49621.81ms
2020-10-04T11:48:36 [I|app|74d67dec] Performing ForemanInventoryUpload::Async::QueueForUploadJob (Job ID: 5b99d645-123d-4413-b8b3-0557ac920ef8) from Dynflow(default) with arguments: "/var/lib/foreman/red_hat_inventory/generated_reports/", "report_for_1.tar.gz", "1"
2020-10-04T11:48:36 [E|app|74d67dec] Error performing ForemanInventoryUpload::Async::QueueForUploadJob (Job ID: 5b99d645-123d-4413-b8b3-0557ac920ef8) from Dynflow(default) in 1.78ms: Errno::ENOENT (No such file or directory @ rb_file_s_rename - (/var/lib/foreman/red_hat_inventory/generated_reports/report_for_1.tar.gz, /var/lib/foreman/red_hat_inventory/uploads/report_for_1.tar.gz)):
/opt/rh/rh-ruby25/root/usr/share/ruby/fileutils.rb:471:in `rename'
/opt/rh/rh-ruby25/root/usr/share/ruby/fileutils.rb:471:in `block in mv'
/opt/rh/rh-ruby25/root/usr/share/ruby/fileutils.rb:1463:in `block in fu_each_src_dest'
/opt/rh/rh-ruby25/root/usr/share/ruby/fileutils.rb:1479:in `fu_each_src_dest0'
/opt/rh/rh-ruby25/root/usr/share/ruby/fileutils.rb:1461:in `fu_each_src_dest'
/opt/rh/rh-ruby25/root/usr/share/ruby/fileutils.rb:460:in `mv'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_rh_cloud-1.0.10/lib/foreman_inventory_upload/async/queue_for_upload_job.rb:12:in `perform'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activejob-5.2.1/lib/active_job/execution.rb:39:in `block in perform_now'
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
..

Indeed, /var/lib/foreman/red_hat_inventory/ directory does not contain report_for_1.tar.gz any time.



Expected results:
No such error.


Additional info:
Maybe unrelated:
Trying to download the report (Uploading tab -> Download Report) raises:

undefined local variable or method `foreman_inventory_upload_index_path' for #<ForemanInventoryUpload::UploadsController:0x00007fcbf7d6e730> Did you mean? foreman_inventory_upload_path foreman_inventory_upload_tasks_path foreman_inventory_upload_accounts_path foreman_inventory_upload_tasks_url

Comment 1 Mirek Długosz 2020-10-12 15:21:10 UTC
Do you have reproducer machine you could share internally for debugging?
What was history of this machine? Could it be caused by failure during update? Could you try on fresh Satellite?
Do you have valid manifest uploaded to this organization?

Comment 4 Pavel Moravec 2020-10-14 07:11:41 UTC
OK, I will try to verify on my Sat once 6.7.5 is out. Thanks for checking the cause on background!