Skip to content

Conversation

@achimnol
Copy link
Member

@achimnol achimnol commented Jul 27, 2025

resolves #xxx (BA-1976)

Now we can leverage:

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue

@github-actions github-actions bot added the size:M 30~100 LoC label Jul 27, 2025
@github-actions github-actions bot added comp:manager Related to Manager component comp:common Related to Common component comp:cli Related to CLI component labels Jul 27, 2025
@HyeockJinKim HyeockJinKim force-pushed the main branch 4 times, most recently from 1a10632 to 2d8c9ea Compare November 23, 2025 14:45
@HyeockJinKim HyeockJinKim force-pushed the main branch 2 times, most recently from 9552aac to 4af738e Compare December 31, 2025 15:41
@github-actions github-actions bot added size:L 100~500 LoC comp:agent Related to Agent component comp:storage-proxy Related to Storage proxy component and removed size:M 30~100 LoC labels Jan 9, 2026
@achimnol achimnol marked this pull request as ready for review January 10, 2026 04:30
@achimnol achimnol requested review from Yaminyam and Copilot January 10, 2026 04:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the etcd-client-py dependency from version 0.4.1 to 0.5.1 and refactors the AsyncEtcd wrapper to be an explicit async context manager. The changes leverage improvements in the etcd-client-py library that ensure graceful tokio runtime shutdown, eliminating the need for manual workarounds.

Changes:

  • Updated etcd-client-py from 0.4.1 to 0.5.1 and testcontainers from 4.8.1 to 4.13.3
  • Made AsyncEtcd and LegacyEtcdLoader explicit async context managers with aenter and aexit methods
  • Refactored all AsyncEtcd usage sites to use async with context managers instead of manual close() calls

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ai/backend/common/etcd.py Added async context manager protocol to AsyncEtcd with aenter and aexit methods
src/ai/backend/manager/config/loader/legacy_etcd_loader.py Added async context manager protocol to LegacyEtcdLoader
src/ai/backend/storage/server.py Updated etcd_ctx to use async with instead of manual close()
src/ai/backend/storage/dependencies/infrastructure/etcd.py Updated provide method to use async with pattern
src/ai/backend/manager/server.py Refactored etcd_ctx to initialize etcd within async with
src/ai/backend/manager/dependencies/bootstrap/etcd.py Updated provide method to use async with pattern
src/ai/backend/manager/cli/context.py Refactored etcd_ctx, config_ctx, and redis_ctx to use async with patterns
src/ai/backend/install/context.py Updated etcd_ctx to use async with instead of manual close()
src/ai/backend/agent/server.py Updated etcd_ctx to use async with instead of manual close()
src/ai/backend/agent/dependencies/bootstrap/etcd.py Updated provide method to use async with pattern
src/ai/backend/cli/main.py Removed workaround sleep for tokio/pyo3-async-runtimes shutdown race
tests/conftest.py Updated test fixtures to use async with pattern
tests/unit/common/conftest.py Updated gateway_etcd fixture to use async with
tests/unit/common/test_distributed.py Updated test to use async with for AsyncEtcd
tests/unit/common/health_checker/checkers/test_etcd.py Updated test fixtures to use async with
tests/unit/storage-proxy/conftest.py Changed mock_etcd to async fixture using async with
tests/unit/storage/dependencies/infrastructure/test_redis.py Updated test fixture to use async with
requirements.txt Updated etcd-client-py and testcontainers versions
python.lock Updated lock file with new dependency versions
changes/5289.fix.md Added changelog entry

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 51 to 53
exc_type: type[BaseException],
exc_val: BaseException,
exc_tb: TracebackType,
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exc_type, exc_val, and exc_tb parameters should be Optional types to match Python's async context manager protocol. The correct signature should be exc_type: Optional[type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]. This ensures the type hints match the protocol when aexit is called without an exception (None values).

Suggested change
exc_type: type[BaseException],
exc_val: BaseException,
exc_tb: TracebackType,
exc_type: Optional[type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],

Copilot uses AI. Check for mistakes.
@achimnol
Copy link
Member Author

Confirmed successful installation in our internal dev-test farm, which had issues without asyncio.sleep(0.1) before this PR.

@achimnol achimnol requested a review from HyeockJinKim January 12, 2026 13:46
@HyeockJinKim HyeockJinKim added this pull request to the merge queue Jan 13, 2026
Merged via the queue into main with commit d83799a Jan 13, 2026
28 checks passed
@HyeockJinKim HyeockJinKim deleted the fix/etcd-client-segfault-fundamental-fix branch January 13, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:agent Related to Agent component comp:cli Related to CLI component comp:common Related to Common component comp:manager Related to Manager component comp:storage-proxy Related to Storage proxy component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants