Skip to content

Commit

Permalink
Integrate dendrite service zones (#1350)
Browse files Browse the repository at this point in the history
* Add support for downloading, installing, and launching the dendrite service zone
  • Loading branch information
Nieuwejaar authored Jul 7, 2022
1 parent 787778b commit 36b54cb
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub const PROPOLIS_PORT: u16 = 12400;
pub const COCKROACH_PORT: u16 = 32221;
pub const CLICKHOUSE_PORT: u16 = 8123;
pub const OXIMETER_PORT: u16 = 12223;
pub const DENDRITE_PORT: u16 = 12224;

pub const NEXUS_INTERNAL_PORT: u16 = 12221;

Expand Down
6 changes: 6 additions & 0 deletions internal-dns-client/src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum ServiceName {
InternalDNS,
Nexus,
Oximeter,
Dendrite,
}

impl fmt::Display for ServiceName {
Expand All @@ -27,6 +28,7 @@ impl fmt::Display for ServiceName {
ServiceName::InternalDNS => write!(f, "internalDNS"),
ServiceName::Nexus => write!(f, "nexus"),
ServiceName::Oximeter => write!(f, "oximeter"),
ServiceName::Dendrite => write!(f, "dendrite"),
}
}
}
Expand Down Expand Up @@ -122,6 +124,10 @@ mod test {
SRV::Service(ServiceName::Oximeter).to_string(),
"_oximeter._tcp.control-plane.oxide.internal",
);
assert_eq!(
SRV::Service(ServiceName::Dendrite).to_string(),
"_dendrite._tcp.control-plane.oxide.internal",
);
}

#[test]
Expand Down
4 changes: 4 additions & 0 deletions nexus/src/db/model/service_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl_enum_type!(
InternalDNS => b"internal_dns"
Nexus => b"nexus"
Oximeter => b"oximeter"
Dendrite => b"dendrite"
);

impl From<internal_api::params::ServiceKind> for ServiceKind {
Expand All @@ -32,6 +33,9 @@ impl From<internal_api::params::ServiceKind> for ServiceKind {
internal_api::params::ServiceKind::Oximeter => {
ServiceKind::Oximeter
}
internal_api::params::ServiceKind::Dendrite => {
ServiceKind::Dendrite
}
}
}
}
3 changes: 3 additions & 0 deletions nexus/src/internal_api/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub enum ServiceKind {
InternalDNS,
Nexus,
Oximeter,
Dendrite,
}

impl fmt::Display for ServiceKind {
Expand All @@ -115,6 +116,7 @@ impl fmt::Display for ServiceKind {
InternalDNS => "internal_dns",
Nexus => "nexus",
Oximeter => "oximeter",
Dendrite => "dendrite",
};
write!(f, "{}", s)
}
Expand All @@ -129,6 +131,7 @@ impl FromStr for ServiceKind {
"nexus" => Ok(Nexus),
"oximeter" => Ok(Oximeter),
"internal_dns" => Ok(InternalDNS),
"dendrite" => Ok(Dendrite),
_ => Err(Self::Err::InternalError {
internal_message: format!("Unknown service kind: {}", s),
}),
Expand Down
3 changes: 2 additions & 1 deletion openapi/nexus-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,8 @@
"enum": [
"internal_d_n_s",
"nexus",
"oximeter"
"oximeter",
"dendrite"
]
},
"ServicePutRequest": {
Expand Down
26 changes: 26 additions & 0 deletions openapi/sled-agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@
}
]
},
"DendriteAsic": {
"type": "string",
"enum": [
"tofino_asic",
"tofino_stub",
"softnpu"
]
},
"DiskEnsureBody": {
"description": "Sent from to a sled agent to establish the runtime state of a Disk",
"type": "object",
Expand Down Expand Up @@ -1211,6 +1219,24 @@
"required": [
"type"
]
},
{
"type": "object",
"properties": {
"asic": {
"$ref": "#/components/schemas/DendriteAsic"
},
"type": {
"type": "string",
"enum": [
"dendrite"
]
}
},
"required": [
"asic",
"type"
]
}
]
},
Expand Down
17 changes: 17 additions & 0 deletions package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,20 @@ commit = "2be097ddd1d3fd8e7f56bc0a4bfd696253b11454"
# The SHA256 digest is automatically posted to:
# https://buildomat.eng.oxide.computer/public/file/oxidecomputer/maghemite/image/<commit>/mg-ddm.sha256.txt
sha256 = "94218915ec6fed75dcc81d736bd5e9ef62c9eb651a67a943b297d94d6b390941"

[external_package.dendrite]
service_name = "dendrite"
zone = true
[external_package.dendrite.source]
# To manually override the package source:
#
# 1. Build the zone image manually
# 1a. cd <dendrite tree>
# 1b. cargo build --features=<tofino_stub|tofino_asic|softnpu>
# 1c. cargo xtask dist -o
# 2. Copy the output zone image from dendrite/out to omicron/out
# 3. Use type = "manual" instead of the "prebuilt"
type = "prebuilt"
repo = "dendrite"
commit = "e752af977c167fa64625231a74bedcbfa5457008"
sha256 = "ddb7c271f4d4b68332adc69b32f90e728f07b1395e01cffd7e71230c2c648c63"
43 changes: 42 additions & 1 deletion sled-agent/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use internal_dns_client::names::{BackendName, ServiceName, AAAA, SRV};
use omicron_common::address::OXIMETER_PORT;
use omicron_common::address::{DENDRITE_PORT, OXIMETER_PORT};
use omicron_common::api::external;
use omicron_common::api::internal::nexus::{
DiskRuntimeState, InstanceRuntimeState,
Expand Down Expand Up @@ -199,6 +199,41 @@ pub struct InstanceSerialConsoleData {
pub last_byte_offset: u64,
}

// The type of networking 'ASIC' the Dendrite service is expected to manage
#[derive(
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Copy, Hash,
)]
#[serde(rename_all = "snake_case")]
pub enum DendriteAsic {
TofinoAsic,
TofinoStub,
Softnpu,
}

impl std::fmt::Display for DendriteAsic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
DendriteAsic::TofinoAsic => "tofino_asic",
DendriteAsic::TofinoStub => "tofino_stub",
DendriteAsic::Softnpu => "softnpu",
}
)
}
}

impl From<DendriteAsic> for sled_agent_client::types::DendriteAsic {
fn from(a: DendriteAsic) -> Self {
match a {
DendriteAsic::TofinoAsic => Self::TofinoAsic,
DendriteAsic::TofinoStub => Self::TofinoStub,
DendriteAsic::Softnpu => Self::Softnpu,
}
}
}

/// The type of a dataset, and an auxiliary information necessary
/// to successfully launch a zone managing the associated data.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
Expand Down Expand Up @@ -306,6 +341,7 @@ pub enum ServiceType {
Nexus { internal_address: SocketAddrV6, external_address: SocketAddr },
InternalDns { server_address: SocketAddrV6, dns_address: SocketAddrV6 },
Oximeter,
Dendrite { asic: DendriteAsic },
}

impl From<ServiceType> for sled_agent_client::types::ServiceType {
Expand All @@ -325,6 +361,7 @@ impl From<ServiceType> for sled_agent_client::types::ServiceType {
}
}
St::Oximeter => AutoSt::Oximeter,
St::Dendrite { asic } => AutoSt::Dendrite { asic: asic.into() },
}
}
}
Expand Down Expand Up @@ -367,6 +404,7 @@ impl ServiceRequest {
}
ServiceType::Nexus { .. } => SRV::Service(ServiceName::Nexus),
ServiceType::Oximeter => SRV::Service(ServiceName::Oximeter),
ServiceType::Dendrite { .. } => SRV::Service(ServiceName::Dendrite),
}
}

Expand All @@ -377,6 +415,9 @@ impl ServiceRequest {
ServiceType::Oximeter => {
SocketAddrV6::new(self.addresses[0], OXIMETER_PORT, 0, 0)
}
ServiceType::Dendrite { .. } => {
SocketAddrV6::new(self.addresses[0], DENDRITE_PORT, 0, 0)
}
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,36 @@ impl ServiceManager {
err,
})?;
}
ServiceType::Dendrite { asic } => {
info!(self.log, "Setting up dendrite service");
running_zone
.run_cmd(&[
crate::illumos::zone::SVCCFG,
"-s",
&smf_name,
"setprop",
&format!("config/asic={}", asic),
])
.map_err(|err| Error::ZoneCommand {
intent: "set dendrite asic type".to_string(),
err,
})?;

running_zone
.run_cmd(&[
crate::illumos::zone::SVCCFG,
"-s",
&default_smf_name,
"refresh",
])
.map_err(|err| Error::ZoneCommand {
intent: format!(
"Refresh SMF manifest {}",
default_smf_name
),
err,
})?;
}
}

debug!(self.log, "enabling service");
Expand Down
9 changes: 9 additions & 0 deletions smf/sled-agent/config-rss.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ addresses = [ "fd00:1122:3344:0101::4" ]
gz_addresses = []
[request.service.service_type]
type = "oximeter"

[[request.service]]
id = "a0fe5ebc-9261-6f77-acc1-972481755789"
name = "dendrite"
addresses = [ "fd00:1122:3344:0101::9" ]
gz_addresses = []
[request.service.service_type]
type = "dendrite"
asic = "tofino_stub"

0 comments on commit 36b54cb

Please sign in to comment.