From ecbafcb79a03b6112dae8af15a9f5a49f0329e3b Mon Sep 17 00:00:00 2001 From: Bernhard Suttner Date: Fri, 22 Mar 2024 13:55:22 +0100 Subject: [PATCH] Fix scheduled task for uploading report failed (#874) (cherry picked from commit 210d322602eb3406f85c91cab2605aee9d456c36) --- app/controllers/api/v2/rh_cloud/inventory_controller.rb | 4 ++-- .../async/generate_all_reports_job.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/v2/rh_cloud/inventory_controller.rb b/app/controllers/api/v2/rh_cloud/inventory_controller.rb index 9df6c731..a64a4366 100644 --- a/app/controllers/api/v2/rh_cloud/inventory_controller.rb +++ b/app/controllers/api/v2/rh_cloud/inventory_controller.rb @@ -18,10 +18,10 @@ def download_file api :POST, "/organizations/:organization_id/rh_cloud/report", N_("Start report generation") param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request") - param :disconnected, :bool, required: false, desc: N_('Generate the report, but do not upload') + param :disconnected, :bool, required: false, default: false, desc: N_('Generate the report, but do not upload') def generate_report organization_id = params[:organization_id] - disconnected = params[:disconnected] + disconnected = params[:disconnected] || false start_report_generation(organization_id, disconnected) diff --git a/lib/foreman_inventory_upload/async/generate_all_reports_job.rb b/lib/foreman_inventory_upload/async/generate_all_reports_job.rb index 61d202a6..ba71fb93 100644 --- a/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +++ b/lib/foreman_inventory_upload/async/generate_all_reports_job.rb @@ -20,7 +20,8 @@ def plan total_hosts = ForemanInventoryUpload::Generators::Queries.for_org(organization.id, use_batches: false).count if total_hosts <= ForemanInventoryUpload.max_org_size - plan_generate_report(ForemanInventoryUpload.generated_reports_folder, organization) + disconnected = false + plan_generate_report(ForemanInventoryUpload.generated_reports_folder, organization, disconnected) else logger.info("Skipping automatic uploads for organization #{organization.name}, too many hosts (#{total_hosts}/#{ForemanInventoryUpload.max_org_size})") end