Skip to content

Commit

Permalink
feat(metrics-exporter): support IPv6 Pod IPs
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont committed Oct 7, 2024
1 parent 6238e84 commit 1430c5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions metrics-exporter/src/bin/io_engine/client/grpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::client::{
replica_stat::{ReplicaIoStat, ReplicaIoStats},
};
use actix_web::http::Uri;
use std::time::Duration;
use std::{net::SocketAddr, time::Duration};
use tokio::time::sleep;
use tonic::transport::Channel;
use tracing::error;
Expand Down Expand Up @@ -112,7 +112,7 @@ pub(crate) async fn init_client() -> Result<GrpcClient, ExporterError> {
let _ = get_node_name()?;
let endpoint = Uri::builder()
.scheme("https")
.authority(format!("{pod_ip}:10124"))
.authority(SocketAddr::new(pod_ip, 10124).to_string())
.path_and_query("")
.build()
.map_err(|error| ExporterError::InvalidURI(error.to_string()))?;
Expand Down
12 changes: 9 additions & 3 deletions metrics-exporter/src/bin/io_engine/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use crate::{
use actix_web::{middleware, HttpServer};
use clap::Parser;
use once_cell::sync::OnceCell;
use std::{env, net::SocketAddr};
use std::{
env,
net::{IpAddr, SocketAddr},
};
use utils::tracing_telemetry::{FmtLayer, FmtStyle};

/// Cache module for exporter.
Expand All @@ -26,8 +29,11 @@ async fn initialize_cache() {
}

/// Get pod ip from env.
fn get_pod_ip() -> Result<String, ExporterError> {
env::var("MY_POD_IP").map_err(|_| ExporterError::PodIPError("Unable to get pod ip".to_string()))
fn get_pod_ip() -> Result<IpAddr, ExporterError> {
let ip = env::var("MY_POD_IP")
.map_err(|_| ExporterError::PodIPError("Unable to get pod ip".to_string()))?;
ip.parse::<IpAddr>()
.map_err(|_| ExporterError::PodIPError("Invalid pod ip".to_string()))
}

/// Get node name from env.
Expand Down

0 comments on commit 1430c5d

Please sign in to comment.