Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCKER_HOST handling fix #1960

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AndreiOrmanji
Copy link

@AndreiOrmanji AndreiOrmanji commented Jan 15, 2025

Description of change

fixes #1959

  1. update bollard to latest version
  • modify Cargo.toml
- bollard = "0.15.0"
+ bollard = { version = "0.18.1", features = ["ssl_providerless"] }
  • replace calls of connect_with_unix to connect_with_socket, because it was renamed in new versions
  1. Fix DOCKER_HOST handling
    replace calls of connect_with_local_defaults to connect_with_defaults to fix cases when DOCKER_HOST is set up as tcp/http/https

How has this been tested? (if applicable)

By running tests locally

@AndreiOrmanji AndreiOrmanji changed the title cargo-shuttle DOCKER_HOST handling fix DOCKER_HOST handling fix Jan 15, 2025
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR updates Docker connection handling across the codebase to improve compatibility with various Docker host configurations and modernizes the bollard dependency.

  • Updates bollard dependency to v0.18.1 with ssl_providerless feature in Cargo.toml for better SSL handling
  • Replaces connect_with_local_defaults() with connect_with_defaults() in provisioner_server.rs to properly handle tcp/http/https DOCKER_HOST configurations
  • Updates connect_with_unix to connect_with_socket in gateway/src/service.rs to align with bollard's renamed API

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -325,7 +325,7 @@ impl GatewayService {
));
}

let docker = Docker::connect_with_unix(&args.docker_host, 60, API_DEFAULT_VERSION).unwrap();
let docker = Docker::connect_with_socket(&args.docker_host, 60, API_DEFAULT_VERSION).unwrap();
Copy link

Choose a reason for hiding this comment

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

style: Consider adding error handling here instead of unwrap() since Docker connection is critical for service operation

@AndreiOrmanji AndreiOrmanji force-pushed the cargo-shuttle-docker-host-fix branch from fb8522a to 2f7a0e1 Compare January 15, 2025 15:02
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Based on the latest changes, here's my concise expert review focusing only on new/different aspects not covered in the previous review:

This PR completes the Docker host configuration improvements by updating the remaining connection handling code in the gateway service.

  • Adds Docker connection timeout configuration in gateway/src/service.rs with a 60-second default
  • Implements consistent Docker host handling across test utilities in gateway/src/lib.rs
  • Ensures proper error handling for Docker connection failures in production/staging environments

The changes look well-considered and maintain consistency across the codebase while improving Docker connectivity reliability.

4 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@jonaro00 jonaro00 requested a review from fussybeaver January 15, 2025 16:18
Comment on lines 41 to +44
// This only constructs the client and does not try to connect.
// If the socket is not found, a "no such file" error will happen on the first request to Docker.
Ok(Self {
docker: Docker::connect_with_local_defaults()?,
docker: Docker::connect_with_defaults()?,
Copy link
Member

Choose a reason for hiding this comment

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

@fussybeaver Is the comment above this line still true for the new version? CI is failing for tests that shouldn't try to connect to Docker.

Choose a reason for hiding this comment

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

I believe connect_with_defaults is a new method that tries to infer from environment variables whether you are connecting to a socket or https or a named pipe - IIRC it was added for better compatibility with testcontainers and co. I would stick to the old method if CI is failing, because we may not be setting those env vars appropriately.

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.

[Improvement]: allow using docker locally configured for DOCKER_HOST tcp/http values
3 participants