[Upgrade Assistant] Fix watermark calculation (#154420)

This commit is contained in:
Ignacio Rivas 2023-04-06 11:33:34 +02:00 committed by GitHub
parent ee123ac5e9
commit cc52e132f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -113,7 +113,7 @@ describe('Disk space API', () => {
.getSettings as jest.Mock
).mockResolvedValue({
defaults: {},
transient: { 'cluster.routing.allocation.disk.watermark.low': '80%' },
transient: { 'cluster.routing.allocation.disk.watermark.low': '79%' },
persistent: { 'cluster.routing.allocation.disk.watermark.low': '85%' },
});
@ -128,7 +128,7 @@ describe('Disk space API', () => {
nodeName: 'node_name',
nodeId: '1YOaoS9lTNOiTxR1uzSgRA',
available: '20%',
lowDiskWatermarkSetting: '80%',
lowDiskWatermarkSetting: '79%',
},
]);
});
@ -186,7 +186,7 @@ describe('Disk space API', () => {
.getSettings as jest.Mock
).mockResolvedValue({
defaults: {
'cluster.routing.allocation.disk.watermark.low': '10%',
'cluster.routing.allocation.disk.watermark.low': '85%',
},
transient: {},
persistent: {},

View file

@ -88,9 +88,10 @@ export function registerNodeDiskSpaceRoute({ router, lib: { handleEsError } }: R
const rawLowDiskWatermarkPercentageValue = Number(
lowDiskWatermarkSetting!.replace('%', '')
);
// ES interprets this setting as a threshold for used disk space; we want free disk space
const freeDiskSpaceAllocated = 100 - rawLowDiskWatermarkPercentageValue;
// If the percentage available is < the low disk watermark setting, mark node as having low disk space
if (percentageAvailable < rawLowDiskWatermarkPercentageValue) {
if (percentageAvailable < freeDiskSpaceAllocated) {
nodesWithLowDiskSpace.push({
nodeId,
nodeName: node.name || nodeId,