-
Notifications
You must be signed in to change notification settings - Fork 580
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
base: 3.0-dev
Are you sure you want to change the base?
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-mode
flag and update error handlers inprecacher.go
- Change download errors to warn and continue, resetting errors for summary generation
- Update
precache.mk
andMakefile
to 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_FATAL
is 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 |
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) | |
} |
Copilot uses AI. Check for mistakes.
@@ -80,11 +81,22 @@ func main() { | |||
|
|||
rpmSnapshot, err := rpmSnapshotFromFile(*snapshot) | |||
if err != nil { | |||
logger.PanicOnError(err) | |||
if *nonFatalMode { |
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.
Copilot uses AI. Check for mistakes.
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-static
subpackages, etc.) have had theirRelease
tag 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.json
filessudo make go-tidy-all
andsudo make go-test-coverage
passSummary
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_FATAL
set toy
by defaultPRECACHER_NON_FATAL
to 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=y
sudo make build-packages REBUILD_TOOLCHAIN=n REBUILD_TOOLS=y SRPM_PACK_LIST=words PACKAGE_REBUILD_LIST=words -j100 PRECACHE=y PRECACHER_NON_FATAL=n