-
Notifications
You must be signed in to change notification settings - Fork 183
cmd-build-with-buildah: add change detection #4323
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
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.
Code Review
This pull request introduces change detection to skip re-importing builds if the inputs haven't changed, which is a great optimization. However, I've identified two high-severity issues with the current implementation. One can cause the script to fail in a clean environment where no previous builds exist. The other involves faulty comparison logic that could lead to incorrectly skipping a build import. I've provided code suggestions to address both of these problems.
21fd215 to
a4080a2
Compare
Use the new inputhash label to tell if there was a meaningful change since the previous build. If not, just no-op. Unless `--force` is passed. See also: coreos/fedora-coreos-config#3758
a4080a2 to
407a23c
Compare
| if [ -z "$FORCE" ]; then | ||
| skip_import=1 | ||
| else | ||
| echo "Importing new build anyway (--force)" | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "${skip_import:-}" ]; then | ||
| /usr/lib/coreos-assembler/cmd-import "${final_ref}" ${SKIP_PRUNE:+--skip-prune} | ||
| fi |
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.
Could this be written more succinctly?
if [ -n "$FORCE" ]; then
echo "Importing new build anyway (--force)"
/usr/lib/coreos-assembler/cmd-import "${final_ref}" ${SKIP_PRUNE:+--skip-prune}
fi
fi
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.
We still need to import if hashes don't match.
dustymabe
left a comment
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.
LGTM
Use the new inputhash label to tell if there was a meaningful change since the previous build. If not, just no-op. Unless
--forceis passed.See also: coreos/fedora-coreos-config#3758