fix(swap): never release the fallback swap during a failed rollback; release 0.3.0 [P0]
The rollback claimed an invariant in its own comment - restore the original, confirm it,
and only then release staging - and did not enforce it. original_back was computed and then
ignored: the staging swapoff ran unconditionally.
The failure path that mattered: staging is active, the original is already off, reactivating
the original fails (swapon can fail under the memory pressure that made the resize
necessary), and the rollback then switched off the staging swap - the last thing carrying
load. Recovering from a failed resize left the host with no swap at all, which is worse
than the failure being recovered from.
original_back now gates the release. If the original cannot be brought back the rollback
returns early with the staging swap still active, and the error carries the two commands
that finish the job by hand. An extra temporary swap is always the better end state than
none. The staging file is also only unlinked once swapoff has actually succeeded - an
active swapfile cannot be removed, and attempting it produced an error that explained
nothing.
Asserting this needs a seam, because the invariant is a sequence of calls rather than a
value: a small SwapCommands trait covers swapon/swapoff, with the real implementation
behind it. Three tests: the original cannot be restored and swapoff is never called with
the message naming the preserved fallback; the original comes back and staging is released
in that order; nothing was taken down so nothing is touched.
Also from the same audit:
- StaleOwnership advice was wrong. It suggested deleting the ownership record, which turns
the file Foreign - refused just as firmly. The message now distinguishes the two cases: a
leftover .previous next to the swapfile is the signature of a replacement killed between
installing the new file and recording its identity, so the error says nothing is lost,
points at the intact previous swapfile, and gives the exact commands for going back or
keeping the new file. Full automatic crash recovery is deliberately not added here - it
needs a transition journal, and that belongs with the Debian acceptance work.
- The acceptance checklist still described the PID-file lock ("re-acquires by the absence
of /proc/<pid>"), which stopped being true when locking moved to flock. The kernel
releases it on process exit, and the leftover file means nothing.
- shellcheck was installed by --prepare-build-env but never run. It now runs in
prepare_build_gate: the script installs systemd units and writes to /usr/sbin, so it is
part of the release surface.
- The skip message for systemd-analyze verify now says what the check actually is - a
post-install gate, expected to be skipped on a clean builder - rather than reading like a
build gate that silently did not run.
One audit item did not reproduce: there is no duplicated -j in antitorrent_drop_counter,
the flag appears once.
Version raised to 0.3.0 in traffic_core/Cargo.toml, with the packaging examples in README
and INSTALLATION updated to match. The reboot scheduler keeps its own 0.2.0.
cargo fmt --check, clippy -D warnings, cargo test --locked --workspace --release: 191 + 4
passed. build.sh not syntax-checked here - no bash on this host; the shellcheck gate now
covers it on the builder.
This commit is contained in:
@@ -188,10 +188,10 @@ Security note:
|
||||
```bash
|
||||
cd awg2_harness
|
||||
./tools/build.sh --prepare-build-env --bootstrap-rust --yes
|
||||
./tools/build.sh --package --version 0.1.6
|
||||
./tools/build.sh --package --version 0.3.0
|
||||
(cd dist && sha256sum -c SHA256SUMS)
|
||||
dpkg-deb -I dist/awg2-harness_0.1.6_amd64.deb
|
||||
dpkg-deb -c dist/awg2-harness_0.1.6_amd64.deb | sort
|
||||
dpkg-deb -I dist/awg2-harness_0.3.0_amd64.deb
|
||||
dpkg-deb -c dist/awg2-harness_0.3.0_amd64.deb | sort
|
||||
```
|
||||
|
||||
`--version` можно не указывать, если версия в `traffic_core/Cargo.toml` уже соответствует release. Если version override указан, он меняет версию Debian-пакета, а не версию crate в `Cargo.toml`.
|
||||
@@ -224,7 +224,7 @@ scp -P 2323 dist/SHA256SUMS root@<server-ip>:/root/
|
||||
```bash
|
||||
cd /root
|
||||
sha256sum -c SHA256SUMS
|
||||
chmod 644 /root/awg2-harness_0.1.6_amd64.deb
|
||||
chmod 644 /root/awg2-harness_0.3.0_amd64.deb
|
||||
apt install ./awg2-harness_*_amd64.deb
|
||||
install -d -m 0755 /etc/awg2-harness
|
||||
install -m 0644 /root/awg2-harness.config.toml /etc/awg2-harness/config.toml
|
||||
@@ -237,7 +237,7 @@ install -m 0644 /root/awg2-harness.config.toml /etc/awg2-harness/config.toml
|
||||
```bash
|
||||
cd /root
|
||||
sha256sum -c SHA256SUMS
|
||||
chmod 644 /root/awg2-harness_0.1.6_amd64.deb
|
||||
chmod 644 /root/awg2-harness_0.3.0_amd64.deb
|
||||
apt install ./awg2-harness_*_amd64.deb
|
||||
install -d -m 0755 /etc/awg2-harness
|
||||
cp /usr/share/doc/awg2-harness/repo/config.example.toml /etc/awg2-harness/config.toml
|
||||
|
||||
Reference in New Issue
Block a user