Skip to content

Commit 8fef5a1

Browse files
author
Yang Guo
committed
pass agent volume to auto local agent
1 parent 66a67af commit 8fef5a1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

core/src/main/java/com/flowci/core/job/service/JobServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public Job cancel(Job job) {
253253

254254
return setJobStatusAndSave(job, Job.Status.CANCELLED, "cancel while agent offline");
255255
} catch (NotFoundException e) {
256-
return setJobStatusAndSave(job, Job.Status.CANCELLED, "cancel while agent deleted");
256+
return setJobStatusAndSave(job, Job.Status.CANCELLED, "cancel while not agent assigned");
257257
}
258258
}
259259

pool/src/main/java/com/flowci/pool/domain/StartContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public static class AgentEnvs {
3737

3838
public static final String AGENT_LOG_LEVEL = "FLOWCI_AGENT_LOG_LEVEL";
3939

40+
public static final String AGENT_VOLUMES = "FLOWCI_AGENT_VOLUMES";
41+
42+
public static final String AGENT_WORKSPACE = "FLOWCI_AGENT_WORKSPACE";
43+
4044
}
4145

4246
@NonNull

pool/src/main/java/com/flowci/pool/manager/SocketPoolManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ public void start(StartContext context) throws DockerPoolException {
9696
CreateContainerResponse container = client.createContainerCmd(AgentContainer.Image).withName(name)
9797
.withEnv(String.format("%s=%s", SERVER_URL, context.getServerUrl()),
9898
String.format("%s=%s", AGENT_TOKEN, context.getToken()),
99-
String.format("%s=%s", AGENT_LOG_LEVEL, context.getLogLevel()))
99+
String.format("%s=%s", AGENT_LOG_LEVEL, context.getLogLevel()),
100+
String.format("%s=%s", AGENT_WORKSPACE, "/ws"),
101+
String.format("%s=%s", AGENT_VOLUMES, System.getenv(AGENT_VOLUMES)))
100102
.withBinds(
101-
new Bind(srcDirOnHost.toString(), new Volume("/root/.flow.ci.agent")),
103+
new Bind(srcDirOnHost.toString(), new Volume("/ws")),
102104
new Bind("/var/run/docker.sock", new Volume("/var/run/docker.sock")))
103105
.exec();
104106

0 commit comments

Comments
 (0)