maidsafe / safe_network

66 stars 40 forks source link

node-launcher gets available disk space wrong on Linux ... sometimes #1888

Closed ptvirgo closed 1 month ago

ptvirgo commented 1 month ago

Screenshot_20240614_073630

That's a screenshot from a vanilla Raspberry PI, with 54 Gigs on the root partition.

Filesystem               Size  Used Avail Use% Mounted on
tmpfs                    6.3G  2.2M  6.3G   1% /run
/dev/mapper/vgmint-root  1.8T  523G  1.2T  31% /
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                    5.0M  4.0K  5.0M   1% /run/lock
/dev/nvme0n1p2           1.7G  419M  1.1G  28% /boot
/dev/nvme0n1p1           511M  6.3M  505M   2% /boot/efi
tmpfs                    6.3G  1.7M  6.3G   1% /run/user/1000

I'm not specifically familiar with Rust, so it's possible I'm way off, but it looks like manage_nodes.rs has a function get_available_disk_space_b that looks at every disk and, on a Unix system, returns the first one with a name that starts with '/'.

If that's true, it's only going to get hit the root path if the iterator happens to hit the desired path first, because all normal mount-points on Linux match the "starts with '/'" criteria. Based on the output I'm guessing that in the case of the vanilla RPI image, it hit the boot partition first and that's how it came up with 1GB.

Best guess is that you could fix that by determining available space from the actual location of the node data.

RolandSherwin commented 1 month ago

Hey @ptvirgo ! Thank you for the detailed bug report. I think this PR https://github.com/maidsafe/safe_network/pull/1925 should fix the above issue. Instead of using starts with / , we now use ends with /. This would return true only if mount point is / and not if they're say /run or /run/