Ещё фиксы от ИИ
All checks were successful
Build and Push Docker Images / build (src/LiquidCode.Tester.Gateway/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman, gateway) (push) Successful in 57s
Build and Push Docker Images / build (src/LiquidCode.Tester.Worker/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-worker-roman, worker) (push) Successful in 1m17s
All checks were successful
Build and Push Docker Images / build (src/LiquidCode.Tester.Gateway/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-gateway-roman, gateway) (push) Successful in 57s
Build and Push Docker Images / build (src/LiquidCode.Tester.Worker/Dockerfile, git.nullptr.top/liquidcode/liquidcode-tester-worker-roman, worker) (push) Successful in 1m17s
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
@@ -157,17 +158,17 @@ public class IsolateService
|
||||
// I/O redirection
|
||||
if (!string.IsNullOrEmpty(options.StdinFile))
|
||||
{
|
||||
args.Add($"--stdin={options.StdinFile}");
|
||||
args.Add($"--stdin={MapSandboxPath(options.StdinFile, options.BoxId)}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(options.StdoutFile))
|
||||
{
|
||||
args.Add($"--stdout={options.StdoutFile}");
|
||||
args.Add($"--stdout={MapSandboxPath(options.StdoutFile, options.BoxId)}");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(options.StderrFile))
|
||||
{
|
||||
args.Add($"--stderr={options.StderrFile}");
|
||||
args.Add($"--stderr={MapSandboxPath(options.StderrFile, options.BoxId)}");
|
||||
}
|
||||
|
||||
// Working directory
|
||||
@@ -210,6 +211,25 @@ public class IsolateService
|
||||
return string.Join(" ", args);
|
||||
}
|
||||
|
||||
private static string MapSandboxPath(string path, int boxId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
var normalizedPath = Path.GetFullPath(path);
|
||||
var boxRoot = Path.GetFullPath($"/var/local/lib/isolate/{boxId}/box");
|
||||
|
||||
if (normalizedPath.StartsWith(boxRoot, StringComparison.Ordinal))
|
||||
{
|
||||
var relative = normalizedPath.Substring(boxRoot.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
return relative.Length == 0 ? "/box" : $"/box/{relative.Replace(Path.DirectorySeparatorChar, '/')}";
|
||||
}
|
||||
|
||||
return normalizedPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse isolate metadata file
|
||||
/// </summary>
|
||||
@@ -267,9 +287,6 @@ public class IsolateService
|
||||
|
||||
case "status":
|
||||
result.Status = value;
|
||||
result.TimeLimitExceeded = value == "TO";
|
||||
result.MemoryLimitExceeded = value == "XX" || value == "MLE";
|
||||
result.RuntimeError = value == "RE" || value == "SG";
|
||||
break;
|
||||
|
||||
case "message":
|
||||
@@ -282,7 +299,10 @@ public class IsolateService
|
||||
|
||||
case "cg-oom-killed":
|
||||
result.CgroupOomKilled = value == "1";
|
||||
result.MemoryLimitExceeded = true;
|
||||
if (result.CgroupOomKilled)
|
||||
{
|
||||
result.MemoryLimitExceeded = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case "csw-voluntary":
|
||||
@@ -297,6 +317,29 @@ public class IsolateService
|
||||
}
|
||||
}
|
||||
|
||||
// Derive status-related flags after parsing all metadata
|
||||
switch (result.Status)
|
||||
{
|
||||
case "TO":
|
||||
result.TimeLimitExceeded = true;
|
||||
break;
|
||||
case "RE":
|
||||
case "SG":
|
||||
result.RuntimeError = true;
|
||||
break;
|
||||
case "XX":
|
||||
// Internal error reported by isolate
|
||||
result.RuntimeError = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!result.MemoryLimitExceeded &&
|
||||
!string.IsNullOrEmpty(result.Message) &&
|
||||
result.Message.Contains("memory limit", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.MemoryLimitExceeded = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user