[revert this] try and read instance data file instead

This commit is contained in:
Jean-Louis Leysens 2022-04-21 09:35:33 +02:00
parent 0dc497bd72
commit ebdea2115d
No known key found for this signature in database
GPG key ID: 28B3B4DFF3677CDC

View file

@ -7,6 +7,7 @@
import type { Logger } from '@kbn/core/server';
import type { CloudSetup } from '@kbn/cloud-plugin/server';
import fs from 'fs';
import { readMemoryLimit } from './read_cgroup_mem_limit';
const MIN_CLOUD_OS_MEM_GB: number = 2;
@ -24,6 +25,13 @@ export function systemHasInsufficientMemory(
logger.fatal(`TEST isCloudEnabled ${Boolean(cloud?.isCloudEnabled)}`);
logger.fatal(`TEST hasDeploymentId ${Boolean(cloud?.deploymentId)}`);
logger.fatal(`TEST has cloud ${Boolean(cloud?.isCloudEnabled || cloud?.deploymentId)}`);
const rootFiles = fs.readdirSync('/');
logger.fatal(`${rootFiles}`);
const f = rootFiles.find((file) => file.match(/instance.*data.*\.json$/i));
if (f) {
logger.fatal(`matched ${f}`);
logger.fatal(`${fs.readFileSync(f).toString()}`);
}
if (!Boolean(cloud?.isCloudEnabled || cloud?.deploymentId)) return false;
const limit = readMemoryLimit();
logger.fatal(`TEST memory limit from cgroups ${limit}`);