Skip to content

Commit

Permalink
Merge branch 'explicit-datasets' into inventory-datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Aug 10, 2024
2 parents 5a91c8f + 3e14cc4 commit 4d41c5c
Show file tree
Hide file tree
Showing 133 changed files with 13,315 additions and 4,274 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hakari.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
toolchain: stable
- name: Install cargo-hakari
uses: taiki-e/install-action@d79dff47733726f636463323dd2d82724f6c36ba # v2
uses: taiki-e/install-action@ada21a86dcbd8480ccdd77e11e167f51a002fb3e # v2
with:
tool: cargo-hakari
- name: Check workspace-hack Cargo.toml is up-to-date
Expand Down
52 changes: 32 additions & 20 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ db-macros = { path = "nexus/db-macros" }
debug-ignore = "1.0.5"
derive_more = "0.99.18"
derive-where = "1.2.7"
diesel = { version = "2.1.6", features = ["postgres", "r2d2", "chrono", "serde_json", "network-address", "uuid"] }
# Having the i-implement-... feature here makes diesel go away from the workspace-hack
diesel = { version = "2.2.2", features = ["i-implement-a-third-party-backend-and-opt-into-breaking-changes", "postgres", "r2d2", "chrono", "serde_json", "network-address", "uuid"] }
diesel-dtrace = { git = "https://github.com/oxidecomputer/diesel-dtrace", branch = "main" }
dns-server = { path = "dns-server" }
dns-server-api = { path = "dns-server-api" }
Expand Down Expand Up @@ -385,7 +386,7 @@ libnvme = { git = "https://github.com/oxidecomputer/libnvme", rev = "dd5bb221d32
linear-map = "1.2.0"
macaddr = { version = "1.0.1", features = ["serde_std"] }
maplit = "1.0.2"
mockall = "0.12"
mockall = "0.13"
newtype_derive = "0.1.6"
mg-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "220dd026e83142b83bd93123f465a64dd4600201" }
ddm-admin-client = { git = "https://github.com/oxidecomputer/maghemite", rev = "220dd026e83142b83bd93123f465a64dd4600201" }
Expand Down Expand Up @@ -470,7 +471,7 @@ progenitor-client = { git = "https://github.com/oxidecomputer/progenitor", branc
bhyve_api = { git = "https://github.com/oxidecomputer/propolis", rev = "24a74d0c76b6a63961ecef76acb1516b6e66c5c9" }
propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "24a74d0c76b6a63961ecef76acb1516b6e66c5c9" }
propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "24a74d0c76b6a63961ecef76acb1516b6e66c5c9" }
proptest = "1.4.0"
proptest = "1.5.0"
quote = "1.0"
rand = "0.8.5"
rand_core = "0.6.4"
Expand Down
2 changes: 1 addition & 1 deletion clients/gateway-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ progenitor::generate_api!(
HostPhase2RecoveryImageId = { derives = [PartialEq, Eq, PartialOrd, Ord] },
ImageVersion = { derives = [PartialEq, Eq, PartialOrd, Ord] },
RotImageDetails = { derives = [PartialEq, Eq, PartialOrd, Ord] },
RotImageError = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize] },
RotImageError = { derives = [ PartialEq, Eq, PartialOrd, Ord] },
RotSlot = { derives = [PartialEq, Eq, PartialOrd, Ord] },
RotState = { derives = [PartialEq, Eq, PartialOrd, Ord] },
SpIdentifier = { derives = [Copy, PartialEq, Hash, Eq] },
Expand Down
33 changes: 2 additions & 31 deletions clients/nexus-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,6 @@ impl From<types::VmmState> for omicron_common::api::internal::nexus::VmmState {
}
}

impl From<omicron_common::api::internal::nexus::InstanceRuntimeState>
for types::InstanceRuntimeState
{
fn from(
s: omicron_common::api::internal::nexus::InstanceRuntimeState,
) -> Self {
Self {
dst_propolis_id: s.dst_propolis_id,
gen: s.gen,
migration_id: s.migration_id,
propolis_id: s.propolis_id,
time_updated: s.time_updated,
}
}
}

impl From<omicron_common::api::internal::nexus::VmmRuntimeState>
for types::VmmRuntimeState
{
Expand All @@ -153,10 +137,10 @@ impl From<omicron_common::api::internal::nexus::SledInstanceState>
s: omicron_common::api::internal::nexus::SledInstanceState,
) -> Self {
Self {
instance_state: s.instance_state.into(),
propolis_id: s.propolis_id,
vmm_state: s.vmm_state.into(),
migration_state: s.migration_state.map(Into::into),
migration_in: s.migration_in.map(Into::into),
migration_out: s.migration_out.map(Into::into),
}
}
}
Expand All @@ -169,26 +153,13 @@ impl From<omicron_common::api::internal::nexus::MigrationRuntimeState>
) -> Self {
Self {
migration_id: s.migration_id,
role: s.role.into(),
state: s.state.into(),
gen: s.gen,
time_updated: s.time_updated,
}
}
}

impl From<omicron_common::api::internal::nexus::MigrationRole>
for types::MigrationRole
{
fn from(s: omicron_common::api::internal::nexus::MigrationRole) -> Self {
use omicron_common::api::internal::nexus::MigrationRole as Input;
match s {
Input::Source => Self::Source,
Input::Target => Self::Target,
}
}
}

impl From<omicron_common::api::internal::nexus::MigrationState>
for types::MigrationState
{
Expand Down
80 changes: 65 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,9 @@
//! Interface for making API requests to a Sled Agent
use async_trait::async_trait;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
use std::convert::TryFrom;
use uuid::Uuid;

Expand Down Expand Up @@ -38,6 +41,7 @@ progenitor::generate_api!(
replace = {
Baseboard = nexus_sled_agent_shared::inventory::Baseboard,
ByteCount = omicron_common::api::external::ByteCount,
DatasetKind = omicron_common::api::internal::shared::DatasetKind,
DiskIdentity = omicron_common::disk::DiskIdentity,
DiskVariant = omicron_common::disk::DiskVariant,
Generation = omicron_common::api::external::Generation,
Expand Down Expand Up @@ -163,10 +167,10 @@ impl From<types::SledInstanceState>
{
fn from(s: types::SledInstanceState) -> Self {
Self {
instance_state: s.instance_state.into(),
propolis_id: s.propolis_id,
vmm_state: s.vmm_state.into(),
migration_state: s.migration_state.map(Into::into),
migration_in: s.migration_in.map(Into::into),
migration_out: s.migration_out.map(Into::into),
}
}
}
Expand All @@ -178,25 +182,12 @@ impl From<types::MigrationRuntimeState>
Self {
migration_id: s.migration_id,
state: s.state.into(),
role: s.role.into(),
gen: s.gen,
time_updated: s.time_updated,
}
}
}

impl From<types::MigrationRole>
for omicron_common::api::internal::nexus::MigrationRole
{
fn from(r: types::MigrationRole) -> Self {
use omicron_common::api::internal::nexus::MigrationRole as Output;
match r {
types::MigrationRole::Source => Output::Source,
types::MigrationRole::Target => Output::Target,
}
}
}

impl From<types::MigrationState>
for omicron_common::api::internal::nexus::MigrationState
{
Expand Down Expand Up @@ -458,12 +449,29 @@ 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(
&self,
id: Uuid,
params: SimulateMigrationSource,
);
async fn disk_finish_transition(&self, id: Uuid);
}

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

async fn instance_finish_transition(&self, id: Uuid) {
let baseurl = self.baseurl();
let client = self.client();
Expand All @@ -485,4 +493,46 @@ impl TestInterfaces for Client {
.await
.expect("disk_finish_transition() failed unexpectedly");
}

async fn instance_simulate_migration_source(
&self,
id: Uuid,
params: SimulateMigrationSource,
) {
let baseurl = self.baseurl();
let client = self.client();
let url = format!("{baseurl}/instances/{id}/sim-migration-source");
client
.post(url)
.json(&params)
.send()
.await
.expect("instance_simulate_migration_source() failed unexpectedly");
}
}

/// Parameters to the `/instances/{id}/sim-migration-source` test API.
///
/// This message type is not included in the OpenAPI spec, because this API
/// exists only in test builds.
#[derive(Serialize, Deserialize, JsonSchema)]
pub struct SimulateMigrationSource {
/// The ID of the migration out of the instance's current active VMM.
pub migration_id: Uuid,
/// What migration result (success or failure) to simulate.
pub result: SimulatedMigrationResult,
}

/// The result of a simulated migration out from an instance's current active
/// VMM.
#[derive(Serialize, Deserialize, JsonSchema)]
pub enum SimulatedMigrationResult {
/// Simulate a successful migration out.
Success,
/// Simulate a failed migration out.
///
/// # Note
///
/// This is not currently implemented by the simulated sled-agent.
Failure,
}
Loading

0 comments on commit 4d41c5c

Please sign in to comment.