Skip to content

Commit 84dd61e

Browse files
committed
Ref #33873: check health of ECS task
1 parent f179bf1 commit 84dd61e

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/eu/openanalytics/containerproxy/backend/ecs/EcsBackend.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,19 @@ public List<ExistingContainerInfo> scanExistingContainers() {
449449

450450
@Override
451451
public boolean isProxyHealthy(Proxy proxy) {
452-
return true; // TODO
452+
for (Container container : proxy.getContainers()) {
453+
Optional<Task> _task = getTask(container);
454+
if (_task.isEmpty()) {
455+
slog.warn(proxy, "ECS container failed: task not found");
456+
return false;
457+
}
458+
Task task = _task.get();
459+
if (!task.lastStatus().equals("RUNNING") || !task.desiredStatus().equals("RUNNING")) {
460+
slog.warn(proxy, String.format("ECS container failed: task not running, stopCode: '%s', stoppingAt: '%s', stoppedAt: '%s', stoppedReason: '%s'", task.stopCode(), task.stoppingAt(), task.stoppedAt(), task.stoppedReason()));
461+
return false;
462+
}
463+
}
464+
return true;
453465
}
454466

455467
protected URI calculateTarget(Container container, PortMappings.PortMappingEntry portMapping, Integer hostPort) throws Exception {

0 commit comments

Comments
 (0)