potiuk opened a new pull request, #66675:
URL: https://github.com/apache/airflow/pull/66675
## Summary
When a trigger finishes, `TriggerRunnerSupervisor._handle_request()`
uploads its log file to the remote store and then closes the local
file descriptor:
```python
if factory := self.logger_cache.pop(id, None):
factory.upload_to_remote()
# Need to close the FD explicitly, as it is not closed when logger is
removed.
factory.close()
```
If `factory.upload_to_remote()` raises (e.g. S3/GCS throttling, transient
network errors), `factory.close()` is never called. The factory has
already been popped from `logger_cache`, so nothing else will close the
underlying `BufferedWriter` — its 8 KiB buffer plus the open fd leak for
every failed upload, and the exception escapes into `handle_requests`
where it is not handled.
Wrap the cleanup in `try/except/finally` so the fd is always closed and
the failure is logged instead of propagating.
Surfaced in #65985.
## Test plan
- [x] New unit test
`test_trigger_logger_fd_closed_when_upload_to_remote_raises`
mocks `upload_to_remote()` to raise and asserts `close()` still
runs and `logger_cache` / `running_triggers` are cleaned up.
- [x] Existing `test_trigger_logger_close` still passes.
- [x] `prek run` clean on changed files (ruff, mypy-airflow-core, bandit,
etc.).
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Opus 4.7 (1M context)
Generated-by: Claude Opus 4.7 (1M context) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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]