Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Hide docker mounts from diskusage by default #836

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions config.docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ const CONFIG = {
ssl: process.env.FLOOD_ENABLE_SSL === 'true' || process.env.FLOOD_ENABLE_SSL === true,
sslKey: '/data/flood_ssl.key',
sslCert: '/data/flood_ssl.cert',
diskUsageService: {
dontWatchMountPoints: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can't just enumerate files our mountpoints here because they can be different for each distro. We need to find a cross-distro way to do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are paths in the container, I don't know if the host distro affects this. I only tried on ubuntu.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I missed it was for docker only.

"/dev",
"/sys/fs/cgroup",
"/etc/resolv.conf",
"/etc/hostname",
"/etc/hosts",
"/dev/shm",
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/timer_list",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware",
],
},
};

module.exports = CONFIG;
16 changes: 10 additions & 6 deletions server/services/diskUsageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ const diskUsageServiceEvents = require('../constants/diskUsageServiceEvents');
const PLATFORMS_SUPPORTED = ['darwin', 'linux', 'freebsd'];
const MAX_BUFFER_SIZE = 65536;

const filterMountPoint =
config.diskUsageService && config.diskUsageService.watchMountPoints
? // if user has configured watchPartitions filter each line output for given
// array
mountpoint => config.diskUsageService.watchMountPoints.includes(mountpoint)
: () => true; // include all mounted file systems by default
const filterMountPoint = mountpoint => {
// include all mounted file systems by default
if (!config.diskUsageService) return true;
const {watchMountPoints, dontWatchMountPoints} = config.diskUsageService;
// whitelist
if (watchMountPoints) return watchMountPoints.includes(mountpoint);
// blacklist
if (dontWatchMountPoints) return !dontWatchMountPoints.includes(mountpoint);
return true;
};

const linuxDfParsing = () =>
execFile('df | tail -n+2', {
Expand Down