From f0fa88cfa0367571ca7ddc6849555fd88684d130 Mon Sep 17 00:00:00 2001 From: Yang Gao <6821729+criyle@users.noreply.github.com> Date: Sun, 9 Feb 2025 05:53:55 -0500 Subject: [PATCH] judge: report warning if memory cgroup is not enabled (#942) --- packages/hydrojudge/src/sandbox.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/hydrojudge/src/sandbox.ts b/packages/hydrojudge/src/sandbox.ts index adcffd9fb..8798f78ff 100644 --- a/packages/hydrojudge/src/sandbox.ts +++ b/packages/hydrojudge/src/sandbox.ts @@ -214,11 +214,13 @@ export function runQueued( export async function versionCheck(reportWarn: (str: string) => void, reportError = reportWarn) { let sandboxVersion: string; let sandboxCgroup: number; + let sandboxCgroupControllers: string[] | null; try { const version = await client.version(); sandboxVersion = version.buildVersion.split('v')[1]; const config = await client.config(); sandboxCgroup = config.runnerConfig?.cgroupType || 0; + sandboxCgroupControllers = config.runnerConfig?.cgroupControllers || null; } catch (e) { if (e?.code === 'ECONNREFUSED') reportError('Failed to connect to sandbox, please check sandbox_host config and if your sandbox is running.'); else reportError('Your sandbox version is tooooooo low! Please upgrade!'); @@ -231,6 +233,11 @@ export async function versionCheck(reportWarn: (str: string) => void, reportErro reportWarn('You are using cgroup v2 without kernel 5.19+. This could result in inaccurate memory usage measurements.'); } } + if (sandboxCgroupControllers) { + if (!sandboxCgroupControllers.includes('memory') && gte(sandboxVersion, '1.8.6')) { + reportWarn('The memory cgroup controller is not enabled. This could result in inaccurate memory usage measurements.'); + } + } return true; }