Skip to content

Commit

Permalink
sled-agent's Instance doesn't need PROPOLIS_PORT (#4425)
Browse files Browse the repository at this point in the history
The full SocketAddr is provided by nexus's internal API call to
`instance_register` ( https://github.com/oxidecomputer/omicron/blob/95805d1d6/nexus/src/app/instance.rs#L1014 )
where it's still hardcoded at the call site. But no sense in stripping
the port off of that parameter and then re-adding it here.

Fixing nexus's side of PROPOLIS_PORT being hardcoded is likely to entail
a db schema change, but this comparatively small change will already
make it more possible to write some tests in sled-agent.
  • Loading branch information
lifning authored Nov 10, 2023
1 parent 5b4ae0b commit 4331828
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions sled-agent/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use illumos_utils::svc::wait_for_service;
use illumos_utils::zone::Zones;
use illumos_utils::zone::PROPOLIS_ZONE_PREFIX;
use omicron_common::address::NEXUS_INTERNAL_PORT;
use omicron_common::address::PROPOLIS_PORT;
use omicron_common::api::internal::nexus::{
InstanceRuntimeState, SledInstanceState, VmmRuntimeState,
};
Expand Down Expand Up @@ -196,8 +195,8 @@ struct InstanceInner {
// The ID of the Propolis server (and zone) running this instance
propolis_id: Uuid,

// The IP address of the Propolis server running this instance
propolis_ip: IpAddr,
// The socket address of the Propolis server running this instance
propolis_addr: SocketAddr,

// NIC-related properties
vnic_allocator: VnicAllocator<Etherstub>,
Expand Down Expand Up @@ -662,7 +661,7 @@ impl Instance {
vcpus: hardware.properties.ncpus.0 as u8,
},
propolis_id,
propolis_ip: propolis_addr.ip(),
propolis_addr,
vnic_allocator,
port_manager,
requested_nics: hardware.nics,
Expand Down Expand Up @@ -964,9 +963,13 @@ impl Instance {
.add_property(
"listen_addr",
"astring",
&inner.propolis_ip.to_string(),
&inner.propolis_addr.ip().to_string(),
)
.add_property(
"listen_port",
"astring",
&inner.propolis_addr.port().to_string(),
)
.add_property("listen_port", "astring", &PROPOLIS_PORT.to_string())
.add_property("metric_addr", "astring", &metric_addr.to_string());

let profile = ProfileBuilder::new("omicron").add_service(
Expand All @@ -989,13 +992,11 @@ impl Instance {
.map_err(|_| Error::Timeout(fmri.to_string()))?;
info!(inner.log, "Propolis SMF service is online");

let server_addr = SocketAddr::new(inner.propolis_ip, PROPOLIS_PORT);

// We use a custom client builder here because the default progenitor
// one has a timeout of 15s but we want to be able to wait indefinitely.
let reqwest_client = reqwest::ClientBuilder::new().build().unwrap();
let client = Arc::new(PropolisClient::new_with_client(
&format!("http://{}", server_addr),
&format!("http://{}", &inner.propolis_addr),
reqwest_client,
));

Expand Down

0 comments on commit 4331828

Please sign in to comment.