Repository navigation
fix(storage): a df that cannot read one mount no longer stops the service - #30
Merged
Merged
Conversation
…vice GET /v1/storage reads the system disk from df -kPT, and a non-zero exit of df was log.Fatal. df exits 1 whenever one mount cannot be read (a dead network or FUSE mount) while it still lists the others: the service stopped on every call, the gateway answered 502, and the Storage tab and the dashboard's storage card came up empty. The output is now read whatever the exit code; only a df that prints nothing is an error.
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.
Reported in ReCasaOS/CasaOS#67 (comment 6805495048): after an update, every
GET /v1/storage?system=showanswers 502, the Storage tab reads "No standalone storage is available" and the dashboard's storage card falls back to the system drive and the USB disks. The ZFS routes of the same service answer.Cause.
GetStorageListreads the system disk fromdf -kPT, andGetSystemDfcalledlog.Fatalon any error from it.dfexits 1 whenever one mount cannot be read (a dead network or FUSE mount: "Transport endpoint is not connected", "Permission denied") and still lists every other one.log.Fatalis not a panic, so Echo's Recover middleware does not catch it: the whole service exits, systemd starts it again, and the gateway gets a closed connection, hence 502 on that route only.GetStorageListis the only caller.Fix. The output is read whatever the exit code; only a
dfthat prints nothing is an error, whichGetStorageListalready handles (no system path, the list is built without it).Proof. Two tests put a fake
dfon the PATH: one exits 1 after printing the root line and a line on stderr, and must still give that line; one prints nothing and must be an error. Run on Linux (WSL). Not looked at: the reporter's box itself. Whether theirdfreally exits 1 is to be confirmed (asked in the issue).