Skip to content

Commit

Permalink
chore(bors): merge pull request #873
Browse files Browse the repository at this point in the history
873: feat(ha-node): allow listening on IPv6 Pod IPs r=michaelbeaumont a=michaelbeaumont

See openebs/mayastor#1731

Co-authored-by: Mike Beaumont <[email protected]>
  • Loading branch information
mayastor-bors and michaelbeaumont committed Oct 14, 2024
2 parents 934be63 + 0a890e8 commit ddd9d36
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
32 changes: 25 additions & 7 deletions control-plane/agents/src/bin/ha/node/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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;
Expand All @@ -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 = 'g', long = "grpc-endpoint")]
deprecated_grpc_endpoint: Option<SocketAddr>,

#[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)]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion control-plane/agents/src/bin/ha/node/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl PathReporter {
.into_iter()
.map(FailedPath::new)
.collect::<Vec<FailedPath>>();
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.
Expand Down
2 changes: 1 addition & 1 deletion control-plane/agents/src/bin/ha/node/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions utils/utils-lib/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit ddd9d36

Please sign in to comment.