diff --git a/agent/src/util/device_plugin_builder.rs b/agent/src/util/device_plugin_builder.rs index c9dd41b88..d20f161c9 100644 --- a/agent/src/util/device_plugin_builder.rs +++ b/agent/src/util/device_plugin_builder.rs @@ -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()) })) diff --git a/agent/src/util/discovery_operator.rs b/agent/src/util/discovery_operator.rs index eecb9ad97..e6fa5d0df 100644 --- a/agent/src/util/discovery_operator.rs +++ b/agent/src/util/discovery_operator.rs @@ -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(); diff --git a/agent/src/util/registration.rs b/agent/src/util/registration.rs index 4d5bd2204..9bf6d8204 100644 --- a/agent/src/util/registration.rs +++ b/agent/src/util/registration.rs @@ -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()) diff --git a/discovery-utils/src/discovery/mod.rs b/discovery-utils/src/discovery/mod.rs index 874633b13..6e6d2914c 100644 --- a/discovery-utils/src/discovery/mod.rs +++ b/discovery-utils/src/discovery/mod.rs @@ -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()) diff --git a/discovery-utils/src/registration_client.rs b/discovery-utils/src/registration_client.rs index b9deb4e16..32da1384a 100644 --- a/discovery-utils/src/registration_client.rs +++ b/discovery-utils/src/registration_client.rs @@ -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()) })) diff --git a/shared/src/uds/unix_stream.rs b/shared/src/uds/unix_stream.rs index 404f58dfc..ebfae6c6c 100644 --- a/shared/src/uds/unix_stream.rs +++ b/shared/src/uds/unix_stream.rs @@ -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())