8000 fix: show NFS/SMB mounts in disk monitor and default update check off (#995, #986) by XXingmfy · Pull Request #1001 · t8y2/motty · GitHub
[go: up one dir, main page]

Skip to content

fix: show NFS/SMB mounts in disk monitor and default update check off (#995, #986) - #1001

Open
XXingmfy wants to merge 1 commit into
t8y2:mainfrom
XXingmfy:fix/995-986-network-mounts-update-default
Open

XXingmfy wants to merge 1 commit into
t8y2:mainfrom
XXingmfy:fix/995-986-network-mounts-update-default

Conversation

@XXingmfy
Copy link
Copy Markdown
Contributor

Summary

Two self-contained bug fixes, each with regression tests. Both are pure Go logic (no UI/platform dependency) and were verified against a local build.

#995 - disk monitor hid NFS/SMB network volumes

The Linux remote probe enumerated disks with df -Pk -l. The -l/--local flag excludes every network filesystem (nfs/nfs4/cifs/smb), so NAS data volumes such as /data1-/data5 never reached the monitor, while virtual mounts filled the list.

  • Enumerate with df -Pk so network mounts are included.
  • Bound the listing with imeout 2 when coreutils imeout is present, so a single stale network mount cannot stall the whole sample (df lines already emitted are still parsed).
  • Virtual-filesystem detection is unchanged; the UI already de-prioritises �irtual disks behind "more".
  • Tests: TestDetailsCommandListsNetworkFilesystems (guards against re-adding -l, requires the timeout guard) and TestDetailsKeepsANetworkMount (NFS + space-containing mount point parse as real, non-virtual disks).

Files: internal/remotestats/details.go, internal/remotestats/details_test.go

#986 - automatic update check defaulted on while docs promise off

README (en/zh/ja) and the website state the update check is off by default, but the code read UpdateCheck != "off", so an empty/absent value (update_check,omitempty) counted as on - including for users upgrading who never opted in.

  • Read the saved value as on only when explicitly "on", in both the startup toggle (
    estoreSFTPSettings) and the diagnostics report.
  • Tests: the previous "on by default" test is replaced by TestTheAutoCheckIsOffByDefaultAndRunsWhenTurnedOn (fresh profile = off + no timer; turning it on runs a check; turning it off persists), and TestTheAutoCheckAsksAgainAfterItsInterval enables the toggle explicitly.

Files: internal/workbench/sftp_extra.go, internal/workbench/diagnostics.go, internal/workbench/launch_test.go

Note: #986 also mentions the update endpoint hitting dl.motty.page before GitHub Releases. That is a deliberate mirror/architecture choice and is left unchanged; this PR only aligns the default on/off behaviour with the documented promise.

Testing

  • go build ./cmd/motty succeeds.
  • go vet ./internal/remotestats ./internal/workbench passes.
  • go test ./internal/remotestats/ passes.
  • Affected internal/workbench subset (About/Settings/Diagnostic/Persist/Update/AutoCheck) passes.

(The full ~3200-test internal/workbench package exceeds the default 10-minute Go test timeout on a local Windows/sqlite machine; recommendation is to let CI run the complete suite.)

…eck off (t8y2#995, t8y2#986)

- remotestats: df -Pk -l hid NFS/SMB/CIFS volumes from the disk monitor on
  Linux hosts. Enumerate with df -Pk so network data volumes appear, bound it
  with timeout(2) when available so one stale mount cannot stall the sample, and
  add regression tests (t8y2#995).
- workbench: the automatic update check defaulted to on while README and the
  website promi
10BC8
se it is off ("Nothing phones home"). Read the saved value as on
  only when explicitly set, in both the startup toggle and the diagnostics
  report, and update the tests (t8y2#986).
@t8y2 t8y2 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the NFS/SMB work. Two things need to change before this merges:

  1. The stale-mount problem (internal/remotestats/details.go:149): timeout 2 df -Pk cannot end a df blocked on a hung NFS/CIFS mount. The 4s deadline then drops the whole details sample every refresh, and each sample leaves a stuck df on the host. Please enumerate mounts from /proc/self/mountinfo without I/O, and keep statfs of network mounts out of the main sample (its own cadence, or skip a mount whose last probe hung).
  2. Please drop the change of the automatic update check default to off. That default is not accepted; the rest of this PR can stay.

Also, TestDetailsKeepsANetworkMount feeds a fixture into parseDetails and passes even with -l in place, so it does not guard this behavior. A Linux test that runs detailsCommand with a fake df on PATH would.

@t8y2 t8y2 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, and the update-check default matches the README. One blocker in the disk monitor change (internal/remotestats/details.go:148): GNU df builds its whole table before printing, so when timeout 2 kills df -Pk on a stale NFS/CIFS mount nothing reaches awk and the monitor loses every disk, local ones included. Before this change -l kept the local disks working. The comment and the PR text saying already-emitted lines are still parsed do not hold.

Please keep df -Pk -l for local disks and add a separate bounded call for network types (timeout 2 df -Pk -t nfs -t nfs4 -t cifs -t smb3 …), merging the rows, so a hung mount only costs the network rows. Please also check older busybox, where timeout 2 may be rejected and the disk list would silently be empty. The tests that assert substrings of the shell script would not catch this; test the merge/parse behaviour instead.

Also, the default-off change only applies to profiles with no saved update_check (persist.go:614 always writes on/off), so existing users stay on; the PR text says otherwise.

@t8y2 t8y2 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! A few things need to change before this can merge:

  1. timeout 2 df -Pk does not keep the already-printed rows parseable: coreutils df stats every mount first and prints the table at the end, so one unreachable NFS mount makes the whole sample lose all disks (including /). With a hard mount, SIGTERM may not even kill df (use timeout -k). A sturdier approach is df -l for local disks so they always show up, then query network mounts (by fstype from /proc/mounts) one at a time, each with its own timeout. Older BusyBox also needs timeout -t 2, otherwise the disk list vanishes entirely there (internal/remotestats/details.go:148).
  2. The two new tests don't cover the real path: one only does strings.Contains on the command, the other feeds an already-processed disk line straight to parseDetails and skips awk. Please test the awk script with real df -P output, including mount points and SMB sources with spaces (//nas/my share). Also len(d.Disks) >= 64 truncates before sorting, so with -l gone NFS volumes can be crowded out by overlay/squashfs entries (details.go:226).
  3. Defaulting update checks to off reverses the deliberate default-on decision in bb3524e, so it needs a maintainer call. Also, users who have saved settings already store "on", so this only affects fresh configs, which differs from the description. Please split it into its own PR with the migration impact spelled out.

The branch also conflicts with main now, so it needs a rebase.

@t8y2 t8y2 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. There are two things to deal with, and the update check half should come out of this PR.

  1. internal/remotestats/details.go:148: with -l removed, timeout 2 df -Pk | awk loses the whole disk list when one network mount hangs. coreutils df stats every mount before it prints anything, so when timeout kills it nothing has been written, and local disks disappear too. That is worse than before, when -l skipped network mounts. timeout also has no -k, so a process stuck in D state may survive. Please keep df -Pk -l so local disks always show, add the network filesystems with a separate bounded call (timeout -k 1 2 df -Pk -t nfs -t nfs4 -t cifs -t smb3), and fall back to -l alone where timeout is missing (BusyBox, macOS, BSD). A test with a fake df that hangs, asserting the local disks still come out within the timeout, would cover it better than the current string checks.
  2. internal/workbench/sftp_extra.go:593: please drop the update check default change from this PR. Automatic checking was made default-on on purpose in bb3524e (an empty update_check means on), and we are keeping that. The README and website saying "off" are out of date and we will fix those ourselves.

The branch also conflicts with main (details_test.go, sftp_extra.go); please rebase after the above.

@t8y2 t8y2 left a comment
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes. The earlier review points still apply to the current head.

  1. timeout 2 df -Pk | awk (details.go:148-150) loses the whole disk table when one NFS/CIFS mount hangs: coreutils df stats every mount before printing, so killing it by timeout yields no output at all, / included, and each sample leaves a stuck df behind. BusyBox needs timeout -t 2, otherwise the list is empty. The "rows already printed are still parsed" claim does not hold. Keep df -Pk -l, fetch network mounts separately with timeout -k 1 2 df -Pk -t nfs -t nfs4 -t cifs -t smb3 and merge, or enumerate from /proc/self/mountinfo.

  2. Switching the update check default to off (sftp_extra.go:593, diagnostics.go:144) was already declined by the maintainer (bb3524e keeps it on deliberately). Please drop it from this PR.

  3. TestDetailsKeepsANetworkMount feeds an already processed disk line to parseDetails, so it passes with -l still in place. Put a fake df (including one that hangs) on PATH and assert the local disks still appear in time, using real df -P output with spaces in mount points and //nas/my share for the awk.

  4. The len(d.Disks) >= 64 truncation happens before sorting, so overlay/squashfs entries may push NFS volumes out once -l is gone.

The branch also conflicts with main (details_test.go, sftp_extra.go); please rebase.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0