Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions nexus/mgs-updates/src/test_util/host_phase_2_test_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ mod api_impl {
use omicron_common::api::internal::shared::{
ResolvedVpcRouteSet, ResolvedVpcRouteState, SwitchPorts,
};
use sled_agent_api::v7::InstanceEnsureBody;
use sled_agent_api::v7::InstanceMulticastBody;
use sled_agent_api::*;
use sled_agent_types::bootstore::BootstoreStatus;
use sled_agent_types::disk::DiskEnsureBody;
use sled_agent_types::early_networking::EarlyNetworkConfig;
use sled_agent_types::firewall_rules::VpcFirewallRulesEnsureBody;
use sled_agent_types::instance::InstanceEnsureBody;
use sled_agent_types::instance::InstanceExternalIpBody;
use sled_agent_types::instance::InstanceMulticastBody;
use sled_agent_types::instance::VmmPutStateBody;
use sled_agent_types::instance::VmmPutStateResponse;
use sled_agent_types::instance::VmmUnregisterResponse;
Expand Down Expand Up @@ -531,15 +531,7 @@ mod api_impl {
unimplemented!()
}

async fn vmm_register_v1(
_rqctx: RequestContext<Self::Context>,
_path_params: Path<VmmPathParam>,
_body: TypedBody<sled_agent_types::instance::InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError> {
unimplemented!()
}

async fn vmm_register_v7(
async fn vmm_register(
_rqctx: RequestContext<Self::Context>,
_path_params: Path<VmmPathParam>,
_body: TypedBody<InstanceEnsureBody>,
Expand Down
22 changes: 12 additions & 10 deletions sled-agent/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ use sled_agent_types::{
early_networking::EarlyNetworkConfig,
firewall_rules::VpcFirewallRulesEnsureBody,
instance::{
InstanceExternalIpBody, VmmPutStateBody, VmmPutStateResponse,
VmmUnregisterResponse,
InstanceEnsureBody, InstanceExternalIpBody, InstanceMulticastBody,
VmmPutStateBody, VmmPutStateResponse, VmmUnregisterResponse,
},
sled::AddSledRequest,
zone_bundle::{
Expand All @@ -55,8 +55,8 @@ use uuid::Uuid;

/// Copies of data types that changed between v3 and v4.
mod v3;
/// Copies of data types that changed between previous versions and v7.
pub mod v7;
/// Copies of data types that changed between previous versions and v6.
mod v6;

api_versions!([
// WHEN CHANGING THE API (part 1 of 2):
Expand Down Expand Up @@ -368,19 +368,21 @@ pub trait SledAgentApi {
async fn vmm_register_v1(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_types::instance::InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError>;
body: TypedBody<v6::InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError> {
Self::vmm_register(rqctx, path_params, body.map(Into::into)).await
}

#[endpoint {
method = PUT,
path = "/vmms/{propolis_id}",
operation_id = "vmm_register",
versions = VERSION_MULTICAST_SUPPORT..
}]
async fn vmm_register_v7(
async fn vmm_register(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<v7::InstanceEnsureBody>,
body: TypedBody<InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError>;

#[endpoint {
Expand Down Expand Up @@ -439,7 +441,7 @@ pub trait SledAgentApi {
async fn vmm_join_multicast_group(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<v7::InstanceMulticastBody>,
body: TypedBody<InstanceMulticastBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

#[endpoint {
Expand All @@ -450,7 +452,7 @@ pub trait SledAgentApi {
async fn vmm_leave_multicast_group(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<v7::InstanceMulticastBody>,
body: TypedBody<InstanceMulticastBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError>;

#[endpoint {
Expand Down
46 changes: 27 additions & 19 deletions sled-agent/api/src/v7.rs → sled-agent/api/src/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use uuid::Uuid;
use sled_agent_types::instance::{InstanceMetadata, VmmSpec};

/// The body of a request to ensure that a instance and VMM are known to a sled
/// agent (version 7, with multicast support).
/// agent.
#[derive(Serialize, Deserialize, JsonSchema)]
pub struct InstanceEnsureBody {
/// The virtual hardware configuration this virtual machine should have when
Expand Down Expand Up @@ -56,7 +56,7 @@ pub struct InstanceEnsureBody {
}

/// Describes sled-local configuration that a sled-agent must establish to make
/// the instance's virtual hardware fully functional (version 7, with multicast).
/// the instance's virtual hardware fully functional.
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub struct InstanceSledLocalConfig {
pub hostname: Hostname,
Expand All @@ -66,25 +66,33 @@ pub struct InstanceSledLocalConfig {
/// provided to an instance to allow inbound connectivity.
pub ephemeral_ip: Option<IpAddr>,
pub floating_ips: Vec<IpAddr>,
pub multicast_groups: Vec<InstanceMulticastMembership>,
pub firewall_rules: Vec<ResolvedVpcFirewallRule>,
pub dhcp_config: DhcpConfig,
}

/// Represents a multicast group membership for an instance.
#[derive(
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
)]
pub struct InstanceMulticastMembership {
pub group_ip: IpAddr,
// For Source-Specific Multicast (SSM)
pub sources: Vec<IpAddr>,
}

/// Request body for multicast group operations.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum InstanceMulticastBody {
Join(InstanceMulticastMembership),
Leave(InstanceMulticastMembership),
impl From<InstanceEnsureBody>
for sled_agent_types::instance::InstanceEnsureBody
{
fn from(
v6: InstanceEnsureBody,
) -> sled_agent_types::instance::InstanceEnsureBody {
sled_agent_types::instance::InstanceEnsureBody {
vmm_spec: v6.vmm_spec,
local_config: sled_agent_types::instance::InstanceSledLocalConfig {
hostname: v6.local_config.hostname,
nics: v6.local_config.nics,
source_nat: v6.local_config.source_nat,
ephemeral_ip: v6.local_config.ephemeral_ip,
floating_ips: v6.local_config.floating_ips,
multicast_groups: Vec::new(),
firewall_rules: v6.local_config.firewall_rules,
dhcp_config: v6.local_config.dhcp_config,
},
vmm_runtime: v6.vmm_runtime,
instance_id: v6.instance_id,
migration_id: v6.migration_id,
propolis_addr: v6.propolis_addr,
metadata: v6.metadata,
}
}
}
27 changes: 7 additions & 20 deletions sled-agent/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use sled_agent_types::disk::DiskEnsureBody;
use sled_agent_types::early_networking::EarlyNetworkConfig;
use sled_agent_types::firewall_rules::VpcFirewallRulesEnsureBody;
use sled_agent_types::instance::{
InstanceExternalIpBody, VmmPutStateBody, VmmPutStateResponse,
VmmUnregisterResponse,
InstanceEnsureBody, InstanceExternalIpBody, InstanceMulticastBody,
VmmPutStateBody, VmmPutStateResponse, VmmUnregisterResponse,
};
use sled_agent_types::probes::ProbeSet;
use sled_agent_types::sled::AddSledRequest;
Expand Down Expand Up @@ -489,29 +489,16 @@ impl SledAgentApi for SledAgentImpl {
Ok(HttpResponseOk(sa.get_role()))
}

async fn vmm_register_v1(
async fn vmm_register(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_types::instance::InstanceEnsureBody>,
body: TypedBody<InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError> {
let sa = rqctx.context();
let propolis_id = path_params.into_inner().propolis_id;
let body_args = body.into_inner();
Ok(HttpResponseOk(
sa.instance_ensure_registered_v1(propolis_id, body_args).await?,
))
}

async fn vmm_register_v7(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_api::v7::InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError> {
let sa = rqctx.context();
let propolis_id = path_params.into_inner().propolis_id;
let body_args = body.into_inner();
Ok(HttpResponseOk(
sa.instance_ensure_registered_v7(propolis_id, body_args).await?,
sa.instance_ensure_registered(propolis_id, body_args).await?,
))
}

Expand Down Expand Up @@ -571,7 +558,7 @@ impl SledAgentApi for SledAgentImpl {
async fn vmm_join_multicast_group(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_api::v7::InstanceMulticastBody>,
body: TypedBody<InstanceMulticastBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let sa = rqctx.context();
let id = path_params.into_inner().propolis_id;
Expand All @@ -583,7 +570,7 @@ impl SledAgentApi for SledAgentImpl {
async fn vmm_leave_multicast_group(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_api::v7::InstanceMulticastBody>,
body: TypedBody<InstanceMulticastBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let sa = rqctx.context();
let id = path_params.into_inner().propolis_id;
Expand Down
4 changes: 0 additions & 4 deletions sled-agent/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ use propolis_client::Client as PropolisClient;
use propolis_client::instance_spec::{ComponentV0, SpecKey};
use rand::SeedableRng;
use rand::prelude::IteratorRandom;
use sled_agent_api::v7::{
InstanceMulticastMembership, InstanceSledLocalConfig,
};
use sled_agent_config_reconciler::AvailableDatasetsReceiver;
use sled_agent_types::instance::*;
use sled_agent_types::zone_bundle::ZoneBundleCause;
Expand Down Expand Up @@ -2491,7 +2488,6 @@ mod tests {
use propolis_client::types::{
InstanceMigrateStatusResponse, InstanceStateMonitorResponse,
};
use sled_agent_api::v7::InstanceEnsureBody;
use sled_agent_config_reconciler::{
CurrentlyManagedZpoolsReceiver, InternalDiskDetails,
InternalDisksReceiver,
Expand Down
1 change: 0 additions & 1 deletion sled-agent/src/instance_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use omicron_common::api::external::ByteCount;
use omicron_common::api::internal::nexus::SledVmmState;
use omicron_common::api::internal::shared::SledIdentifiers;
use omicron_uuid_kinds::PropolisUuid;
use sled_agent_api::v7::{InstanceEnsureBody, InstanceMulticastBody};
use sled_agent_config_reconciler::AvailableDatasetsReceiver;
use sled_agent_config_reconciler::CurrentlyManagedZpoolsReceiver;
use sled_agent_types::instance::*;
Expand Down
20 changes: 4 additions & 16 deletions sled-agent/src/sim/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ use omicron_common::api::internal::shared::{
ResolvedVpcRouteSet, ResolvedVpcRouteState, SwitchPorts,
};
use range_requests::PotentialRange;
use sled_agent_api::v7::InstanceMulticastBody;
use sled_agent_api::*;
use sled_agent_types::bootstore::BootstoreStatus;
use sled_agent_types::disk::DiskEnsureBody;
use sled_agent_types::early_networking::EarlyNetworkConfig;
use sled_agent_types::firewall_rules::VpcFirewallRulesEnsureBody;
use sled_agent_types::instance::InstanceEnsureBody;
use sled_agent_types::instance::InstanceExternalIpBody;
use sled_agent_types::instance::InstanceMulticastBody;
use sled_agent_types::instance::VmmPutStateBody;
use sled_agent_types::instance::VmmPutStateResponse;
use sled_agent_types::instance::VmmUnregisterResponse;
Expand Down Expand Up @@ -82,23 +83,10 @@ enum SledAgentSimImpl {}
impl SledAgentApi for SledAgentSimImpl {
type Context = Arc<SledAgent>;

async fn vmm_register_v1(
async fn vmm_register(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_types::instance::InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError> {
let sa = rqctx.context();
let propolis_id = path_params.into_inner().propolis_id;
let body_args = body.into_inner();
Ok(HttpResponseOk(
sa.instance_register_v1(propolis_id, body_args).await?,
))
}

async fn vmm_register_v7(
rqctx: RequestContext<Self::Context>,
path_params: Path<VmmPathParam>,
body: TypedBody<sled_agent_api::v7::InstanceEnsureBody>,
body: TypedBody<InstanceEnsureBody>,
) -> Result<HttpResponseOk<SledVmmState>, HttpError> {
let sa = rqctx.context();
let propolis_id = path_params.into_inner().propolis_id;
Expand Down
44 changes: 6 additions & 38 deletions sled-agent/src/sim/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ use propolis_client::{
};
use range_requests::PotentialRange;
use sled_agent_api::SupportBundleMetadata;
use sled_agent_api::v7::InstanceMulticastMembership;
use sled_agent_types::disk::DiskStateRequested;
use sled_agent_types::early_networking::{
EarlyNetworkConfig, EarlyNetworkConfigBody,
};
use sled_agent_types::instance::{
InstanceExternalIpBody, VmmPutStateResponse, VmmStateRequested,
VmmUnregisterResponse,
InstanceEnsureBody, InstanceExternalIpBody, InstanceMulticastMembership,
VmmPutStateResponse, VmmStateRequested, VmmUnregisterResponse,
};

use slog::Logger;
Expand Down Expand Up @@ -200,43 +199,12 @@ impl SledAgent {
})
}

/// Idempotently ensures that the given API Instance (described by
/// `api_instance`) exists on this server in the given runtime state
/// (described by `target`).
// Keep the v1 method for compatibility but it just delegates to v2
pub async fn instance_register_v1(
self: &Arc<Self>,
propolis_id: PropolisUuid,
instance: sled_agent_types::instance::InstanceEnsureBody,
) -> Result<SledVmmState, Error> {
// Convert v1 to v7 for internal processing
let v5_instance = sled_agent_api::v7::InstanceEnsureBody {
vmm_spec: instance.vmm_spec,
local_config: sled_agent_api::v7::InstanceSledLocalConfig {
hostname: instance.local_config.hostname,
nics: instance.local_config.nics,
source_nat: instance.local_config.source_nat,
ephemeral_ip: instance.local_config.ephemeral_ip,
floating_ips: instance.local_config.floating_ips,
multicast_groups: Vec::new(), // v1 doesn't support multicast
firewall_rules: instance.local_config.firewall_rules,
dhcp_config: instance.local_config.dhcp_config,
},
vmm_runtime: instance.vmm_runtime,
instance_id: instance.instance_id,
migration_id: instance.migration_id,
propolis_addr: instance.propolis_addr,
metadata: instance.metadata,
};
self.instance_register(propolis_id, v5_instance).await
}

pub async fn instance_register(
self: &Arc<Self>,
propolis_id: PropolisUuid,
instance: sled_agent_api::v7::InstanceEnsureBody,
instance: InstanceEnsureBody,
) -> Result<SledVmmState, Error> {
let sled_agent_api::v7::InstanceEnsureBody {
let InstanceEnsureBody {
vmm_spec,
local_config,
instance_id,
Expand Down Expand Up @@ -722,7 +690,7 @@ impl SledAgent {
pub async fn instance_join_multicast_group(
&self,
propolis_id: PropolisUuid,
membership: &sled_agent_api::v7::InstanceMulticastMembership,
membership: &InstanceMulticastMembership,
) -> Result<(), Error> {
if !self.vmms.contains_key(&propolis_id.into_untyped_uuid()).await {
return Err(Error::internal_error(
Expand All @@ -741,7 +709,7 @@ impl SledAgent {
pub async fn instance_leave_multicast_group(
&self,
propolis_id: PropolisUuid,
membership: &sled_agent_api::v7::InstanceMulticastMembership,
membership: &InstanceMulticastMembership,
) -> Result<(), Error> {
if !self.vmms.contains_key(&propolis_id.into_untyped_uuid()).await {
return Err(Error::internal_error(
Expand Down
Loading
Loading