-
Notifications
You must be signed in to change notification settings - Fork 603
Update Precacher to No Longer Fatally Error by Default #14013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tal version update precacher for non-fatal error mode turn on non-fatal precacher by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a non-fatal mode for the precacher so that failures are logged without aborting the build by default.
- Add a
--non-fatal-modeflag and update error handlers inprecacher.go - Change download errors to warn and continue, resetting errors for summary generation
- Update
precache.mkandMakefileto enable non-fatal mode by default
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| toolkit/tools/precacher/precacher.go | Add nonFatalMode flag and adjust error handling to optionally log errors instead of exiting |
| toolkit/scripts/precache.mk | Pass --non-fatal-mode flag based on PRECACHER_NON_FATAL |
| toolkit/Makefile | Set PRECACHER_NON_FATAL to y by default for non-fatal behavior |
Comments suppressed due to low confidence (1)
toolkit/tools/precacher/precacher.go:65
- [nitpick] Non-fatal mode behavior isn't covered by existing tests. Consider adding unit or integration tests to verify that errors are logged and the tool exits successfully when
PRECACHER_NON_FATALis enabled, and exits with non-zero when disabled.
nonFatalMode = app.Flag("non-fatal-mode", "Run in non-fatal mode, where errors are logged but do not cause the program to exit with a non-zero code.").Bool()
| logger.Log.Warnf("Package download failed") | ||
| logger.Log.Warnf("Missing package download failed: %s", err) | ||
| // reset the error to nil so we can still write the summary file | ||
| // packages which are not able to be downloaded are not considered a failure of the tool, just a failure to download some packages | ||
| err = nil |
Copilot
AI
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downloadMissingPackages error handling unconditionally resets err to nil, ignoring nonFatalMode. In fatal mode, download failures should cause the program to exit, but currently they always result in a warning. Wrap this block in a nonFatalMode check similar to other error handlers.
| logger.Log.Warnf("Package download failed") | |
| logger.Log.Warnf("Missing package download failed: %s", err) | |
| // reset the error to nil so we can still write the summary file | |
| // packages which are not able to be downloaded are not considered a failure of the tool, just a failure to download some packages | |
| err = nil | |
| if *nonFatalMode { | |
| logger.Log.Warnf("Package download failed") | |
| logger.Log.Warnf("Missing package download failed: %s", err) | |
| // reset the error to nil so we can still write the summary file | |
| // packages which are not able to be downloaded are not considered a failure of the tool, just a failure to download some packages | |
| err = nil | |
| } else { | |
| logger.FatalOnError(err) | |
| } |
| rpmSnapshot, err := rpmSnapshotFromFile(*snapshot) | ||
| if err != nil { | ||
| logger.PanicOnError(err) | ||
| if *nonFatalMode { |
Copilot
AI
Jun 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The non-fatal error handling logic is duplicated in multiple places. Consider extracting a helper function (e.g., handleError(err)) to reduce duplication and improve maintainability.
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-staticsubpackages, etc.) have had theirReleasetag incremented../cgmanifest.json,./toolkit/scripts/toolchain/cgmanifest.json,.github/workflows/cgmanifest.json)./LICENSES-AND-NOTICES/SPECS/data/licenses.json,./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md,./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)*.signatures.jsonfilessudo make go-tidy-allandsudo make go-test-coveragepassSummary
What does the PR accomplish, why was it needed?
The precacher is not required for a build to complete, even if enabled. This change allows the precacher to fail without causing the build to fail in tandem.
The precacher should not be blocking builds which it is enabled for.
Change Log
PRECACHER_NON_FATALset toyby defaultPRECACHER_NON_FATALto maintain current precacher behaviorDoes this affect the toolchain?
NO
Test Methodology
sudo make build-packages REBUILD_TOOLCHAIN=n REBUILD_TOOLS=y SRPM_PACK_LIST=words PACKAGE_REBUILD_LIST=words -j100 PRECACHE=ysudo make build-packages REBUILD_TOOLCHAIN=n REBUILD_TOOLS=y SRPM_PACK_LIST=words PACKAGE_REBUILD_LIST=words -j100 PRECACHE=y PRECACHER_NON_FATAL=n