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

Support Unix domain sockets in IoT Edge on Windows #518

Merged
merged 26 commits into from
Nov 13, 2018

Conversation

damonbarry
Copy link
Member

@damonbarry damonbarry commented Nov 6, 2018

Changes to Edge Agent:

  • When Edge Agent builds the Docker "createOptions" string to send to iotedged, the bind-mount specification on Windows needs to point to the parent directory for each socket file, not to the files themselves. On Windows, Docker can't bind-mount a Unix domain socket file.

Changes to edgelet:

  • Change the default management and workload URIs (YAML config) for Windows to specify Unix domain sockets instead of HTTP endpoints.
  • Deserialize the management and workload URIs into file paths on Windows by parsing them with the file:// scheme instead of unix://. This is because the url crate does lots of special handling of Windows paths for the file:// scheme, but doesn't do it for "non-special" schemes like unix:// (per the URL spec).
  • Depend on mio-uds-windows, tokio-uds-windows, and hyperlocal-windows crates on Windows. These are adaptations of mio-uds, tokio-uds, and hyperlocal respectively.
  • Where appropriate, remove the #[cfg(unix)] attribute from Unix domain socket-specific features that expected a Unix-only implementation, and add it in places where we still need to differentiate on platform. Notable examples:
    • In edgelet-http::unix::listener(path), only use umask to reset socket file permissions on Unix platforms.
    • On Unix platforms check for existence of the Unix domain socket file with file.exists(). On Windows, use fs::symlink_metadata() instead because it works on reparse points (Unix domain sockets in Windows are reparse points).
  • Implement UnixStreamExt::pid(&self) for Windows
  • A test that previously used UnixStream::pair() to do its setup doesn't work on Windows because Winsock2 doesn't implement BSD's pair function. So create an ugly workaround for the test on Windows.
  • Use TempDir more pervasively in tests that create a socket file. In a Unix-only world we got away with simpler solutions that don't work if you can't rely on the existence of /tmp.
  • Move the test helper routine run_uds_server out of a linux-specific source file and into the parent mod.rs.
  • When the Edge Agent container is created in Windows, bind-mount the parent directory for each socket file rather than the file itself, just as Edge Agent does for other modules.

In the Windows installer script:

  • Create the parent directory for each socket file, and give Modify rights to a well-known group (NT AUTHORITY\Authenticated Users) that will exist in any container so that non-privileged modules can access it. Since we give the rights to the parent folder, we don't need to recreate the permissions every time iotedged restarts, like we do for Unix platforms. (Note: this part of the script is disabled for now, until we have everything in place to fully support UDS in IoT Edge on Windows, specifically RS5-based module images and the ability to use process-isolated containers on non-Server Windows.)

@arsing
Copy link
Member

arsing commented Nov 7, 2018

LGTM for the edgelet and installer script changes. Someone else should review the edge agent change.

As discussed offline, this change allows users to use unix URLs in config.yaml even on RS4 (which we support for development use-cases). The daemon should fail when it bootstraps the management and workload servers (because the socket() call inside mio should fail to recognize the address family), so please check if this error manifests to the user clearly.

arsing
arsing previously approved these changes Nov 7, 2018
@damonbarry damonbarry merged commit b1ee469 into Azure:master Nov 13, 2018
@damonbarry damonbarry deleted the windows-uds-2 branch November 13, 2018 23:18
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