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

use valid format for dummy uris connect through UDS channel #668

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion agent/src/util/device_plugin_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,11 @@ impl DevicePluginBuilder {
};

// We will ignore this dummy uri because UDS does not use it.
// Some servers will check the uri content so the uri needs to
// be in valid format even it's not used, the scheme part is used
// to specific what scheme to use, such as http or https
let kubelet_socket_closure = kubelet_socket.to_string();
let channel = Endpoint::try_from("http://[::]:50051")?
let channel = Endpoint::try_from("http://[::1]:50051")?
.connect_with_connector(service_fn(move |_: Uri| {
UnixStream::connect(kubelet_socket_closure.clone())
}))
Expand Down
5 changes: 4 additions & 1 deletion agent/src/util/discovery_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ impl DiscoveryOperator {
// Clone socket for closure which has static lifetime
let socket = socket.clone();
// We will ignore this dummy uri because UDS does not use it.
match Endpoint::try_from("http://[::]:50051")
// Some servers will check the uri content so the uri needs to
// be in valid format even it's not used, the scheme part is used
// to specific what scheme to use, such as http or https
match Endpoint::try_from("http://[::1]:50051")
.unwrap()
.connect_with_connector(tower::service_fn(move |_: Uri| {
let endpoint = socket.clone();
Expand Down
2 changes: 1 addition & 1 deletion agent/src/util/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod tests {
.await
.is_ok());
// Connect to registration service
let channel = Endpoint::try_from("http://[::]:50051")
let channel = Endpoint::try_from("http://[::1]:50051")
.unwrap()
.connect_with_connector(tower::service_fn(move |_: Uri| {
UnixStream::connect(registration_socket_path_string.clone())
Expand Down
2 changes: 1 addition & 1 deletion discovery-utils/src/discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub mod server {
Vec::new(),
)
.await;
let channel = Endpoint::try_from("http://[::]:50051")
let channel = Endpoint::try_from("http://[::1]:50051")
.unwrap()
.connect_with_connector(tower::service_fn(move |_: Uri| {
UnixStream::connect(discovery_handler_socket.clone())
Expand Down
5 changes: 4 additions & 1 deletion discovery-utils/src/registration_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ pub async fn register_discovery_handler(
info!("register_discovery_handler - entered");
loop {
// We will ignore this dummy uri because UDS does not use it.
if let Ok(channel) = Endpoint::try_from("http://[::]:50051")?
// Some servers will check the uri content so the uri needs to
// be in valid format even it's not used, the scheme part is used
// to specific what scheme to use, such as http or https
if let Ok(channel) = Endpoint::try_from("http://[::1]:50051")?
.connect_with_connector(tower::service_fn(move |_: Uri| {
tokio::net::UnixStream::connect(super::get_registration_socket())
}))
Expand Down
5 changes: 4 additions & 1 deletion shared/src/uds/unix_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ pub async fn try_connect(socket_path: &str) -> Result<(), anyhow::Error> {
{
let path = socket_path.to_string();
// We will ignore this dummy uri because UDS does not use it.
if let Ok(_v) = tonic::transport::Endpoint::try_from("http://[::]:50051")
// Some servers will check the uri content so the uri needs to
// be in valid format even it's not used, the scheme part is used
// to specific what scheme to use, such as http or https
if let Ok(_v) = tonic::transport::Endpoint::try_from("http://[::1]:50051")
.map_err(|e| anyhow::format_err!("{}", e))?
.connect_with_connector(tower::service_fn(move |_: tonic::transport::Uri| {
tokio::net::UnixStream::connect(path.clone())
Expand Down
Loading