damccorm opened a new pull request, #41899:
URL: https://github.com/apache/beam/pull/41899
Note: this PR was auto-generated by tooling. Before moving it out of draft,
the author has done a full review of the PR, specifically evaluating it on the
following criteria:
- The PR is an appropriate fix for the issue (e.g. we're not changing a test
to avoid a bug)
- The PR is a simple fix to the issue (e.g. we're not adding infra when we
could just modify a test)
- The PR is not covering for other problems (e.g. if we're bumping timeouts,
it is not because we're covering for a performance problem)
Full details of the methodology of generation and review can be found here -
https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
If you have concerns with the PR or with the underlying methodology used to
generate this, please comment below - they will be addressed by the author not
the tooling :)
## Root Cause
In `PostCommit TransformService Direct` run
[47097574511](https://github.com/apache/beam/actions/runs/47097574511) (Python
3.11, [build scan](https://develocity.apache.org/s/nhq6f7mun7vas)),
`:sdks:python:test-suites:direct:xlang:transformServiceSetup` failed with:
```
java.util.concurrent.TimeoutException: Transform Service did not start in
120 seconds.
at
org.apache.beam.sdk.transformservice.launcher.TransformServiceLauncher.waitTillUp(TransformServiceLauncher.java:323)
```
The launcher log showed why:
- At `11:53:42Z`, `TransformServiceLauncher.start()` launched
`docker-compose up -d`, slept a fixed 3 seconds (`STATUS_LOGGER_WAIT_TIME`)
without calling `Process.waitFor(...)`, and returned immediately while Docker
Compose was still creating `expansion-service-1` and `expansion-service-2`.
- `waitTillUp(120000)` immediately started its 120s timer at `11:53:45Z` and
spawned `docker-compose ps` roughly every 4 seconds while `up -d` was still
creating containers.
- At `11:55:42Z`, `docker-compose up -d` actually finished starting
`transform-service-1`, but the final `ps` call had already raced it and
`waitTillUp` threw `TimeoutException` at `11:55:46Z` — 4 seconds after
`transform-service-1` started.
More generally, `TransformServiceLauncher.runDockerComposeCommand` never
waited for any spawned `docker-compose` subprocess (`up -d`, `down`, or `ps`)
to exit (unlike the Python launcher's `process.communicate()`), causing:
1. `start()` to return prematurely before container creation/startup
finishes, eating into `waitTillUp`'s timeout budget and adding `docker-compose
ps` contention;
2. `getStatus()` to sleep 3s unnecessarily on fast `ps` calls while risking
reading an incomplete/empty `outputOverride` file if `ps` takes >3s;
3. `shutdown()` to return after 3s before `docker-compose down` finishes
stopping/removing containers.
## Fix
- Update `TransformServiceLauncher.runDockerComposeCommand` to wait for the
spawned `docker-compose` process via `Process.waitFor(timeoutMs,
TimeUnit.MILLISECONDS)` (forcibly terminating and reaping on timeout or
interruption).
- Wait up to 300s in `start()` for `docker-compose up -d` to complete
(throwing `TimeoutException` on timeout and `IOException` on non-zero exit
code) before `waitTillUp` polls status.
- Wait for `docker-compose down` and `docker-compose ps` to complete, pass
the remaining `waitTillUp` deadline into `getStatus(remainingMs)`, use
monotonic `System.nanoTime()` for deadline tracking, check status output
immediately after `ps` exits, and delete the temporary status file in a
`finally` block.
- Add unit tests in `TransformServiceLauncherTest` covering `start()`,
`waitTillUp()`, and `shutdown()` process completion, timeout, and error
handling.
### Verification
- Triggered `.github/workflows/beam_PostCommit_TransformService_Direct.yml`
workflow run on branch:
[`47105248606`](https://github.com/apache/beam/actions/runs/47105248606)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]