Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] example of trait-based Dropshot server #5653

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
85 changes: 72 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ members = [
"nexus/db-model",
"nexus/db-queries",
"nexus/defaults",
"nexus/internal-api",
"nexus/inventory",
"nexus/macros-common",
"nexus/metrics-producer-gc",
Expand Down Expand Up @@ -128,6 +129,7 @@ default-members = [
"nexus/db-model",
"nexus/db-queries",
"nexus/defaults",
"nexus/internal-api",
"nexus/inventory",
"nexus/reconfigurator/execution",
"nexus/reconfigurator/planning",
Expand Down Expand Up @@ -277,6 +279,7 @@ nexus-config = { path = "nexus-config" }
nexus-db-model = { path = "nexus/db-model" }
nexus-db-queries = { path = "nexus/db-queries" }
nexus-defaults = { path = "nexus/defaults" }
nexus-internal-api = { path = "nexus/internal-api" }
nexus-inventory = { path = "nexus/inventory" }
nexus-macros-common = { path = "nexus/macros-common" }
nexus-metrics-producer-gc = { path = "nexus/metrics-producer-gc" }
Expand Down Expand Up @@ -619,8 +622,9 @@ opt-level = 3
# It's common during development to use a local copy of various complex
# dependencies. If you want to use those, uncomment one of these blocks.
#
#[patch."https://github.com/oxidecomputer/dropshot"]
[patch."https://github.com/oxidecomputer/dropshot"]
#dropshot = { path = "../dropshot/dropshot" }
dropshot = { git = "https://github.com/oxidecomputer//dropshot", branch = "sunshowers/spr/wip-prototype-for-trait-based-dropshot-servers" }
#[patch.crates-io]
#steno = { path = "../steno" }
#[patch."https://github.com/oxidecomputer/propolis"]
Expand Down
1 change: 1 addition & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ uuid.workspace = true
nexus-defaults.workspace = true
nexus-db-model.workspace = true
nexus-db-queries.workspace = true
nexus-internal-api.workspace = true
nexus-inventory.workspace = true
nexus-metrics-producer-gc.workspace = true
nexus-reconfigurator-execution.workspace = true
Expand Down
23 changes: 23 additions & 0 deletions nexus/db-model/src/external_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use nexus_types::deployment::OmicronZoneExternalSnatIp;
use nexus_types::external_api::params;
use nexus_types::external_api::shared;
use nexus_types::external_api::views;
use nexus_types::external_api::views::ProbeExternalIp;
use nexus_types::external_api::views::ProbeIpKind;
use nexus_types::inventory::SourceNatConfig;
use omicron_common::api::external::Error;
use omicron_common::api::external::IdentityMetadata;
Expand Down Expand Up @@ -90,6 +92,16 @@ impl std::fmt::Display for IpKind {
}
}

impl From<IpKind> for ProbeIpKind {
fn from(kind: IpKind) -> ProbeIpKind {
match kind {
IpKind::Floating => ProbeIpKind::Floating,
IpKind::Ephemeral => ProbeIpKind::Ephemeral,
IpKind::SNat => ProbeIpKind::Snat,
}
}
}

/// The main model type for external IP addresses for instances
/// and externally-facing services.
///
Expand Down Expand Up @@ -140,6 +152,17 @@ pub struct ExternalIp {
pub is_probe: bool,
}

impl From<ExternalIp> for ProbeExternalIp {
fn from(ip: ExternalIp) -> Self {
Self {
ip: ip.ip.ip(),
first_port: ip.first_port.0,
last_port: ip.last_port.0,
kind: ip.kind.into(),
}
}
}

#[derive(Debug, thiserror::Error, SlogInlineError)]
pub enum OmicronZoneExternalIpError {
#[error("database IP is for an instance")]
Expand Down
18 changes: 1 addition & 17 deletions nexus/db-model/src/ipv4_nat_entry.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use std::net::{Ipv4Addr, Ipv6Addr};

use super::MacAddr;
use crate::{
schema::ipv4_nat_changes, schema::ipv4_nat_entry, Ipv4Net, Ipv6Net, SqlU16,
Vni,
};
use chrono::{DateTime, Utc};
use omicron_common::api::external;
use schemars::JsonSchema;
use nexus_types::internal_api::views::Ipv4NatEntryView;
use serde::Deserialize;
use serde::Serialize;
use uuid::Uuid;
Expand Down Expand Up @@ -65,19 +62,6 @@ pub struct Ipv4NatChange {
pub deleted: bool,
}

/// NAT Record
#[derive(Clone, Debug, Serialize, JsonSchema)]
pub struct Ipv4NatEntryView {
pub external_address: Ipv4Addr,
pub first_port: u16,
pub last_port: u16,
pub sled_address: Ipv6Addr,
pub vni: external::Vni,
pub mac: external::MacAddr,
pub gen: i64,
pub deleted: bool,
}

impl From<Ipv4NatChange> for Ipv4NatEntryView {
fn from(value: Ipv4NatChange) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/ipv4_nat_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use diesel::prelude::*;
use diesel::sql_types::BigInt;
use nexus_db_model::ExternalIp;
use nexus_db_model::Ipv4NatChange;
use nexus_db_model::Ipv4NatEntryView;
use nexus_types::internal_api::views::Ipv4NatEntryView;
use omicron_common::api::external::CreateResult;
use omicron_common::api::external::DeleteResult;
use omicron_common::api::external::Error;
Expand Down
1 change: 0 additions & 1 deletion nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ pub use dns::DnsVersionUpdateBuilder;
pub use instance::InstanceAndActiveVmm;
pub use inventory::DataStoreInventoryTest;
use nexus_db_model::AllSchemaVersions;
pub use probe::ProbeInfo;
pub use rack::RackInit;
pub use silo::Discoverability;
pub use switch_port::SwitchPortSettingsCombinedResult;
Expand Down
Loading
Loading