fix: Filter container overlay mounts in non-standard locations
Detect container overlay filesystem paths from various container runtimes (Docker, Podman, LXC, EnhanceCP, etc.) that may not be in standard /var/lib/docker or /var/lib/containers locations. Paths containing /containers/ with overlay patterns (/overlay2/, /overlay/, /diff/, /merged) are now filtered from disk usage aggregation. Related to #790
This commit is contained in:
parent
a6f675281c
commit
c76239b1d4
2 changed files with 29 additions and 0 deletions
|
|
@ -86,9 +86,21 @@ var specialMountPrefixes = []string{
|
|||
"/sys",
|
||||
"/run",
|
||||
"/var/lib/docker",
|
||||
"/var/lib/containers",
|
||||
"/snap",
|
||||
}
|
||||
|
||||
// containerOverlayPatterns detect container overlay filesystem paths from various
|
||||
// container runtimes (Docker, Podman, LXC, EnhanceCP, etc.) that may not be in
|
||||
// standard locations. These paths should be excluded from disk usage as they
|
||||
// represent container layers, not actual storage usage.
|
||||
var containerOverlayPatterns = []string{
|
||||
"/overlay2/",
|
||||
"/overlay/",
|
||||
"/diff/",
|
||||
"/merged",
|
||||
}
|
||||
|
||||
// ShouldSkipFilesystem determines if a filesystem should be excluded from disk
|
||||
// usage aggregation. It checks for read-only filesystems, virtual/pseudo filesystems,
|
||||
// network mounts, and special system mountpoints. Returns skip=true if the filesystem
|
||||
|
|
@ -132,5 +144,16 @@ func ShouldSkipFilesystem(fsType, mountpoint string, totalBytes, usedBytes uint6
|
|||
reasons = append(reasons, "special-mountpoint")
|
||||
}
|
||||
|
||||
// Check for container overlay paths from various runtimes in non-standard locations
|
||||
// (e.g., /var/local/enhance/containers/*/overlay/merged). Related to #790.
|
||||
if strings.Contains(mountpoint, "/containers/") {
|
||||
for _, pattern := range containerOverlayPatterns {
|
||||
if strings.Contains(mountpoint, pattern) {
|
||||
reasons = append(reasons, "container-overlay")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return len(reasons) > 0, reasons
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,6 +173,12 @@ func TestShouldSkipFilesystem(t *testing.T) {
|
|||
{"/var/lib/docker", "ext4", "/var/lib/docker/overlay2", 1000000, 500000, true},
|
||||
{"/snap prefix", "ext4", "/snap/core/12345", 1000000, 500000, true},
|
||||
{"/boot/efi exact", "vfat", "/boot/efi", 512 * 1024 * 1024, 50 * 1024 * 1024, true},
|
||||
{"/var/lib/containers podman", "ext4", "/var/lib/containers/storage/overlay/abc123/merged", 1000000, 500000, true},
|
||||
|
||||
// Container overlay paths in non-standard locations (issue #790)
|
||||
{"enhance containers overlay", "ext4", "/var/local/enhance/containers/abc123/overlay/merged", 1000000, 500000, true},
|
||||
{"custom containers diff", "ext4", "/opt/containers/myapp/diff/layer", 1000000, 500000, true},
|
||||
{"custom containers overlay2", "ext4", "/data/containers/xyz/overlay2/layer1", 1000000, 500000, true},
|
||||
|
||||
// Windows paths
|
||||
{"Windows System Reserved", "NTFS", "System Reserved", 500 * 1024 * 1024, 100 * 1024 * 1024, true},
|
||||
|
|
|
|||
Loading…
Reference in a new issue