Repository navigation
Reduce risk of an interrupted installation leading to a partial installation - #2261
Conversation
b40cdc9 to
3d4e033
Compare
d472e48 to
6b19e24
Compare
Gankra
left a comment
There was a problem hiding this comment.
The overall approach makes total sense to me, good call.
| for _bin_name in $_bins; do | ||
| ensure mv "$_install_temp/$_bin_name" "$_install_dir" | ||
| for _dest in $(aliases_for_binary "$_bin_name" "$_arch"); do | ||
| ln -sf "$_install_dir/$_bin_name" "$_install_dir/$_dest" | ||
| done |
There was a problem hiding this comment.
Indentation here got doubled compared to the rest of the file
| ensure mkdir -p "$_install_dir" | ||
| ensure mkdir -p "$_lib_install_dir" | ||
| _install_temp=$(mktemp -d "$_install_dir/tmp.XXXXXXXXXX") | ||
| _lib_install_temp=$(mktemp -d "$_lib_install_dir/tmp.XXXXXXXXXX") |
There was a problem hiding this comment.
It's a bit unfortunate that we unconditionally do this, even in the common case (all of astral) where there's no libs to install.
There was a problem hiding this comment.
There's quite a lot of unconditional stuff which isn't needed for our stuff. I was thinking of contributing something to clear that up. Do you want me to add a commit which removes the lib stuff when there are no libs? It shouldn't be difficult, except for the tests - I wouldn't know where to start with those...
| _test_blake2s="$(printf "can do blake2s" | b2sum -a blake2s | awk '{printf $1}')" || _test_blake2s="" | ||
|
|
||
| if [ "X$_test_blake2s" = "X$_well_known_blake2s_checksum" ]; then | ||
| if [ "$_test_blake2s" = "$_well_known_blake2s_checksum" ]; then |
There was a problem hiding this comment.
Heh, I added a shellcheck ignore in my PR because I didn't want to think about if this is indeed safe to drop on all our supported platforms (if you have a strong sense I'm happy to land this).
There was a problem hiding this comment.
The most recent shell which fixed the bug that this tries to work around is zsh which I don't think anyone uses as their /bin/sh implementation (mac uses bash for it). They fixed in 2015.
Dash fixed it in 2008 and bash fixed in 1995.
That being said, now that I've given this a second glance, I think there's a trivial way to make it so it doesn't matter. We can just swap the arguments and put "_well_known_blake2s_checksum" first. That is controlled by the generator so it won't start with a leading - (assuming it continues to be a blake2 hash).
This triggers recent shellcheck and isn't necessary when targetting posix shell. See https://www.shellcheck.net/wiki/SC2268 .
This defers moving the new files until after they're definitely on the same filesystem as the target directory to reduce the window during which an interrupted installation could cause a partial update.
|
I couldn't figure out how to run the |
6b19e24 to
42c1dce
Compare
|
Yeah I discovered this week that the basic test is subject to some unfortunate bitrot, the only way to run it is to install exactly this copy of omnibor: (I should rip out the omnibor stuff if it doesn't even work...) |
|
I was checking GitHub and it looks like at least one project out there is using the omnibor support. It's unfortunate they changed the CLI options in a backwards-incompatible way; makes it harder for us to support older and newer versions. |
Since the installer script uses
mktemp -dto create a directory to store the downloaded release and extract it, the files might end up on a different filesystem than the target installation directory. This means that themvbasically turns into acpfollowed by anrmwhich means that if it gets interrupted at this point, the result could be a partially written file, or just in general an installation with only some of the files written.There's no real way to solve this without support from the filesystem, so instead this PR aims to reduce the window in these cases by first using
mvto copy/move the files into a subdirectory of the target and thenmvthe files out. The second round ofmvshould just berenameunder the hood so this should happen quickly. As an additional side effect, while you might end up with a partial upgrade, you will never end up with a partially written binary.Also, since the temporary directory creation was successful, this means that the final round of
mvis likely to also be successful as both require the same permissions to the parent directory.