fix(ecs): retry teardown of redeployed task containers (#4280)

* fix(ecs): retry teardown of redeployed task containers

* test(ecs): wait for explicit task stop in SDK compatibility test

* fix(ecs): serialize teardown and align stop compatibility test

* test(ecs): observe blocked concurrent stop without delay

* fix(ecs): preserve unknown exits and serialize startup transition
This commit is contained in:
Abhigya authored and GitHub committed 2026-09-24 15:51:05 -04:00
1 parent ecc4b1a569
commit 76cc27f2f1
7 files changed
+552 -36

No files matched your search

@@ -195,8 +195,8 @@ class EcsOneShotTaskLifecycleTest {
@Test
@Order(7)
@DisplayName("StopTask - explicit stop populates exitCode when already stopped")
void explicitStopExitCode() {
@DisplayName("StopTask - explicit stop requests terminal status")
void explicitStopRequestsTerminalStatus() {
// Register and run a second task; stop it explicitly before it exits naturally.
String family2 = family + "-explicit";
ecs.registerTaskDefinition(RegisterTaskDefinitionRequest.builder()
@@ -221,21 +221,14 @@ class EcsOneShotTaskLifecycleTest {
.count(1)
.build()).tasks().get(0).taskArn();
Task stopped = ecs.stopTask(StopTaskRequest.builder()
Task stopping = ecs.stopTask(StopTaskRequest.builder()
.cluster(clusterName)
.task(explicitTaskArn)
.reason("test-explicit-stop")
.build()).task();
assertThat(stopped.lastStatus()).isEqualTo("STOPPED");
assertThat(stopped.stoppedAt()).isNotNull();
// exitCode should be present (Docker assigns 137 for SIGKILL on explicit stop)
assertThat(stopped.containers()).isNotEmpty();
stopped.containers().forEach(c ->
assertThat(c.exitCode())
.as("explicit stopTask must populate exitCode on container %s", c.name())
.isNotNull());
assertThat(stopping.desiredStatus()).isEqualTo("STOPPED");
assertThat(stopping.stoppedReason()).isEqualTo("test-explicit-stop");
}
// ── Helpers ──────────────────────────────────────────────────────────────