Skip to content

Commit

Permalink
Merge branch 'main' into clickward
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv authored Aug 27, 2024
2 parents 1de9376 + dd85331 commit a63eb41
Show file tree
Hide file tree
Showing 142 changed files with 8,437 additions and 2,862 deletions.
246 changes: 183 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,12 @@ api_identity = { path = "api_identity" }
approx = "0.5.1"
assert_matches = "1.5.0"
assert_cmd = "2.0.16"
async-bb8-diesel = { git = "https://github.com/oxidecomputer/async-bb8-diesel", rev = "ed7ab5ef0513ba303d33efd41d3e9e381169d59b" }
async-bb8-diesel = "0.2"
async-trait = "0.1.81"
atomicwrites = "0.4.3"
authz-macros = { path = "nexus/authz-macros" }
backoff = { version = "0.4.0", features = [ "tokio" ] }
base64 = "0.22.1"
bb8 = "0.8.5"
bcs = "0.1.6"
bincode = "1.3.3"
bootstore = { path = "bootstore" }
Expand Down Expand Up @@ -452,7 +451,7 @@ omicron-test-utils = { path = "test-utils" }
omicron-workspace-hack = "0.1.0"
omicron-zone-package = "0.11.0"
oxide-client = { path = "clients/oxide-client" }
oxide-vpc = { git = "https://github.com/oxidecomputer/opte", rev = "3dc9a3dd8d3c623f0cf2c659c7119ce0c026a96d", features = [ "api", "std" ] }
oxide-vpc = { git = "https://github.com/oxidecomputer/opte", rev = "76878de67229ea113d70503c441eab47ac5dc653", features = [ "api", "std" ] }
oxlog = { path = "dev-tools/oxlog" }
oxnet = { git = "https://github.com/oxidecomputer/oxnet" }
once_cell = "1.19.0"
Expand All @@ -462,7 +461,7 @@ openapiv3 = "2.0.0"
# must match samael's crate!
openssl = "0.10"
openssl-sys = "0.9"
opte-ioctl = { git = "https://github.com/oxidecomputer/opte", rev = "3dc9a3dd8d3c623f0cf2c659c7119ce0c026a96d" }
opte-ioctl = { git = "https://github.com/oxidecomputer/opte", rev = "76878de67229ea113d70503c441eab47ac5dc653" }
oso = "0.27"
owo-colors = "4.0.0"
oximeter = { path = "oximeter/oximeter" }
Expand Down Expand Up @@ -499,6 +498,7 @@ bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "24a74d0c
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "24a74d0c76b6a63961ecef76acb1516b6e66c5c9" }
propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "24a74d0c76b6a63961ecef76acb1516b6e66c5c9" }
proptest = "1.5.0"
qorb = { git = "https://github.com/oxidecomputer/qorb", branch = "master" }
quote = "1.0"
rand = "0.8.5"
rand_core = "0.6.4"
Expand Down Expand Up @@ -582,7 +582,7 @@ textwrap = "0.16.1"
test-strategy = "0.3.1"
thiserror = "1.0"
tofino = { git = "https://github.com/oxidecomputer/tofino", branch = "main" }
tokio = "1.38.1"
tokio = "1.39.3"
tokio-postgres = { version = "0.7", features = [ "with-chrono-0_4", "with-uuid-1" ] }
tokio-stream = "0.1.15"
tokio-tungstenite = "0.20"
Expand Down
13 changes: 7 additions & 6 deletions clients/nexus-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,11 @@ impl From<omicron_common::api::internal::nexus::VmmRuntimeState>
}
}

impl From<omicron_common::api::internal::nexus::SledInstanceState>
for types::SledInstanceState
impl From<omicron_common::api::internal::nexus::SledVmmState>
for types::SledVmmState
{
fn from(
s: omicron_common::api::internal::nexus::SledInstanceState,
) -> Self {
fn from(s: omicron_common::api::internal::nexus::SledVmmState) -> Self {
Self {
propolis_id: s.propolis_id,
vmm_state: s.vmm_state.into(),
migration_in: s.migration_in.map(Into::into),
migration_out: s.migration_out.map(Into::into),
Expand Down Expand Up @@ -213,6 +210,7 @@ impl From<omicron_common::api::internal::nexus::ProducerKind>
fn from(kind: omicron_common::api::internal::nexus::ProducerKind) -> Self {
use omicron_common::api::internal::nexus::ProducerKind;
match kind {
ProducerKind::ManagementGateway => Self::ManagementGateway,
ProducerKind::SledAgent => Self::SledAgent,
ProducerKind::Service => Self::Service,
ProducerKind::Instance => Self::Instance,
Expand Down Expand Up @@ -390,6 +388,9 @@ impl From<types::ProducerKind>
fn from(kind: types::ProducerKind) -> Self {
use omicron_common::api::internal::nexus::ProducerKind;
match kind {
types::ProducerKind::ManagementGateway => {
ProducerKind::ManagementGateway
}
types::ProducerKind::SledAgent => ProducerKind::SledAgent,
types::ProducerKind::Instance => ProducerKind::Instance,
types::ProducerKind::Service => ProducerKind::Service,
Expand Down
1 change: 1 addition & 0 deletions clients/oximeter-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl From<omicron_common::api::internal::nexus::ProducerKind>
fn from(kind: omicron_common::api::internal::nexus::ProducerKind) -> Self {
use omicron_common::api::internal::nexus;
match kind {
nexus::ProducerKind::ManagementGateway => Self::ManagementGateway,
nexus::ProducerKind::Service => Self::Service,
nexus::ProducerKind::SledAgent => Self::SledAgent,
nexus::ProducerKind::Instance => Self::Instance,
Expand Down
30 changes: 15 additions & 15 deletions clients/sled-agent-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! Interface for making API requests to a Sled Agent
use async_trait::async_trait;
use omicron_uuid_kinds::PropolisUuid;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
Expand Down Expand Up @@ -161,12 +162,11 @@ impl From<types::VmmRuntimeState>
}
}

impl From<types::SledInstanceState>
for omicron_common::api::internal::nexus::SledInstanceState
impl From<types::SledVmmState>
for omicron_common::api::internal::nexus::SledVmmState
{
fn from(s: types::SledInstanceState) -> Self {
fn from(s: types::SledVmmState) -> Self {
Self {
propolis_id: s.propolis_id,
vmm_state: s.vmm_state.into(),
migration_in: s.migration_in.map(Into::into),
migration_out: s.migration_out.map(Into::into),
Expand Down Expand Up @@ -448,33 +448,33 @@ impl From<types::SledIdentifiers>
/// are bonus endpoints, not generated in the real client.
#[async_trait]
pub trait TestInterfaces {
async fn instance_single_step(&self, id: Uuid);
async fn instance_finish_transition(&self, id: Uuid);
async fn instance_simulate_migration_source(
async fn vmm_single_step(&self, id: PropolisUuid);
async fn vmm_finish_transition(&self, id: PropolisUuid);
async fn vmm_simulate_migration_source(
&self,
id: Uuid,
id: PropolisUuid,
params: SimulateMigrationSource,
);
async fn disk_finish_transition(&self, id: Uuid);
}

#[async_trait]
impl TestInterfaces for Client {
async fn instance_single_step(&self, id: Uuid) {
async fn vmm_single_step(&self, id: PropolisUuid) {
let baseurl = self.baseurl();
let client = self.client();
let url = format!("{}/instances/{}/poke-single-step", baseurl, id);
let url = format!("{}/vmms/{}/poke-single-step", baseurl, id);
client
.post(url)
.send()
.await
.expect("instance_single_step() failed unexpectedly");
}

async fn instance_finish_transition(&self, id: Uuid) {
async fn vmm_finish_transition(&self, id: PropolisUuid) {
let baseurl = self.baseurl();
let client = self.client();
let url = format!("{}/instances/{}/poke", baseurl, id);
let url = format!("{}/vmms/{}/poke", baseurl, id);
client
.post(url)
.send()
Expand All @@ -493,14 +493,14 @@ impl TestInterfaces for Client {
.expect("disk_finish_transition() failed unexpectedly");
}

async fn instance_simulate_migration_source(
async fn vmm_simulate_migration_source(
&self,
id: Uuid,
id: PropolisUuid,
params: SimulateMigrationSource,
) {
let baseurl = self.baseurl();
let client = self.client();
let url = format!("{baseurl}/instances/{id}/sim-migration-source");
let url = format!("{baseurl}/vmms/{id}/sim-migration-source");
client
.post(url)
.json(&params)
Expand Down
2 changes: 1 addition & 1 deletion common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2371,7 +2371,7 @@ pub struct SwitchPortLinkConfig {

/// The link-layer discovery protocol service configuration id for this
/// link.
pub lldp_link_config_id: Uuid,
pub lldp_link_config_id: Option<Uuid>,

/// The name of this link.
pub link_name: String,
Expand Down
12 changes: 5 additions & 7 deletions common/src/api/internal/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,9 @@ pub struct VmmRuntimeState {
pub time_updated: DateTime<Utc>,
}

/// A wrapper type containing a sled's total knowledge of the state of a
/// specific VMM and the instance it incarnates.
/// A wrapper type containing a sled's total knowledge of the state of a VMM.
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct SledInstanceState {
/// The ID of the VMM whose state is being reported.
pub propolis_id: PropolisUuid,

pub struct SledVmmState {
/// The most recent state of the sled's VMM process.
pub vmm_state: VmmRuntimeState,

Expand All @@ -142,7 +138,7 @@ impl Migrations<'_> {
}
}

impl SledInstanceState {
impl SledVmmState {
pub fn migrations(&self) -> Migrations<'_> {
Migrations {
migration_in: self.migration_in.as_ref(),
Expand Down Expand Up @@ -223,6 +219,8 @@ pub enum ProducerKind {
Service,
/// The producer is a Propolis VMM managing a guest instance.
Instance,
/// The producer is a management gateway service.
ManagementGateway,
}

/// Information announced by a metric server, used so that clients can contact it and collect
Expand Down
24 changes: 24 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,27 @@ where
async fn never_bail() -> Result<bool, Error> {
Ok(false)
}

/// A wrapper struct that does nothing other than elide the inner value from
/// [`std::fmt::Debug`] output.
///
/// We define this within Omicron instead of using one of the many available
/// crates that do the same thing because it's trivial to do so, and we want the
/// flexibility to add traits to this type without needing to wait on upstream
/// to add an optional dependency.
///
/// If you want to use this for secrets, consider that it might not do
/// everything you expect (it does not zeroize memory on drop, nor get in the
/// way of you removing the inner value from this wrapper struct).
#[derive(
Clone, Copy, serde::Deserialize, serde::Serialize, schemars::JsonSchema,
)]
#[repr(transparent)]
#[serde(transparent)]
pub struct NoDebug<T>(pub T);

impl<T> std::fmt::Debug for NoDebug<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "..")
}
}
1 change: 1 addition & 0 deletions dev-tools/mgs-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ futures.workspace = true
gateway-messages.workspace = true
gateway-test-utils.workspace = true
libc.workspace = true
omicron-gateway.workspace = true
omicron-workspace-hack.workspace = true
signal-hook-tokio.workspace = true
tokio.workspace = true
24 changes: 22 additions & 2 deletions dev-tools/mgs-dev/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use clap::{Args, Parser, Subcommand};
use futures::StreamExt;
use libc::SIGINT;
use signal_hook_tokio::Signals;
use std::net::SocketAddr;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -36,7 +37,12 @@ enum MgsDevCmd {
}

#[derive(Clone, Debug, Args)]
struct MgsRunArgs {}
struct MgsRunArgs {
/// Override the address of the Nexus instance to use when registering the
/// Oximeter producer.
#[clap(long)]
nexus_address: Option<SocketAddr>,
}

impl MgsRunArgs {
async fn exec(&self) -> Result<(), anyhow::Error> {
Expand All @@ -46,9 +52,23 @@ impl MgsRunArgs {
let mut signal_stream = signals.fuse();

println!("mgs-dev: setting up MGS ... ");
let gwtestctx = gateway_test_utils::setup::test_setup(
let (mut mgs_config, sp_sim_config) =
gateway_test_utils::setup::load_test_config();
if let Some(addr) = self.nexus_address {
mgs_config.metrics =
Some(gateway_test_utils::setup::MetricsConfig {
disabled: false,
dev_nexus_address: Some(addr),
dev_bind_loopback: true,
});
}

let gwtestctx = gateway_test_utils::setup::test_setup_with_config(
"mgs-dev",
gateway_messages::SpPort::One,
mgs_config,
&sp_sim_config,
None,
)
.await;
println!("mgs-dev: MGS is running.");
Expand Down
13 changes: 7 additions & 6 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ impl DbUrlOptions {
eprintln!("note: using database URL {}", &db_url);

let db_config = db::Config { url: db_url.clone() };
let pool = Arc::new(db::Pool::new(&log.clone(), &db_config));
let pool =
Arc::new(db::Pool::new_single_host(&log.clone(), &db_config));

// Being a dev tool, we want to try this operation even if the schema
// doesn't match what we expect. So we use `DataStore::new_unchecked()`
Expand Down Expand Up @@ -4224,7 +4225,7 @@ async fn cmd_db_inventory(
}

async fn cmd_db_inventory_baseboard_ids(
conn: &DataStoreConnection<'_>,
conn: &DataStoreConnection,
limit: NonZeroU32,
) -> Result<(), anyhow::Error> {
#[derive(Tabled)]
Expand Down Expand Up @@ -4261,7 +4262,7 @@ async fn cmd_db_inventory_baseboard_ids(
}

async fn cmd_db_inventory_cabooses(
conn: &DataStoreConnection<'_>,
conn: &DataStoreConnection,
limit: NonZeroU32,
) -> Result<(), anyhow::Error> {
#[derive(Tabled)]
Expand Down Expand Up @@ -4302,7 +4303,7 @@ async fn cmd_db_inventory_cabooses(
}

async fn cmd_db_inventory_physical_disks(
conn: &DataStoreConnection<'_>,
conn: &DataStoreConnection,
limit: NonZeroU32,
args: InvPhysicalDisksArgs,
) -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -4359,7 +4360,7 @@ async fn cmd_db_inventory_physical_disks(
}

async fn cmd_db_inventory_rot_pages(
conn: &DataStoreConnection<'_>,
conn: &DataStoreConnection,
limit: NonZeroU32,
) -> Result<(), anyhow::Error> {
#[derive(Tabled)]
Expand Down Expand Up @@ -4394,7 +4395,7 @@ async fn cmd_db_inventory_rot_pages(
}

async fn cmd_db_inventory_collections_list(
conn: &DataStoreConnection<'_>,
conn: &DataStoreConnection,
limit: NonZeroU32,
) -> Result<(), anyhow::Error> {
#[derive(Tabled)]
Expand Down
Loading

0 comments on commit a63eb41

Please sign in to comment.