Skip to content

fs/zfs: fall back to VFS when zfs stats are unavailable#3918

Merged
dims merged 1 commit into
google:masterfrom
locker95:fix/zfs-unprivileged-fallback
Jul 20, 2026
Merged

fs/zfs: fall back to VFS when zfs stats are unavailable#3918
dims merged 1 commit into
google:masterfrom
locker95:fix/zfs-unprivileged-fallback

Conversation

@locker95

Copy link
Copy Markdown
Contributor

Description

Unprivileged containers (e.g. LXC) with a ZFS root often still have /dev/zfs, but the process cannot use the zfs module. After the filesystem plugin migration (#3794), cAdvisor selected the ZFS plugin whenever the device node existed and returned an error from GetZfsStats instead of falling back to VFS. That leaves kubelet without rootfs capacity (cannot find filesystem info for device "zfs/...").

This restores the practical pre-migration behavior for those hosts:

  • If /dev/zfs is missing or unusable, fall back to VFS via ErrFallbackToVFS
  • If zfs list fails for any reason (including EPERM), fall back to VFS as well

Privileged hosts with working ZFS continue to use native zfs stats.

Related Issue

Fixes #3904

Testing Done

cd lib && go test ./fs/zfs/ -count=1 -v
  • TestGetStatsFallsBackWhenDevMissing
  • TestGetStatsFallsBackOnZfsError (simulates EPERM after device present)
  • TestGetStatsSuccess
  • existing TestParseZfsListUsage

After the filesystem plugin migration, ZFS was selected whenever /dev/zfs
existed. Unprivileged containers often still have that device node but
cannot talk to the zfs module (EPERM), so GetStats failed and kubelet
lost rootfs capacity data.

Treat missing/unusable /dev/zfs and any zfs list failure as
ErrFallbackToVFS so capacity is still reported via statfs, matching the
pre-migration practical behavior on unprivileged hosts.

Fixes google#3904

Signed-off-by: Dean Chen <862469039@qq.com>
@google-cla

google-cla Bot commented Jul 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@locker95

Copy link
Copy Markdown
Contributor Author

cla: yes

@locker95

Copy link
Copy Markdown
Contributor Author

I have signed the Google CLA with this GitHub account (locker95) and authorized email 862469039@qq.com.

cla: yes

Please recheck.

@dims
dims force-pushed the fix/zfs-unprivileged-fallback branch from 162191e to b8a8e3a Compare July 20, 2026 21:08
@dims
dims merged commit 0e107a3 into google:master Jul 20, 2026
29 checks passed
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.

zfsPlugin.GetStats does not work in unprivileged containers

2 participants