Skip to content

feat: add automatic Docker service endpoint resolution#75

Merged
briangreunke merged 2 commits into
mainfrom
feat/handle-docker-networks
Jun 13, 2025
Merged

feat: add automatic Docker service endpoint resolution#75
briangreunke merged 2 commits into
mainfrom
feat/handle-docker-networks

Conversation

@briangreunke
Copy link
Copy Markdown
Contributor

@briangreunke briangreunke commented Jun 13, 2025

Add automatic Docker service endpoint resolution

Key Changes:

  • Implement automatic endpoint resolution for Docker environments
  • Add fallback strategies for containerized service discovery
  • Enhance S3 filesystem connectivity in Docker deployments
  • Improve error handling for network connectivity issues

Added:

  • _resolve_endpoint() static method for endpoint resolution
  • _is_docker_service_name() to detect Docker service names
  • _resolve_docker_service() with multiple fallback strategies
  • _test_connection() for socket-based connectivity testing
  • Socket import for network connectivity checks

Changed:

  • S3FileSystem initialization now uses resolved endpoints
  • Enhanced error messages for connection failures
  • Improved Docker service name detection logic
  • Updated endpoint handling in configure() method

Removed:

  • N/A

Generated Summary:

  • Introduced automatic resolution of endpoint URLs based on environment and Docker settings.
  • Added three static methods:
    • _resolve_endpoint: Resolves the provided endpoint URL.
    • _is_docker_service_name: Detects if a hostname is a Docker service name.
    • _resolve_docker_service: Attempts to resolve service name to actual address using multiple strategies.
    • _test_connection: Conducts a simple connectivity test on the given endpoint.
  • Updated the configure method to use the new endpoint resolution logic when connecting to S3 storage.
  • Potential impact:
    • Improves connectivity handling for Dockerized environments.
    • Provides clearer error messaging on connection failures.
    • Enhances flexibility for deploying across different infrastructures.

This summary was generated with ❤️ by rigging

This PR addresses connectivity issues when running Dreadnode in Docker environments where service names need to be resolved to accessible endpoints. The implementation tries multiple resolution strategies (original service name, localhost, host.docker.internal, Docker bridge IP) and automatically selects the first working connection.

- Add endpoint resolution for Docker service names
- Implement connection testing with fallback strategies
- Support localhost, host.docker.internal, and bridge IP fallbacks
- Add socket-based connectivity testing
- Resolve S3 filesystem endpoints automatically in Docker environments
- Add type annotations to _resolve_endpoint, _is_docker_service_name, _resolve_docker_service, and _test_connection methods
- Add ValueError for invalid endpoint URLs in _resolve_endpoint
- Improve null safety with proper None checks
- Use default port 443 for socket connections when port is None
- Simplify variable assignments by removing unnecessary parentheses
- Add SLF001 exception to ruff config for test files to allow private member access
@dreadnode-renovate-bot dreadnode-renovate-bot Bot added the area/python Changes to Python package configuration and dependencies label Jun 13, 2025
@briangreunke briangreunke merged commit 9e9615b into main Jun 13, 2025
8 checks passed
@monoxgas monoxgas deleted the feat/handle-docker-networks branch June 17, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/python Changes to Python package configuration and dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant