Fixes #39088 - Search generated_reports for report file paths#1165
Merged
chris1984 merged 1 commit intotheforeman:foreman_3_18from Mar 4, 2026
Merged
Fixes #39088 - Search generated_reports for report file paths#1165chris1984 merged 1 commit intotheforeman:foreman_3_18from
chris1984 merged 1 commit intotheforeman:foreman_3_18from
Conversation
…and dev setup (theforeman#1155) * Improve report file paths and dev environment setup Updates report_file_paths to search in priority order (done, uploads, generated) ensuring downloads return the most recent report. Also fixes base_folder to use parent directory in dev environments, keeping generated files outside the Foreman repo directory. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Add documentation for report_file_paths search order Explains the file lifecycle through generated → uploads → done folders and why the search order prioritizes newest files first. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Reviewer's GuideAdjusts Foreman inventory report file discovery to search a new generated_reports directory with correct priority, introduces a helper for generated report paths, and fixes the base folder resolution for development vs production environments. Class diagram for ForemanInventoryUpload changesclassDiagram
class ForemanInventoryUpload {
<<module>>
+base_folder() String
+done_folder() String
+uploads_folder() String
+generated_reports_folder() String
+outputs_folder() String
+facts_archive_name(organization_id) String
+uploads_file_path(filename) String
+done_file_path(filename) String
+generated_reports_file_path(filename) String
+report_file_paths(organization_id) Array~String~
}
ForemanInventoryUpload : base_folder uses Dir.glob
ForemanInventoryUpload : base_folder uses File.dirname
ForemanInventoryUpload : generated_reports_file_path builds path under generated_reports_folder
ForemanInventoryUpload : report_file_paths searches generated_reports, uploads, done in order
Flow diagram for report_file_paths search orderflowchart TD
A["Start report_file_paths"] --> B["Compute filename = facts_archive_name(organization_id)"]
B --> C["Build path_generated = generated_reports_file_path(filename)"]
C --> D["Build path_uploads = uploads_file_path(filename)"]
D --> E["Build path_done = done_file_path(filename)"]
E --> F["Return Dir[ path_generated, path_uploads, path_done ]"]
Flow diagram for base_folder resolution in prod vs devflowchart TD
A["Start base_folder"] --> B["Search selinux_path = Dir.glob(/var/lib/foreman).first"]
B --> C{"selinux_path found?"}
C -- Yes --> D["base_root = selinux_path"]
C -- No --> E["base_root = File.dirname(Dir.getwd)"]
D --> F["base_folder = File.join(base_root, red_hat_inventory/)"]
E --> F
F --> G["Return base_folder"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
chris1984
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of #1155 to foreman_3_18 branch.
Changes
report_file_pathsto search for reports in priority order: generated_reports → uploads → donegenerated_reports_file_pathhelper methodbase_folderto use parent directory in dev environmentsOriginal PR
#1155
Summary by Sourcery
Search inventory report files in all expected locations and correct the base directory used in development environments.
Bug Fixes:
Enhancements: