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

Add support for unix domain sockets #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

argerus
Copy link
Contributor

@argerus argerus commented Nov 5, 2024

No description provided.

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 19.54023% with 70 lines in your changes missing coverage. Please review.

Project coverage is 49.78%. Comparing base (0af2e2e) to head (f8d4388).

Files with missing lines Patch % Lines
databroker/src/main.rs 0.00% 46 Missing ⚠️
databroker/src/grpc/server.rs 41.46% 24 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #94      +/-   ##
==========================================
- Coverage   49.95%   49.78%   -0.18%     
==========================================
  Files          31       31              
  Lines       11792    11867      +75     
==========================================
+ Hits         5891     5908      +17     
- Misses       5901     5959      +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erikbosch
Copy link
Contributor

I think we should add some documentation. Some things I think could be useful to include/mention:

  • Does the CLI support it?
  • Provide a example where we use the new argument. Preferably also with a client (if supported)
  • Mention that the socket is not protected by TLS or similar, that you may need to consider to mechanisms like MAC/DAC for protecting the socket
  • Mention that token functionality works the same way as for TCP/IP connection.

When merged we should preferably also mention something on how to test it in https://github.com/eclipse-kuksa/kuksa-databroker/wiki/Release-Testing - I think we at least shall have some form of smoke test, manual or in Github CI to verify that it works before releasing.

grpc::server::serve(
let unix_socket = args.get_one::<String>("unix-socket").cloned();
if let Some(path) = unix_socket {
unlink_unix_domain_socket(&path)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to unlink first?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is a quite common approach. Normally on a clean shutdown we will do the unlinking at exit, but for crashes and forced shutdown (kill -9) we will not unlink it, and then best to try to unlink it before creating it.

Copy link
Contributor

Choose a reason for hiding this comment

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

understood

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, it will fail to bind the path if there is already a file in place.

But as you rightfully point out, a comment explaining the reason why this is done would be appropriate 😄

@@ -138,23 +131,55 @@ where
.await
}

pub async fn serve_with_incoming_shutdown<F>(
listener: TcpListener,
pub async fn serve_uds<F>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to get rid of uds everywhere, i.e. rename this one to serve_unix_domain_socket or similar?

@erikbosch
Copy link
Contributor

Rebased the PR and added some basic documentation. Also addressed two of the comments

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