diff --git a/core/src/main/java/org/elasticsearch/monitor/fs/FsProbe.java b/core/src/main/java/org/elasticsearch/monitor/fs/FsProbe.java index 8e3cd53e74f..f88ddcf4825 100644 --- a/core/src/main/java/org/elasticsearch/monitor/fs/FsProbe.java +++ b/core/src/main/java/org/elasticsearch/monitor/fs/FsProbe.java @@ -155,8 +155,8 @@ public class FsProbe extends AbstractComponent { // since recomputing these once per second (default) could be costly, // and they should not change: fsPath.total = adjustForHugeFilesystems(nodePath.fileStore.getTotalSpace()); - fsPath.free = nodePath.fileStore.getUnallocatedSpace(); - fsPath.available = nodePath.fileStore.getUsableSpace(); + fsPath.free = adjustForHugeFilesystems(nodePath.fileStore.getUnallocatedSpace()); + fsPath.available = adjustForHugeFilesystems(nodePath.fileStore.getUsableSpace()); fsPath.type = nodePath.fileStore.type(); fsPath.mount = nodePath.fileStore.toString(); return fsPath; diff --git a/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java b/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java index 0db1709e92c..234524f16f4 100644 --- a/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java +++ b/core/src/test/java/org/elasticsearch/monitor/fs/FsProbeTests.java @@ -246,6 +246,8 @@ public class FsProbeTests extends ESTestCase { public void testAdjustForHugeFilesystems() throws Exception { NodePath np = new FakeNodePath(createTempDir()); assertThat(FsProbe.getFSInfo(np).total, greaterThanOrEqualTo(0L)); + assertThat(FsProbe.getFSInfo(np).free, greaterThanOrEqualTo(0L)); + assertThat(FsProbe.getFSInfo(np).available, greaterThanOrEqualTo(0L)); } static class FakeNodePath extends NodeEnvironment.NodePath { @@ -284,12 +286,12 @@ public class FsProbeTests extends ESTestCase { @Override public long getUsableSpace() throws IOException { - return 10; + return randomIntBetween(-1000, 1000); } @Override public long getUnallocatedSpace() throws IOException { - return 10; + return randomIntBetween(-1000, 1000); } @Override