agentscope-ai / agentscope-ai/agentscope-java

[Bug]:创建k8s沙箱的时候报错,无法新建工作目录

Open
#2,396 4 comments 0 reactions 0 assignees View on GitHub
area/extensions bug
Dominant language
Java
Stars
5.6k
Forks
1.3k
Avg merge
4d 12h
Merged PRs (30d)
77

Description

public ExecResult exec(KubernetesSandboxState state, String command, int timeoutSeconds)
throws Exception {
String script =
"cd " + shellSingleQuote(state.getWorkspaceRoot()) + " && (" + command + ")";
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
ContainerResource pod = pod(state);
try (ExecWatch watch = pod.writingOutput(out).writingError(err).exec("sh", "-c", script)) {
Integer exit = watch.exitCode().get(timeoutSeconds + 5L, TimeUnit.SECONDS);
int code = exit != null ? exit : -1;
String stdout = truncate(out.toByteArray());
String stderr = truncate(err.toByteArray());
boolean truncated =
out.size() >= OUTPUT_TRUNCATE_BYTES || err.size() >= OUTPUT_TRUNCATE_BYTES;
ExecResult result = new ExecResult(code, stdout, stderr, truncated);
if (!result.ok()) {
throw new SandboxException.ExecException(code, stdout, stderr);
}
return result;
} catch (java.util.concurrent.TimeoutException e) {
throw new SandboxException.ExecTimeoutException(command, timeoutSeconds);
}
}
这个代码中命令是cd workspace && mkdir -p workspace,但是workspace 不存在,cd workspace会报错,导致创建沙箱失败

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.