{"record":{"id":"141f379d37d9cf50","repo":"theonedev/onedev","slug":"this-workspace-is-provisioned-on-agent-previously","errorCode":null,"errorMessage":"This workspace is provisioned on agent previously, and cannot be reprovisioned via server docker","messagePattern":"This workspace is provisioned on agent previously, and cannot be reprovisioned via server docker","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-plugin/server-plugin-provisioner-serverdocker/src/main/java/io/onedev/server/plugin/provisioner/serverdocker/ServerDockerProvisioner.java","lineNumber":557,"sourceCode":"\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t\treturn serverHost;\n\t}\n\n\tprotected int getConcurrencyNumber() {\n\t\treturn concurrency != null ? concurrency : 0;\n\t}\n\n\t@Override\n\tpublic List<RegistryLoginFacade> getRegistryLogins(String token) {\n\t\treturn getRegistryLoginFacades(token);\n\t}\n\n\t@Override\n\tpublic <T> Future<T> submitTask(@Nullable String pinnedServerAddress, @Nullable Long pinnedAgentId,\n\t\t\t\t\t\t ClusterTask<T> task, TaskLogger logger) {\n\t\tif (pinnedAgentId != null) {\n\t\t\tthrow new ExplicitException(\"\"\"\n\t\t\t\tThis workspace is provisioned on agent previously, \\\n\t\t\t\tand cannot be reprovisioned via server docker\"\"\");\n\t\t}\n\t\tlogger.log(\"Pending resource allocation...\");\n\t\treturn getResourceService().submitServerTask(\n\t\t\t\tpinnedServerAddress, getName(), getConcurrencyNumber(), 1, task);\n\t}\n\n\t@Override\n\tpublic void deleteWorkspace(Long projectId, Long workspaceNumber, @Nullable String pinnedServer, @Nullable Long pinnedAgentId) {\n\t\tServerProvisionerUtils.deleteWorkspace(projectId, workspaceNumber, pinnedServer);\n\t}\n\n\t@Override\n\tpublic boolean isApplicable(Project project) {\n\t\treturn getApplicableProjects() == null || WildcardUtils.matchPath(getApplicableProjects(), project.getPath());\n\t}\n","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-provisioner-serverdocker/src/main/java/io/onedev/server/plugin/provisioner/serverdocker/ServerDockerProvisioner.java#L539-L575","documentation":"ServerDockerProvisioner.submitTask throws ExplicitException when the task is pinned to a specific agent (pinnedAgentId != null). A workspace previously provisioned on a (remote) agent cannot have its cluster tasks executed via the server-docker provisioner — the pin is incompatible.","triggerScenarios":"A cluster task with a non-null pinnedAgentId submitted against the server docker provisioner — typically a workspace that was originally provisioned by the agent/server-shell provisioner and later switched to server docker, then re-provisioned or resumed with a stale agent pin.","commonSituations":"Migrating workspaces from agent-based provisioner to server docker; stale workspace state referencing an old agent after provisioner change; resuming an interrupted task pinned to a decommissioned agent.","solutions":["Re-create/reprovision the workspace so it is provisioned by server docker without agent pinning","Clear the stale agent pin on the workspace (or reset workspace state) before re-running","Keep the workspace on its original agent-based provisioner if it must run on that agent","If migrating provisioners intentionally, create a fresh workspace instead of reprovisioning the old one"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"if (task.getPinnedAgentId() != null) { throw new IllegalStateException('Use the original agent-based provisioner for this workspace'); }","typeGuard":null,"tryCatchPattern":"try { submitTask(...); } catch (ExplicitException e) { if (e.getMessage().contains('provisioned on agent')) recreateWorkspaceWithoutAgentPin(); else throw e; }","preventionTips":["Do not switch a workspace from agent-based provisioner to server docker; create a new workspace instead","Clean up stale agent pins when agents are decommissioned","Track which provisioner originally provisioned each workspace"],"tags":["provisioner","workspace","state-conflict"],"backgroundTag":"invalid-state-transition","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}