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

Configurable bind addrs #471

Merged
merged 11 commits into from
Apr 18, 2024
Merged

Conversation

Michael-J-Ward
Copy link
Contributor

@Michael-J-Ward Michael-J-Ward commented Apr 12, 2024

Changelog

  • Daemon now has configurable bind addr that defaults to 0.0.0.0:0
  • Coordinator now ha a configurable bind addr that defaults to 0.0.0.0:DORA_COORDINATOR_PORT_DEFAULT

The CLI provides the defaults, so this shouldn't break any existing run commands.

Notes

cargo fmt --all makes a lot of unrelated changes. Do you have a rustfmt config somewhere that I can use? Similarly, cargo clippy gives a fair number of lints.

If you'd like, let me know if you want me to include those - either in addition to this or as a separate PR.

EDIT: I realized my own rustfmt was running off a custom config.

Ref #459

@Michael-J-Ward Michael-J-Ward changed the title Configurable bind mounts Configurable bind addrs Apr 13, 2024
Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

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

Thanks!

@Michael-J-Ward Michael-J-Ward force-pushed the configurable-bind-mounts branch from 71adb50 to 3a6323f Compare April 16, 2024 15:36
@Michael-J-Ward
Copy link
Contributor Author

Rebased off main and applied the appropriate rustfmt to the commits.

@Michael-J-Ward
Copy link
Contributor Author

Multi-daemon example breaks on Windows but not on Linux.

2024-04-16T16:10:17.406865Z  WARN dora_daemon::node_communication: failed to send event to daemon
failed to run dora-daemon: failed to forward output to remote receivers: failed to connect to machine `B`: failed to connect: The requested address is not valid in its context. (os error 10049)

...

 2024-04-16T16:10:17.412084Z ERROR dora_coordinator::listener: Os { code: 10054, kind: ConnectionReset, message: "An existing connection was forcibly closed by the remote host." }
    at binaries\coordinator\src\listener.rs:33

@phil-opp did you update those logs in an attempt to debug?

@Michael-J-Ward
Copy link
Contributor Author

Ahh - 0.0.0.0 is not connectable by clients on windows, whereas linux routes it to your localhost.

Fixing.

clients can not connect to `0.0.0.0` on windows.
@Michael-J-Ward
Copy link
Contributor Author

Daemon::run uses its configuable address to construct register its listen_socket with the coordinator in coordinator_messages::CoordinatorRequest::Register.

If a window's users configures that to 127.0.0.1 or <vpn-ip>, that works fine.

But if a Window's users configures it to 0.0.0.0, then the daemon listen_socket can't actually be connected to as an InterDaemonConnection.

Copy link
Collaborator

@haixuanTao haixuanTao left a comment

Choose a reason for hiding this comment

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

Looking good! I think we should use address as overall name instead of bind which can mean many things.

binaries/cli/src/main.rs Outdated Show resolved Hide resolved
binaries/cli/src/main.rs Outdated Show resolved Hide resolved
binaries/coordinator/src/lib.rs Outdated Show resolved Hide resolved
examples/multiple-daemons/run.rs Outdated Show resolved Hide resolved
examples/multiple-daemons/run.rs Show resolved Hide resolved
…ocket

We are not interested in the local bind address of the daemon. Instead, we want to use the IP address under which the daemon is available from other machines.

This should also avoids the issue that connecting to 0.0.0.0 is not possible on Windows (we want to use 0.0.0.0 as default bind address).
@phil-opp
Copy link
Collaborator

@phil-opp did you update those logs in an attempt to debug?

Yes, but I think it's also an improvement that we might want to keep.

Daemon::run uses its configuable address to construct register its listen_socket with the coordinator in coordinator_messages::CoordinatorRequest::Register.

If a window's users configures that to 127.0.0.1 or <vpn-ip>, that works fine.

But if a Window's users configures it to 0.0.0.0, then the daemon listen_socket can't actually be connected to as an InterDaemonConnection.

Thanks a lot for debugging this! This is indeed the issue. However, I think the correct fix is to use the public IP instead of the local bind address for the registration. One way to get the public IP of the daemon could be to take the connection.peer_addr().ip() of the incoming connection. The Register message then only needs to tell us the (public) port number, on which the daemon listens for incoming inter-daemon connections.

I opened a PR against your PR to implement this change: Michael-J-Ward#1. I also tested this change on our CI in #473.

@Michael-J-Ward
Copy link
Contributor Author

Ready to go.

One follow-on item raised by @haixuanTao: a proper "distributed-test" example where the daemon's run separately.

Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I opened #475 to track the idea of doing a proper multi-machine test on CI.

@phil-opp phil-opp merged commit bbabdc3 into dora-rs:main Apr 18, 2024
17 checks passed
@Michael-J-Ward Michael-J-Ward deleted the configurable-bind-mounts branch April 23, 2024 09:44
@haixuanTao haixuanTao mentioned this pull request May 17, 2024
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.

3 participants