-
Notifications
You must be signed in to change notification settings - Fork 128
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
fix: clean up logic around config.toml handling #1222
Conversation
1131462
to
875880a
Compare
echo "Using the ${CONFIG_TOML_FILE} file found in the repository root!" | ||
else | ||
echo "No ${CONFIG_TOML_FILE} file found in the repository. Set params.${CONFIG_TOML_FILE}_FILE to a valid config.toml file." | ||
exit 1 |
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.
This will make it impossible for the task to run if there is no file regardless as to whether the parameter was specified or not. Is that desired?
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.
I think so. Right? Like, what's the behavior of bib if there is literally no config.toml at all?
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.
This is effectively a breaking change. If we want to make it explicit like this then will we have to bump the version?
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.
I don't know if the file is missing, but bib is fine if the file is empty
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.
I'm not interested in introducing a breaking change. I'm just trying to clean it up.
If bib is happy if the file is empty, I'll drop this part.
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.
OK - I revised this to drop the exit 1
and restore the touch
line. (Now I understand what that line was for. I assumed bib would balk at an empty config.toml file.)
if [ -f "/var/workdir/source/${CONFIG_TOML_FILE}" ]; then | ||
echo "Using the ${CONFIG_TOML_FILE} file found in the repository root!" | ||
else | ||
echo "No ${CONFIG_TOML_FILE} file found in the repository. Set params.${CONFIG_TOML_FILE}_FILE to a valid config.toml file." |
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.
echo "No ${CONFIG_TOML_FILE} file found in the repository. Set params.${CONFIG_TOML_FILE}_FILE to a valid config.toml file." | |
echo "No ${CONFIG_TOML_FILE} file found in the repository. Set params.CONFIG_TOML_FILE to a valid config.toml file." |
?
Maybe the PR title doesn't reflect what you want to achieve, but the CONFIG_TOML_FILE is taken into account (at least in our pipeline it seems ok) |
Looking at https://gitlab.com/redhat/rhel-ai/disk-images/nvidia-bootc/-/merge_requests/56, it's not up to date with the current build-definitions main. Maybe the behavior is already fixed? A very nasty bug in the gitlab version is if [! -n "${CONFIG_TOML_FILE}" ]; then This is just a much harder to spot #!/bin/bash
set -e
if [! -n "" ]; then
echo 'true'
else
echo 'false'
fi
|
Signed-off-by: Ralph Bean <[email protected]>
The logic here was pretty confusing. Trying to straighten it out.
Andrew pointed out in code review that it's too specific to claim that it is found in the repository root. It could be in a subdir.
875880a
to
cecd998
Compare
else | ||
echo "No ${CONFIG_TOML_FILE} file found. Using an empty configuration." | ||
touch "/var/workdir/source/${CONFIG_TOML_FILE}" | ||
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.
With the old version of the task, explicitly passing a non-existent CONFIG_TOML_FILE would result in a failure (intentionally) rather than ignoring the problem and creating an empty config.
IMO that's the saner behavior that one would expect from most tools, but there seems to be a natural pull towards creating the empty config instead (both in your and in Andrew's PRs 😄 )
I'm fine with it either way, the log message should make it clear why e.g. a mis-spelled config file path is being ignored
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.
Aha. Now that you say that, I do remember those iterations two weeks back. I think that the reason that both @ralphbean and myself did that is because it enables cleaner/clearer logic.
Once I tried to allow failures when a nonexistent file is specified, the logic became more confusing.
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.
See the table for intended behavior from the prior PR: #1171 (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.
I wouldn't say it enables cleaner logic, it's just a touch easier to make it clean. Can still be clean and behave nicely though
if [ -z "$CONFIG_TOML_FILE" ]; then
CONFIG_TOML_FILE=config.toml
touch "/var/workdir/source/$CONFIG_TOML_FILE"
elif ! [ -f "/var/workdir/source/$CONFIG_TOML_FILE" ]; then
echo "Config file doesn't exist: $CONFIG_TOML_FILE"
exit 1
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.
I fear I've made a mess. I wasn't aware of the conversations you guys had the other week about this and I assumed this section of code was just carelessly written in the first place during fast-hacking to make vm building work in early June, when in reality you guys had really thought it through. The code was written more recently than I knew!
My real goal here was to get https://gitlab.com/redhat/rhel-ai/disk-images/nvidia-bootc/-/commit/3ab9e272069e9469abc2ace36bf11b63a438f456 to happen - and it did.
I'm inclined to drop this PR without merging it, just to let it exist as you guys defined it in #1171 (comment). WDYT?
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.
👍
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.
@ralphbean , @chmeliik 's suggestion above is similar to what you proposed. It still defines the failure criteria and clearly describes why a failure happens instead of falling back to other processes to fail (i.e. rsync). I think this would still be an improvement.
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.
Ack, if we adopt that - we'll need a version bump per this comment, true?
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.
No, If the only failure is a user specifying a file path that does not exist then that is consistent. The breaking change previously is if no file was specified. We would not create an empty file for them.
Hey guys, I'm going to drop this. Focusing on other things. |
No description provided.