Skip to content

Commit c2d44ab

Browse files
committed
handle agent created status
1 parent 434fdd3 commit c2d44ab

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

core/src/main/java/com/flowci/core/agent/service/AgentHostServiceImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,30 @@ public boolean start(AgentHost host) {
193193
}
194194

195195
List<Agent> agents = agentDao.findAllByHostId(host.getId());
196-
List<Agent> offline = new LinkedList<>();
196+
List<Agent> startList = new LinkedList<>();
197197

198-
// resume from stopped
199198
for (Agent agent : agents) {
199+
// add to offline list to start later
200+
if (agent.getStatus() == Agent.Status.CREATED) {
201+
startList.add(agent);
202+
continue;
203+
}
204+
205+
// try to resume, add to start list if failed
200206
if (agent.getStatus() == Agent.Status.OFFLINE) {
201207
try {
202208
optional.get().resume(agent.getName());
203209
log.info("Agent {} been resumed", agent.getName());
204210
return true;
205211
} catch (DockerPoolException e) {
206212
log.warn("Unable to resume agent {}", agent.getName());
207-
offline.add(agent);
213+
startList.add(agent);
208214
}
209215
}
210216
}
211217

212218
// re-start from offline, and delete if cannot be started
213-
for (Agent agent : offline) {
219+
for (Agent agent : startList) {
214220
StartContext context = new StartContext();
215221
context.setServerUrl(serverUrl);
216222
context.setAgentName(agent.getName());

0 commit comments

Comments
 (0)