diff --git a/pageserver/src/controller_upcall_client.rs b/pageserver/src/controller_upcall_client.rs index be1de43d18..8da4cee4b9 100644 --- a/pageserver/src/controller_upcall_client.rs +++ b/pageserver/src/controller_upcall_client.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::net::IpAddr; use futures::Future; use pageserver_api::config::NodeMetadata; @@ -16,7 +17,7 @@ use tokio_util::sync::CancellationToken; use url::Url; use utils::generation::Generation; use utils::id::{NodeId, TimelineId}; -use utils::{backoff, failpoint_support}; +use utils::{backoff, failpoint_support, ip_address}; use crate::config::PageServerConf; use crate::virtual_file::on_fatal_io_error; @@ -27,6 +28,7 @@ pub struct StorageControllerUpcallClient { http_client: reqwest::Client, base_url: Url, node_id: NodeId, + node_ip_addr: Option, cancel: CancellationToken, } @@ -91,11 +93,18 @@ impl StorageControllerUpcallClient { ); } + // Intentionally panics if we encountered any errors parsing or reading the IP address. + // Note that if the required environment variable is not set, `read_node_ip_addr_from_env` returns `Ok(None)` + // instead of an error. + let node_ip_addr = + ip_address::read_node_ip_addr_from_env().expect("Error reading node IP address."); + Self { http_client: client.build().expect("Failed to construct HTTP client"), base_url: url, node_id: conf.id, cancel: cancel.clone(), + node_ip_addr, } } @@ -193,8 +202,8 @@ impl StorageControllerUpcallApi for StorageControllerUpcallClient { listen_http_addr: m.http_host, listen_http_port: m.http_port, listen_https_port: m.https_port, + node_ip_addr: self.node_ip_addr, availability_zone_id: az_id.expect("Checked above"), - node_ip_addr: None, }) } Err(e) => {