Repository navigation
fix(upgrade): roll back on a dangling pid-file symlink, line-clean matrix skip - #1854
Merged
Merged
Conversation
…trix skip Follow-up to #1848 (merged as c0edfa8). `util::open_pid_file` checked a missing pid file through the parent of the configured path, but `O_CREAT` in `util::publish_pid_file` follows a dangling symlink and creates its final target. A link into a missing directory passed the pre-PREPARED check, the upgrade committed, and the post-COMMIT create failed with ENOENT and was only logged. The check now follows the link chain (bounded at MAXSYMLINKS) and tests the final target's parent, still creating nothing. Failures that cannot be detected without creating a file (ENOSPC, quota, an LSM denial) stay logged after COMMIT; the residual risk is documented on `open_pid_file`. The compatibility-matrix skip message was written with an unbuffered `writeln!`, one write(2) per format piece, which libtest's progress output and the parallel case interleaved with. It is now formatted first and written with a single `write_all`, framed by newlines. Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1848 (merged as c0edfa8).
Problem
O_CREATfails withENOENTand is only logged. Before fix(command): retry interrupted blocking reads during main upgrade #1848 this case rolled back.test legacy_sender_survives_option3_candidate_refusal ... skipping option3-to-legacyok: set SOZU_MATRIX...(6 garbled lines in 200 parallel runs).Cause
util::open_pid_file(bin/src/util.rs) opens without create (ENOENTthrough the dangling link), then checksaccess(W_OK|X_OK)on the parent of the configured path.O_CREATinutil::publish_pid_filefollows the link and creates its final target, whose parent may not exist.writeln!on unbuffered stderr issues onewrite(2)per format piece; libtest's progress writes and the parallel case land between them.Fix
NotFoundbranch, follow the symlink chain (symlink_metadata+read_link, relative targets resolved against the link's directory, bounded at 40 likeMAXSYMLINKS,ELOOPpast it) and check the final target's parent. Still creates nothing, so fix(command): retry interrupted blocking reads during main upgrade #1848's no-empty-pid-file guarantee holds.write_allon locked stderr, framed by\nbefore and after. Whether the case runs is unchanged.Contract
Every failure that is deterministic and detectable without creating a file must fail before PREPARED (directory at path, missing parent, EROFS/EACCES, and now a dangling symlink into a missing directory). Failures detectable only by creating a file (
ENOSPC, inode/disk quota, an LSM denial of the create) remain an accepted residual risk: they surface after COMMIT, are logged, and the new main keeps running (systemd still receivesMAINPID=). Documented onopen_pid_file, indoc/upgrade_e2e_tests.mdand in the CHANGELOG.Tests
open_pid_file_rejects_a_dangling_symlink_into_a_missing_directory(red before the fix, green after) andopen_pid_file_follows_a_dangling_relative_symlink_to_its_target(a creatable link target stays accepted, nothing created until publish).dangling_pid_file_symlink_rolls_back_main_upgrade_and_keeps_servinginupgrade_pid_file_failure_e2e(shares the existing harness viaassert_upgrade_rolls_back). Red before the fix:a main upgrade that cannot write its pid file must fail; status=ExitStatus(unix_wait_status(0)), stdout="... Success: Upgrade successful ...". CI already runs the whole file with--test upgrade_pid_file_failure_e2e -- --ignored.Validation (
--no-default-features --features crypto-ring,opentelemetry,splice,simd):cargo test -p sozu -p sozu-command-lib,cargo test -p sozu -- --ignored --test-threads=1(all process tests pass),cargo clippy -p sozu -p sozu-command-lib --all-targets -- -D warnings,cargo +nightly fmt --all --check,check_doc_citations.py --base origin/main.