Skip to content

Commit

Permalink
Support nfs FsType in processMounts
Browse files Browse the repository at this point in the history
- Fix kubenetes issue kubernetes/kubernetes#98009
  • Loading branch information
gjkim42 committed Jan 23, 2021
1 parent c09d1ab commit a228e69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
partitions := make(map[string]partition)

supportedFsType := map[string]bool{
// all ext systems are checked through prefix.
// all ext and nfs systems are checked through prefix
// because there are a number of families (e.g., ext3, ext4, nfs3, nfs4...)
"btrfs": true,
"overlay": true,
"tmpfs": true,
Expand All @@ -179,7 +180,8 @@ func processMounts(mounts []*mount.Info, excludedMountpointPrefixes []string) ma
}

for _, mnt := range mounts {
if !strings.HasPrefix(mnt.Fstype, "ext") && !supportedFsType[mnt.Fstype] {
if !strings.HasPrefix(mnt.Fstype, "ext") && !strings.HasPrefix(mnt.Fstype, "nfs") &&
!supportedFsType[mnt.Fstype] {
continue
}
// Avoid bind mounts, exclude tmpfs.
Expand Down
18 changes: 10 additions & 8 deletions fs/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,18 +563,20 @@ func TestProcessMounts(t *testing.T) {
{Root: "/", Mountpoint: "/d", Source: "/dev/sdd", Fstype: "xfs", Major: 253, Minor: 3},
{Root: "/", Mountpoint: "/e", Source: "/dev/sde", Fstype: "zfs", Major: 253, Minor: 4},
{Root: "/", Mountpoint: "/f", Source: "overlay", Fstype: "overlay", Major: 253, Minor: 5},
{Root: "/", Mountpoint: "/g", Source: "127.0.0.1:/nfs", Fstype: "nfs4", Major: 253, Minor: 6},
{Root: "/", Mountpoint: "/test1", Source: "tmpfs", Fstype: "tmpfs", Major: 253, Minor: 4},
{Root: "/", Mountpoint: "/test2", Source: "tmpfs", Fstype: "tmpfs", Major: 253, Minor: 4},
},
expected: map[string]partition{
"/dev/sda": {fsType: "ext3", mountpoint: "/a", major: 253, minor: 0},
"/dev/sdb": {fsType: "ext4", mountpoint: "/b", major: 253, minor: 1},
"/dev/sdc": {fsType: "btrfs", mountpoint: "/c", major: 253, minor: 2},
"/dev/sdd": {fsType: "xfs", mountpoint: "/d", major: 253, minor: 3},
"/dev/sde": {fsType: "zfs", mountpoint: "/e", major: 253, minor: 4},
"overlay_253-5": {fsType: "overlay", mountpoint: "/f", major: 253, minor: 5},
"/test1": {fsType: "tmpfs", mountpoint: "/test1", major: 253, minor: 4},
"/test2": {fsType: "tmpfs", mountpoint: "/test2", major: 253, minor: 4},
"/dev/sda": {fsType: "ext3", mountpoint: "/a", major: 253, minor: 0},
"/dev/sdb": {fsType: "ext4", mountpoint: "/b", major: 253, minor: 1},
"/dev/sdc": {fsType: "btrfs", mountpoint: "/c", major: 253, minor: 2},
"/dev/sdd": {fsType: "xfs", mountpoint: "/d", major: 253, minor: 3},
"/dev/sde": {fsType: "zfs", mountpoint: "/e", major: 253, minor: 4},
"overlay_253-5": {fsType: "overlay", mountpoint: "/f", major: 253, minor: 5},
"127.0.0.1:/nfs": {fsType: "nfs4", mountpoint: "/g", major: 253, minor: 6},
"/test1": {fsType: "tmpfs", mountpoint: "/test1", major: 253, minor: 4},
"/test2": {fsType: "tmpfs", mountpoint: "/test2", major: 253, minor: 4},
},
},
}
Expand Down

0 comments on commit a228e69

Please sign in to comment.