Skip to content

The Unified and Autonomous Development Platform

fix: Workspace fails to start if site directory is also mounted (OD-2761)

Robin Shend97ab8b6a17d
diff --git a/pom.xml b/pom.xml
index 3eaa671b6a..59bbccd7a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -682,7 +682,7 @@
</repositories>
<properties>
<commons.version>3.3.1</commons.version>
- <agent.version>2.5.10</agent.version>
+ <agent.version>2.6.0</agent.version>
<slf4j.version>2.0.9</slf4j.version>
<logback.version>1.4.14</logback.version>
<antlr.version>4.7.2</antlr.version>
diff --git a/server-plugin/server-plugin-executor-serverdocker/src/main/java/io/onedev/server/plugin/executor/serverdocker/ServerDockerExecutor.java b/server-plugin/server-plugin-executor-serverdocker/src/main/java/io/onedev/server/plugin/executor/serverdocker/ServerDockerExecutor.java
index 175cac9d08..541e3376c8 100644
--- a/server-plugin/server-plugin-executor-serverdocker/src/main/java/io/onedev/server/plugin/executor/serverdocker/ServerDockerExecutor.java
+++ b/server-plugin/server-plugin-executor-serverdocker/src/main/java/io/onedev/server/plugin/executor/serverdocker/ServerDockerExecutor.java
@@ -37,8 +37,6 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.SystemUtils;
import org.jspecify.annotations.Nullable;
-import com.google.common.base.Preconditions;
-
import io.onedev.agent.AgentUtils;
import io.onedev.commons.bootstrap.Bootstrap;
import io.onedev.commons.bootstrap.SecretMasker;
@@ -125,9 +123,7 @@ public class ServerDockerExecutor extends JobExecutor implements DockerAware, Te
private transient volatile LeafFacade runningStep;
private transient volatile String containerName;
-
- private static volatile String hostInstallPath;
-
+
@Editable(order=400, description="Specify registry logins if necessary. For built-in registry, " +
"use <code>@server_url@</code> for registry url, <code>@job_token@</code> for user name, and " +
"access token for password")
@@ -673,16 +669,10 @@ public class ServerDockerExecutor extends JobExecutor implements DockerAware, Te
}
private String getHostPath(String path) {
- String installPath = Bootstrap.installDir.getAbsolutePath();
- Preconditions.checkState(path.startsWith(installPath + "/")
- || path.startsWith(installPath + "\\"));
- if (hostInstallPath == null) {
- if (Bootstrap.isInDocker())
- hostInstallPath = AgentUtils.getHostPath(newDocker(), installPath);
- else
- hostInstallPath = installPath;
- }
- return hostInstallPath + path.substring(installPath.length());
+ if (Bootstrap.isInDocker())
+ return AgentUtils.getHostPath(newDocker(), path);
+ else
+ return path;
}
@Override
diff --git a/server-plugin/server-plugin-provisioner-docker/src/main/java/io/onedev/server/plugin/provisioner/docker/DockerProvisioner.java b/server-plugin/server-plugin-provisioner-docker/src/main/java/io/onedev/server/plugin/provisioner/docker/DockerProvisioner.java
index bc6eb877d3..f7c2e92d40 100644
--- a/server-plugin/server-plugin-provisioner-docker/src/main/java/io/onedev/server/plugin/provisioner/docker/DockerProvisioner.java
+++ b/server-plugin/server-plugin-provisioner-docker/src/main/java/io/onedev/server/plugin/provisioner/docker/DockerProvisioner.java
@@ -97,8 +97,6 @@ public class DockerProvisioner extends WorkspaceProvisioner implements DockerAwa
private String memoryLimit;
- private static volatile String hostInstallPath;
-
@Editable(order=400, description="Specify registry logins if necessary. For built-in registry, " +
"use <code>@server_url@</code> for registry url, <code>@job_token@</code> for user name, and " +
"access token for password")
@@ -216,15 +214,10 @@ public class DockerProvisioner extends WorkspaceProvisioner implements DockerAwa
}
private String getHostPath(String path) {
- String installPath = Bootstrap.installDir.getAbsolutePath();
- Preconditions.checkState(path.startsWith(installPath + "/") || path.startsWith(installPath + "\\"));
- if (hostInstallPath == null) {
- if (Bootstrap.isInDocker())
- hostInstallPath = AgentUtils.getHostPath(newDocker(), installPath);
- else
- hostInstallPath = installPath;
- }
- return hostInstallPath + path.substring(installPath.length());
+ if (Bootstrap.isInDocker())
+ return AgentUtils.getHostPath(newDocker(), path);
+ else
+ return path;
}
private List<RegistryLoginFacade> getRegistryLoginFacades(String token) {