From 4ea4a8249b2f9877c80c1c8c0b8d43b32ef36f21 Mon Sep 17 00:00:00 2001 From: Mike Beaumont Date: Mon, 7 Oct 2024 22:09:26 +0200 Subject: [PATCH 1/2] feat(ha-node): allow listening on IPv6 Pod IPs Signed-off-by: Mike Beaumont --- control-plane/agents/src/bin/ha/node/main.rs | 32 +++++++++++++++---- .../agents/src/bin/ha/node/reporter.rs | 2 +- .../agents/src/bin/ha/node/server.rs | 2 +- utils/utils-lib/src/constants.rs | 8 +++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/control-plane/agents/src/bin/ha/node/main.rs b/control-plane/agents/src/bin/ha/node/main.rs index 509458872..75dce7103 100644 --- a/control-plane/agents/src/bin/ha/node/main.rs +++ b/control-plane/agents/src/bin/ha/node/main.rs @@ -5,7 +5,10 @@ use grpc::{ }; use http::Uri; use once_cell::sync::OnceCell; -use std::{net::SocketAddr, time::Duration}; +use std::{ + net::{IpAddr, SocketAddr}, + time::Duration, +}; use stor_port::{ transport_api::TimeoutOptions, types::v0::transport::cluster_agent::NodeAgentInfo, }; @@ -14,9 +17,9 @@ use tonic::transport::{Channel, Endpoint}; use tower::service_fn; use utils::{ package_description, tracing_telemetry::KeyValue, version_info_str, - DEFAULT_CLUSTER_AGENT_CLIENT_ADDR, DEFAULT_NODE_AGENT_SERVER_ADDR, - NVME_PATH_AGGREGATION_PERIOD, NVME_PATH_CHECK_PERIOD, NVME_PATH_CONNECTION_PERIOD, - NVME_PATH_RETRANSMISSION_PERIOD, NVME_SUBSYS_REFRESH_PERIOD, + DEFAULT_CLUSTER_AGENT_CLIENT_ADDR, DEFAULT_NODE_AGENT_SERVER_IP, + DEFAULT_NODE_AGENT_SERVER_PORT, NVME_PATH_AGGREGATION_PERIOD, NVME_PATH_CHECK_PERIOD, + NVME_PATH_CONNECTION_PERIOD, NVME_PATH_RETRANSMISSION_PERIOD, NVME_SUBSYS_REFRESH_PERIOD, }; mod detector; mod path_provider; @@ -40,8 +43,14 @@ struct Cli { node_name: String, /// IP address and port for the ha node-agent to listen on. - #[clap(short, long, default_value = DEFAULT_NODE_AGENT_SERVER_ADDR)] - grpc_endpoint: SocketAddr, + #[clap(short, long = "grpc-endpoint")] + deprecated_grpc_endpoint: Option, + + #[clap(long, default_value_t = DEFAULT_NODE_AGENT_SERVER_IP)] + grpc_ip: IpAddr, + + #[clap(long, default_value_t = DEFAULT_NODE_AGENT_SERVER_PORT)] + grpc_port: u16, /// Add process service tags to the traces. #[clap(short, long, env = "TRACING_TAGS", value_delimiter=',', value_parser = utils::tracing_telemetry::parse_key_value)] @@ -108,6 +117,15 @@ impl Cli { fn args() -> Self { Cli::parse() } + + fn grpc_endpoint(&self) -> SocketAddr { + #[allow(deprecated)] + if let Some(deprecated_endpoint) = &self.deprecated_grpc_endpoint { + *deprecated_endpoint + } else { + std::net::SocketAddr::new(self.grpc_ip, self.grpc_port) + } + } } #[tokio::main] @@ -139,7 +157,7 @@ async fn main() -> anyhow::Result<()> { if let Err(error) = cluster_agent_client() .register( - &NodeAgentInfo::new(cli_args.node_name.clone(), cli_args.grpc_endpoint), + &NodeAgentInfo::new(cli_args.node_name.clone(), cli_args.grpc_endpoint()), None, ) .await diff --git a/control-plane/agents/src/bin/ha/node/reporter.rs b/control-plane/agents/src/bin/ha/node/reporter.rs index f3e7b0980..8cdc44839 100755 --- a/control-plane/agents/src/bin/ha/node/reporter.rs +++ b/control-plane/agents/src/bin/ha/node/reporter.rs @@ -74,7 +74,7 @@ impl PathReporter { .into_iter() .map(FailedPath::new) .collect::>(); - let node_ep = Cli::args().grpc_endpoint; + let node_ep = Cli::args().grpc_endpoint(); let mut req = ReportFailedPaths::new(node_name.to_string(), failed_paths, node_ep); // Report all paths in a separate task, continue till transmission succeeds. diff --git a/control-plane/agents/src/bin/ha/node/server.rs b/control-plane/agents/src/bin/ha/node/server.rs index 6527bd5a9..43eabf6e4 100755 --- a/control-plane/agents/src/bin/ha/node/server.rs +++ b/control-plane/agents/src/bin/ha/node/server.rs @@ -44,7 +44,7 @@ impl NodeAgentApiServer { /// Returns a new `Self` with the given parameters. pub(crate) fn new(args: &Cli, path_cache: NvmePathCache) -> Self { Self { - endpoint: args.grpc_endpoint, + endpoint: args.grpc_endpoint(), path_cache, path_connection_timeout: *args.path_connection_timeout, subsys_refresh_period: *args.subsys_refresh_period, diff --git a/utils/utils-lib/src/constants.rs b/utils/utils-lib/src/constants.rs index 1f0ff6a70..263907a3a 100644 --- a/utils/utils-lib/src/constants.rs +++ b/utils/utils-lib/src/constants.rs @@ -103,8 +103,12 @@ pub const DEFAULT_CLUSTER_AGENT_SERVER_ADDR: &str = "[::]:11500"; /// The default value to be assigned as cluster agent GRPC client addr if not overridden. pub const DEFAULT_CLUSTER_AGENT_CLIENT_ADDR: &str = "https://agent-ha-cluster:11500"; -/// The default value to be assigned as node-agent GRPC server addr if not overridden. -pub const DEFAULT_NODE_AGENT_SERVER_ADDR: &str = "[::]:11600"; +/// The default value to be assigned as node-agent GRPC ip addr if not overridden. +pub const DEFAULT_NODE_AGENT_SERVER_IP: std::net::IpAddr = + std::net::IpAddr::V6(std::net::Ipv6Addr::UNSPECIFIED); + +/// The default value to be assigned as node-agent GRPC port if not overridden. +pub const DEFAULT_NODE_AGENT_SERVER_PORT: u16 = 11600; /// The default worker threads cap for the api-rest service. pub const DEFAULT_REST_MAX_WORKER_THREADS: &str = "8"; From 0a890e83e2256ab57fda2b04f062332a537478cd Mon Sep 17 00:00:00 2001 From: Mike Beaumont Date: Wed, 9 Oct 2024 19:36:46 +0200 Subject: [PATCH 2/2] fix: restore short arg for deprecated option Signed-off-by: Mike Beaumont --- control-plane/agents/src/bin/ha/node/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control-plane/agents/src/bin/ha/node/main.rs b/control-plane/agents/src/bin/ha/node/main.rs index 75dce7103..bc7eb494c 100644 --- a/control-plane/agents/src/bin/ha/node/main.rs +++ b/control-plane/agents/src/bin/ha/node/main.rs @@ -43,7 +43,7 @@ struct Cli { node_name: String, /// IP address and port for the ha node-agent to listen on. - #[clap(short, long = "grpc-endpoint")] + #[clap(short = 'g', long = "grpc-endpoint")] deprecated_grpc_endpoint: Option, #[clap(long, default_value_t = DEFAULT_NODE_AGENT_SERVER_IP)]