Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Container on WSL2 not returning all the correct mount points #867

Open
zhyph opened this issue Nov 14, 2023 · 1 comment
Open

Docker Container on WSL2 not returning all the correct mount points #867

zhyph opened this issue Nov 14, 2023 · 1 comment

Comments

@zhyph
Copy link

zhyph commented Nov 14, 2023

Describe the bug
Hello, I'm using the homepage dashboard on a docker container in WSL2, and on his repo he uses your package to identify disks and their sizes (among other things, but this is where I'm having a problem), and when mounting my disks through the docker compose yml and expecting them to return on his API usually only one of them returns, and it's random too, not sure how or why, that's what I'm trying to figure it out.

To Reproduce
Steps to reproduce the behavior:

  1. In a WSL2 instance with Ubuntu (22.04.3), create a docker-compose similar to this:
version: "3.3"
services:
  homepage:
    image: ghcr.io/gethomepage/homepage:latest
    container_name: homepage
    environment:
      PUID: 1000
      PGID: 1000
    ports:
      - 3000:3000
    volumes:
    # My windows volumes, I have three disks, so I map them as followed:
      - /mnt/c:/mnt/c
      - /mnt/d:/mnt/d
      - /mnt/e:/mnt/e
      - /config/location:/app/config # Make sure your local config directory exists
    restart: always

And now, after running docker compose up -d (or just up) check the config location, there should be a widgets.yml, you can place there the mount points that were specified in the compose file, like so:

- resources:
    label: Windows Disks
    expanded: true
    disk:
      - /mnt/c
      - /mnt/d
      - /mnt/e

Restart the homepage container and now there should be your 3 disks at the top, showing the wrong information.
2. code snippet:
This is where his API processes the requests from the front-end, his code
3. start app / code:
You can run his code locally, but the problem here is just the container while in a WSL2 instance
4. See output/error '....'
No errors just incorrect return.

Current Output
I'll be adding the npx systeminformation info and some extra context down below.

Expected behavior
Expected that the package returned all mount points.

Environment (please complete the following information):

  • systeminformation package version: 5.17.12
  • OS: Windows - WSL2 - Ubuntu 22.04.3
  • Hardware:
    CPU: i5-11400
    RAM: 8GB 3200
    GPU: 4060Ti 8GB
    Disks: 2 SSDs, 1 HDD

To get all needed environment information, please run the following command:

~ # npx systeminformation info
┌─────────────────────────────────────────────────────────────────────────────────────────┐
│  SYSTEMINFORMATION                                                     Version: 5.21.17 │
└─────────────────────────────────────────────────────────────────────────────────────────┘

Operating System:
──────────────────────────────────────────────────────────────────────────────────────────
Platform         : linux
Distro           : Alpine Linux
Release          : 3.18.4
Codename         : 
Kernel           : 5.15.90.1-microsoft-standard-WSL2
Arch             : x64
Hostname         : 6c85ba4339cf
Codepage         : UTF-8
Build            : 

System:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer     : Microsoft
Model            : Docker Container
Version          : 2
Virtual          : true

CPU:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer     : Intel
Brand            : Gen Intel® Core™ i5-11400
Family           : 
Model            : 
Stepping         : 
Speed            : 2.6
Cores            : 12
PhysicalCores    : 12
PerformanceCores : 12
EfficiencyCores  : 
Processors       : 1
Socket           :

Additional context
I created just a small snippet with the following code, so I can return the disks, like he does on his API.

// test.js
const si = require('systeminformation')

const test = async () => {
const fsSize = await si.fsSize();
console.log(fsSize)
}

test()
  /app # node test.js 
[
  {
    fs: 'overlay',
    type: 'overlay',
    size: 1081101176832,
    used: 11360079872,
    available: 1014748741632,
    use: 1.11,
    mount: '/',
    rw: false
  },
  {
    fs: 'drvfs',
    type: '9p',
    size: 1999619747840,
    used: 1339534852096,
    available: 660084895744,
    use: 66.99,
    mount: '/mnt/c', # The only disk to return
    rw: false
  },
  {
    fs: '/dev/sdc',
    type: 'ext4',
    size: 1081101176832,
    used: 5329620992,
    available: 1020779200512,
    use: 0.52,
    mount: '/app/config',
    rw: true
  },
  {
    fs: '/dev/sde',
    type: 'ext4',
    size: 1081101176832,
    used: 11360079872,
    available: 1014748741632,
    use: 1.11,
    mount: '/etc/resolv.conf',
    rw: true
  }
]
/app # ls /mnt
c  d  e
/app # df -h
Filesystem                Size      Used Available Use% Mounted on
overlay                1006.9G     10.6G    945.1G   1% /
tmpfs                    64.0M         0     64.0M   0% /dev
tmpfs                   953.1M         0    953.1M   0% /sys/fs/cgroup
shm                      64.0M         0     64.0M   0% /dev/shm
drvfs                     1.8T      1.2T    611.4G  67% /mnt/c
drvfs                   111.8G    110.6G      1.2G  99% /mnt/d
drvfs                   931.5G    920.7G     10.8G  99% /mnt/e
/dev/sdc               1006.9G      5.0G    950.7G   1% /app/config
/dev/sde               1006.9G     10.6G    945.1G   1% /etc/resolv.conf
/dev/sde               1006.9G     10.6G    945.1G   1% /etc/hostname
/dev/sde               1006.9G     10.6G    945.1G   1% /etc/hosts
tmpfs                   953.1M         0    953.1M   0% /proc/acpi
tmpfs                    64.0M         0     64.0M   0% /proc/kcore
tmpfs                    64.0M         0     64.0M   0% /proc/keys
tmpfs                    64.0M         0     64.0M   0% /proc/timer_list
tmpfs                   953.1M         0    953.1M   0% /sys/firmware
/app # df /mnt/c -h
Filesystem                Size      Used Available Use% Mounted on
drvfs                     1.8T      1.2T    614.7G  67% /mnt/c
/app # df /mnt/d -h
Filesystem                Size      Used Available Use% Mounted on
drvfs                   111.8G    110.6G      1.2G  99% /mnt/d
/app # df /mnt/e -h
Filesystem                Size      Used Available Use% Mounted on
drvfs                   931.5G    920.7G     10.8G  99% /mnt/e

As you can see, when running fsSize(), only one of the disks that were mounted on my docker container returns.
And if you want to you can use the API directly, by doing something like this:
http://localhost:3000/api/widgets/resources?type=disk&target=/disks/e

@Crec0
Copy link

Crec0 commented Mar 3, 2024

Hey, I was having similar issue where the fsSize wouldn't return the expected mountpoints. It also was seemingly random as sometimes it will correct points, while other times it wouldn't. So I decided to investigate and found the culprit to be this if statement right here https://github.com/sebhildebrandt/systeminformation/blob/master/lib/filesystem.js#L99.
Because the order of lines from df command isn't as reliable, if you end up in a situation where a same type and fs but different mount point, it would be filtered out here.

Random order can be observed in these screenshots taken before and after rerunning container
My desired mount point /mnt/root/home was missing from the fsSize output in first scenario but was present in second.


Please lemme know if you want me to PR a fix by removing the said check or by adding a mount point equality as well.

Crec0 added a commit to Crec0/docker that referenced this issue Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants