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

Accept Docker service hostnames in addition to IP addresses in configuration. #415

Closed
XAMPPRocky opened this issue Oct 7, 2021 · 6 comments · Fixed by #419
Closed

Accept Docker service hostnames in addition to IP addresses in configuration. #415

XAMPPRocky opened this issue Oct 7, 2021 · 6 comments · Fixed by #419
Labels
area/networking Related to networking I/O good first issue Good for newcomers help wanted Extra attention is needed kind/feature New feature or request

Comments

@XAMPPRocky
Copy link
Collaborator

XAMPPRocky commented Oct 7, 2021

Currently if you use a docker hostname in the configuration you'll get an error about a invalid IP address, but there are times where you need to get IP from the hostname. When I was trying to make a docker-compose version of the iperf3 for #410, docker compose gives services hostnames for service discovery, but these are not picked up by std's implementation of ToSocketAddrs or dns-lookup it seems.

@XAMPPRocky XAMPPRocky added the kind/bug Something isn't working label Oct 7, 2021
@iffyio
Copy link
Collaborator

iffyio commented Oct 7, 2021

Is this ticket more to be able to accept dns names or is the issue docker-compose specific?
Re the docker scenario, I imagine docker's using dns names that are by default only valid within the bridge network it runs the containers so unless quilkin is part of that network it won't be able to resolve them. And we'd need to e.g run quilkin in the same network, somehow make docker's private dns resolvable on the host machine (it sounds like its not currently) or pass the ip address that those entries point to in quilkin's config

@iffyio iffyio added kind/feature New feature or request and removed kind/bug Something isn't working labels Oct 7, 2021
@iffyio
Copy link
Collaborator

iffyio commented Oct 7, 2021

Removed the bug label since we explicitly call out that only ip address and port is supported in both static and dynamic configs

@XAMPPRocky
Copy link
Collaborator Author

XAMPPRocky commented Oct 7, 2021

Is this ticket more to be able to accept dns names or is the issue docker-compose specific?

It's specific to docker networks (not just compose), as I believe the DNS works the same.

And we'd need to e.g run quilkin in the same network, somehow make docker's private dns resolvable on the host machine (it sounds like its not currently) or pass the ip address that those entries point to in quilkin's config

I mean I think I am running in the network with compose, I'm honestly surprised it doesn't just work. I thought it was supposed to be transparent to processes running in the container. I'm testing with this code.

Dockerfile

FROM rust:latest
WORKDIR /app
RUN cargo init --name dns-test .
RUN echo 'dns-lookup = "*"' >> Cargo.toml
COPY main.rs /app/src/main.rs
RUN cargo build
CMD ["cargo", "run"]

main.rs

fn main() {
    println!("{:?}", dns_lookup::lookup_host("iperf:8000").unwrap());
}

compose.yml

  dns_test:
    build: .
  iperf:
    image: networkstatic/iperf3:latest
    restart: always
    ports:
      - 8000:5201
    command: -s

@iffyio
Copy link
Collaborator

iffyio commented Oct 7, 2021

so it seems dns only works out of the box from compose version 2 and above, I tried with the following that worked

version: '2'
services:
  dns_test:
    build: .
  iperf:
    image: networkstatic/iperf3:latest
    restart: always
    ports:
      - 8000:5201
    command: -s
fn main() {
        println!("it were: {:?}", dns_lookup::lookup_host("iperf").unwrap());
}

@XAMPPRocky
Copy link
Collaborator Author

XAMPPRocky commented Oct 7, 2021

Ah the issue is with having the :<port>. Very odd, but oh well.

@XAMPPRocky XAMPPRocky reopened this Oct 7, 2021
@XAMPPRocky
Copy link
Collaborator Author

Actually I'm going to re-open because we need to be able to set the port in quilkin endpoint configuration, and I don't know how to do that without changing the serde impl, because it seems like we need to parse the host and port separately due to ToSocketAddrs not performing a full lookup. So we have to query the DNS, because the following still fails.

fn main() {
        println!("it were: {:?}", "iperf".parse::<std::net::SocketAddr>().unwrap());
}

@XAMPPRocky XAMPPRocky added good first issue Good for newcomers help wanted Extra attention is needed area/networking Related to networking I/O labels Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking Related to networking I/O good first issue Good for newcomers help wanted Extra attention is needed kind/feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants