agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

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

Open BEN5890 opened this issue 4 months ago • 4 comments

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会报错,导致创建沙箱失败

BEN5890 avatar Jul 26 '26 10:07 BEN5890

你是哪个版本呢?我好像没在 main 分支上见到这个方法。 @BEN5890

zouyx avatar Jul 26 '26 11:07 zouyx

你是哪个版本呢?我好像没在 main 分支上见到这个方法。 @BEN5890

Image 这个Fabric8KubernetesPodRuntime里面,好像main分支确实没有

BEN5890 avatar Jul 26 '26 12:07 BEN5890

PR #2308 这个 pr 修改过,你试试看是否还有问题

zouyx avatar Jul 26 '26 13:07 zouyx

Based on the discussion above, the createWorkDir method referenced in this issue does not exist on the current main branch. It was likely part of an older version or a different branch.

PR #2308 modified the Fabric8KubernetesPodRuntime and may have already resolved this.

Could you try with the latest main branch and confirm whether the issue still reproduces? If it does, please share the exact version/commit and the full stack trace.

Marking as needs-repro.

oss-maintainer avatar Jul 28 '26 06:07 oss-maintainer