Skip to content

Conversation

chris-sanders
Copy link
Owner

Summary

  • Fix _UnixReadPipeTransport cleanup warnings during garbage collection
  • Eliminate external curl command dependency in bundle.py
  • Replace curl subprocess calls with aiohttp HTTP client
  • Add proper AsyncIO transport cleanup utilities
  • Fix async decorator issues in e2e container tests

Test plan

  • All 160 unit tests pass
  • All 7 subprocess utilities integration tests pass
  • All code quality checks pass (black, ruff, mypy)
  • Curl dependency completely eliminated
  • Transport cleanup warnings resolved
  • CI tests pass (to be verified)

Technical Details

Transport Cleanup Issues Fixed

  • Created src/mcp_server_troubleshoot/subprocess_utils.py with proper cleanup utilities
  • Implemented pipe_transport_reader context manager for safe transport handling
  • Updated kubectl.py to use new cleanup utilities instead of direct subprocess calls
  • Fixed _UnixReadPipeTransport cleanup warnings during garbage collection

Curl Dependency Eliminated

  • Replaced curl subprocess calls in bundle.py with aiohttp HTTP client
  • Eliminated external curl command dependency that caused failures in minimal environments
  • Maintained same functionality for API server health checks without external dependencies

Test Suite Improvements

  • Fixed missing @pytest.mark.asyncio decorators in e2e container tests
  • Updated transport cleanup tests to verify fixes work instead of reproducing failures
  • Replaced complex mocks with functional integration tests
  • All unit and integration tests for subprocess utilities pass

This resolves the transport cleanup and curl dependency issues described in the task.

- Remove curl dependency from check_api_server_available() method
- Replace curl fallback with more aggressive aiohttp retry
- Update _get_system_info() to use aiohttp instead of curl for port testing
- Maintain same timeout behavior (3.0 seconds)
- Preserve diagnostic information collection for system info
- Eliminate external curl dependency across codebase
- Create subprocess_utils.py with proper async context managers
- Add pipe_transport_reader() to handle _UnixReadPipeTransport cleanup
- Add subprocess_exec_with_cleanup() for guaranteed subprocess cleanup
- Add subprocess_shell_with_cleanup() and managed_subprocess() utilities
- Update bundle.py to use pipe_transport_reader for sbctl output reading
- Update bundle.py subprocess calls to use cleanup utilities
- Update kubectl.py to use subprocess_exec_with_cleanup
- Ensure proper timeout handling and process termination
- Prevent ResourceWarning about unclosed transports
- Add proper type annotations to subprocess utilities
- Fix linting issues in test files
- Ensure all type checking passes
- Remove unused imports from test files
- Transform test_demonstrate_curl_dependency_failure to test_demonstrate_curl_dependency_fix_success
- Transform test_demonstrate_expected_transport_cleanup_failure to test_demonstrate_transport_cleanup_fix_success
- Tests now verify that curl dependency has been eliminated
- Tests now verify that transport cleanup utilities work correctly
- Tests now PASS instead of failing, confirming fixes are working
- Add proper mocking for async subprocess operations
- Verify aiohttp usage and eliminate curl subprocess calls
- Replace previous curl dependency check with functional health check test
- Test verifies API health check works without curl being available
- Test confirms aiohttp is used exclusively for HTTP operations
- Test verifies no curl subprocess calls are made
- Better functional test than just checking if curl is called
- Update test_kubectl_executor_run_kubectl_command_timeout to mock subprocess_exec_with_cleanup
- Update test_kubectl_timeout_behavior to mock subprocess_exec_with_cleanup
- Skip obsolete curl dependency reproduction tests that are no longer relevant
- Tests now properly verify timeout handling with new subprocess utilities
- Timeout cleanup is handled internally by subprocess utilities
- Create comprehensive integration tests in tests/integration/test_subprocess_utilities_integration.py
- Remove 5 obsolete tests that tested old curl dependency behavior
- Replace flaky async mocking with actual subprocess operations
- Add functional tests for subprocess_exec_with_cleanup and subprocess_shell_with_cleanup
- Add transport warning detection tests that work without complex mocks
- Tests now verify actual functionality rather than reproducing old issues
- All tests pass and are more reliable than previous mocked versions
## Summary
- Fix _UnixReadPipeTransport cleanup warnings during garbage collection
- Eliminate external curl command dependency in bundle.py
- Replace curl subprocess calls with aiohttp HTTP client
- Add proper AsyncIO transport cleanup utilities
- Fix async decorator issues in e2e container tests

## Technical Changes
- Created subprocess_utils.py with proper transport cleanup
- Updated bundle.py to use aiohttp instead of curl subprocess
- Updated kubectl.py to use new subprocess utilities
- Fixed missing @pytest.mark.asyncio decorators in container tests
- Updated transport cleanup tests to verify fixes work

## Test Results
- All 160 unit tests pass
- All 7 subprocess utilities integration tests pass
- All code quality checks pass (black, ruff, mypy)
- Curl dependency completely eliminated
- Transport cleanup warnings resolved
- Allow environment-specific shell warnings in subprocess shell test
- Fixes CI failure from 'getcwd() failed' warnings in GitHub Actions
- Test still validates command success and output correctness
@chris-sanders chris-sanders merged commit 5f91550 into main Jul 24, 2025
6 checks passed
@chris-sanders chris-sanders deleted the task/transport-cleanup-curl-fixes branch July 24, 2025 18:55
chris-sanders added a commit that referenced this pull request Jul 29, 2025
- fix-container-name-conflicts.md (PR #46 merged)
- fix-asyncio-transport-python313.md (PR #42 merged)
- fix-container-shutdown-race-condition.md (PR #41 merged)
- fix-transport-cleanup-and-curl-dependency.md (PR #40 merged)
- implement-comprehensive-testing-improvements.md (PR #39 merged)
- switch-to-melange-apko-build.md (completed previously)
chris-sanders added a commit that referenced this pull request Aug 11, 2025
* Replace curl subprocess with aiohttp in bundle.py
* Implement proper transport cleanup utilities
* Update demonstration tests to verify fixes work
* Fix kubectl timeout tests for subprocess_exec_with_cleanup
* Fix AsyncIO transport cleanup and eliminate curl dependency

## Summary
- Fix _UnixReadPipeTransport cleanup warnings during garbage collection
- Eliminate external curl command dependency in bundle.py
- Replace curl subprocess calls with aiohttp HTTP client
- Add proper AsyncIO transport cleanup utilities
- Fix async decorator issues in e2e container tests

## Technical Changes
- Created subprocess_utils.py with proper transport cleanup
- Updated bundle.py to use aiohttp instead of curl subprocess
- Updated kubectl.py to use new subprocess utilities
- Fixed missing @pytest.mark.asyncio decorators in container tests
- Updated transport cleanup tests to verify fixes work

## Test Results
- All 160 unit tests pass
- All 7 subprocess utilities integration tests pass
- All code quality checks pass (black, ruff, mypy)
- Curl dependency completely eliminated
- Transport cleanup warnings resolved
chris-sanders added a commit that referenced this pull request Aug 11, 2025
- fix-container-name-conflicts.md (PR #46 merged)
- fix-asyncio-transport-python313.md (PR #42 merged)
- fix-container-shutdown-race-condition.md (PR #41 merged)
- fix-transport-cleanup-and-curl-dependency.md (PR #40 merged)
- implement-comprehensive-testing-improvements.md (PR #39 merged)
- switch-to-melange-apko-build.md (completed previously)
chris-sanders added a commit that referenced this pull request Aug 11, 2025
* Replace curl subprocess with aiohttp in bundle.py
* Implement proper transport cleanup utilities
* Update demonstration tests to verify fixes work
* Fix kubectl timeout tests for subprocess_exec_with_cleanup
* Fix AsyncIO transport cleanup and eliminate curl dependency

## Summary
- Fix _UnixReadPipeTransport cleanup warnings during garbage collection
- Eliminate external curl command dependency in bundle.py
- Replace curl subprocess calls with aiohttp HTTP client
- Add proper AsyncIO transport cleanup utilities
- Fix async decorator issues in e2e container tests

## Technical Changes
- Created subprocess_utils.py with proper transport cleanup
- Updated bundle.py to use aiohttp instead of curl subprocess
- Updated kubectl.py to use new subprocess utilities
- Fixed missing @pytest.mark.asyncio decorators in container tests
- Updated transport cleanup tests to verify fixes work

## Test Results
- All 160 unit tests pass
- All 7 subprocess utilities integration tests pass
- All code quality checks pass (black, ruff, mypy)
- Curl dependency completely eliminated
- Transport cleanup warnings resolved
chris-sanders added a commit that referenced this pull request Aug 11, 2025
- fix-container-name-conflicts.md (PR #46 merged)
- fix-asyncio-transport-python313.md (PR #42 merged)
- fix-container-shutdown-race-condition.md (PR #41 merged)
- fix-transport-cleanup-and-curl-dependency.md (PR #40 merged)
- implement-comprehensive-testing-improvements.md (PR #39 merged)
- switch-to-melange-apko-build.md (completed previously)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant