Commit b8b7f3f
fix(dagster-aws): make ECS pipes interruption test robust under CI load (#24924)
## Summary & Motivation
`test_ecs_pipes_interruption_forwarding` has been flaking on `internal`
builds when CI is under load (e.g.
https://buildkite.com/dagster/internal/builds/152968,
https://buildkite.com/dagster/internal/builds/152985), failing with
`KeyError: 0` at the final assertion.
Root cause is a race in the test itself, not a CI resource issue. The
test spawns a subprocess that runs `_materialize_asset`, then sleeps a
hardcoded 4 seconds before sending `SIGTERM` and asserting that the
subprocess populated `return_dict[0]` with the stopped ECS task state.
`return_dict[0]` is only written from a `finally` block, gated by
`assert len(pipes._client._task_runs) > 0`. Under load, Python startup +
`DagsterInstance.from_config()` + moto setup take longer than 4 seconds,
so the subprocess receives `SIGTERM` before `materialize()` has launched
the ECS task. The `finally`-block precondition fails, the child dies
without writing `return_dict[0]`, and the parent's assertion blows up.
The captured stderr in both failing builds shows the child died inside
`instance_for_test()` → `unified_storage = instance_ref.storage`, well
before any task was launched.
Replace the fixed sleep with an explicit "task launched" signal. The
child monkey-patches `mock_client.run_task` to set a
`multiprocessing.Event` as soon as `run_task` returns; the parent
`event.wait(timeout=60)` before sending `SIGTERM`, guaranteeing there is
a live ECS task to interrupt. The unbounded `while p.is_alive():
sleep(4); terminate()` retry loop is replaced with a single
`terminate()` + bounded `join(timeout=30)`.
## Test Plan
- `tox -e py312 -- -k test_ecs_pipes_interruption_forwarding` in
`python_modules/libraries/dagster-aws` (from `dagster-oss/`).
- Watch the dagster-aws step on this PR's Buildkite run; it should pass
without retries.
Internal-RevId: b8eefc49d4bf8091e176569ccbde859c273624fb1 parent fcca120 commit b8b7f3f
1 file changed
Lines changed: 27 additions & 10 deletions
Lines changed: 27 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
140 | | - | |
| 139 | + | |
141 | 140 | | |
142 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
143 | 156 | | |
144 | | - | |
| 157 | + | |
145 | 158 | | |
146 | 159 | | |
147 | 160 | | |
| |||
165 | 178 | | |
166 | 179 | | |
167 | 180 | | |
| 181 | + | |
168 | 182 | | |
169 | 183 | | |
170 | 184 | | |
171 | 185 | | |
172 | 186 | | |
173 | 187 | | |
| 188 | + | |
174 | 189 | | |
175 | 190 | | |
176 | 191 | | |
177 | 192 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 193 | + | |
182 | 194 | | |
183 | | - | |
184 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
185 | 203 | | |
186 | | - | |
187 | 204 | | |
188 | 205 | | |
189 | 206 | | |
| |||
0 commit comments