Skip to content

Commit f53eb00

Browse files
authored
[2/n] move instance_migrate and APIs used by tests/omdb from nexus-internal to nexus-lockstep (#9037)
Part of #8902. Stacked on #8983.
1 parent e76962a commit f53eb00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+12613
-9302
lines changed

Cargo.lock

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/nexus-client/src/lib.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
//! Interface for making API requests to the Oxide control plane at large
66
//! from within the control plane
77
8-
use iddqd::IdOrdItem;
9-
use iddqd::id_upcast;
108
use std::collections::HashMap;
11-
use uuid::Uuid;
129

1310
progenitor::generate_api!(
1411
spec = "../../openapi/nexus-internal.json",
@@ -38,35 +35,24 @@ progenitor::generate_api!(
3835
BlueprintPhysicalDiskDisposition = nexus_types::deployment::BlueprintPhysicalDiskDisposition,
3936
BlueprintZoneImageSource = nexus_types::deployment::BlueprintZoneImageSource,
4037
Certificate = omicron_common::api::internal::nexus::Certificate,
41-
ClickhouseMode = nexus_types::deployment::ClickhouseMode,
42-
ClickhousePolicy = nexus_types::deployment::ClickhousePolicy,
4338
DatasetKind = omicron_common::api::internal::shared::DatasetKind,
4439
DnsConfigParams = nexus_types::internal_api::params::DnsConfigParams,
4540
DnsConfigZone = nexus_types::internal_api::params::DnsConfigZone,
4641
DnsRecord = nexus_types::internal_api::params::DnsRecord,
4742
Generation = omicron_common::api::external::Generation,
4843
ImportExportPolicy = omicron_common::api::external::ImportExportPolicy,
4944
MacAddr = omicron_common::api::external::MacAddr,
50-
MgsUpdateDriverStatus = nexus_types::internal_api::views::MgsUpdateDriverStatus,
5145
Name = omicron_common::api::external::Name,
5246
NetworkInterface = omicron_common::api::internal::shared::NetworkInterface,
5347
NetworkInterfaceKind = omicron_common::api::internal::shared::NetworkInterfaceKind,
5448
NewPasswordHash = omicron_passwords::NewPasswordHash,
55-
OmicronPhysicalDiskConfig = omicron_common::disk::OmicronPhysicalDiskConfig,
56-
OmicronPhysicalDisksConfig = omicron_common::disk::OmicronPhysicalDisksConfig,
5749
OximeterReadMode = nexus_types::deployment::OximeterReadMode,
58-
OximeterReadPolicy = nexus_types::deployment::OximeterReadPolicy,
5950
PendingMgsUpdate = nexus_types::deployment::PendingMgsUpdate,
6051
PlannerConfig = nexus_types::deployment::PlannerConfig,
61-
ReconfiguratorConfig = nexus_types::deployment::ReconfiguratorConfig,
62-
ReconfiguratorConfigParam = nexus_types::deployment::ReconfiguratorConfigParam,
63-
ReconfiguratorConfigView = nexus_types::deployment::ReconfiguratorConfigView,
6452
RecoverySiloConfig = nexus_sled_agent_shared::recovery_silo::RecoverySiloConfig,
6553
Srv = nexus_types::internal_api::params::Srv,
6654
TypedUuidForBlueprintKind = omicron_uuid_kinds::BlueprintUuid,
67-
TypedUuidForCollectionKind = omicron_uuid_kinds::CollectionUuid,
6855
TypedUuidForDatasetKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::DatasetKind>,
69-
TypedUuidForDemoSagaKind = omicron_uuid_kinds::DemoSagaUuid,
7056
TypedUuidForDownstairsKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::DownstairsKind>,
7157
TypedUuidForPhysicalDiskKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::PhysicalDiskKind>,
7258
TypedUuidForPropolisKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::PropolisKind>,
@@ -76,9 +62,6 @@ progenitor::generate_api!(
7662
TypedUuidForUpstairsSessionKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::UpstairsSessionKind>,
7763
TypedUuidForVolumeKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::VolumeKind>,
7864
TypedUuidForZpoolKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::ZpoolKind>,
79-
UpdateStatus = nexus_types::internal_api::views::UpdateStatus,
80-
ZoneStatus = nexus_types::internal_api::views::ZoneStatus,
81-
ZoneStatusVersion = nexus_types::internal_api::views::ZoneStatusVersion,
8265
ZpoolName = omicron_common::zpool_name::ZpoolName,
8366
},
8467
patch = {
@@ -88,26 +71,6 @@ progenitor::generate_api!(
8871
}
8972
);
9073

91-
impl IdOrdItem for types::PendingSagaInfo {
92-
type Key<'a> = Uuid;
93-
94-
fn key(&self) -> Self::Key<'_> {
95-
self.saga_id
96-
}
97-
98-
id_upcast!();
99-
}
100-
101-
impl IdOrdItem for types::HeldDbClaimInfo {
102-
type Key<'a> = u64;
103-
104-
fn key(&self) -> Self::Key<'_> {
105-
self.id
106-
}
107-
108-
id_upcast!();
109-
}
110-
11174
impl omicron_common::api::external::ClientError for types::Error {
11275
fn message(&self) -> String {
11376
self.message.clone()

clients/nexus-lockstep-client/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ workspace = true
1010
[dependencies]
1111
chrono.workspace = true
1212
futures.workspace = true
13+
iddqd.workspace = true
14+
nexus-types.workspace = true
15+
omicron-common.workspace = true
16+
omicron-uuid-kinds.workspace = true
1317
omicron-workspace-hack.workspace = true
18+
oxnet.workspace = true
1419
progenitor.workspace = true
1520
regress.workspace = true
1621
reqwest.workspace = true
1722
schemars.workspace = true
1823
serde.workspace = true
24+
serde_json.workspace = true
1925
slog.workspace = true
2026
uuid.workspace = true

clients/nexus-lockstep-client/src/lib.rs

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
//! callers that update in lockstep with Nexus itself (e.g. rack initialization,
77
//! tests and debugging)
88
9+
use iddqd::IdOrdItem;
10+
use iddqd::id_upcast;
11+
use uuid::Uuid;
12+
913
progenitor::generate_api!(
1014
spec = "../../openapi/nexus-lockstep.json",
1115
interface = Positional,
12-
derives = [schemars::JsonSchema],
16+
derives = [schemars::JsonSchema, PartialEq],
1317
inner_type = slog::Logger,
1418
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {
1519
slog::debug!(log, "client request";
@@ -21,4 +25,82 @@ progenitor::generate_api!(
2125
post_hook = (|log: &slog::Logger, result: &Result<_, _>| {
2226
slog::debug!(log, "client response"; "result" => ?result);
2327
}),
28+
crates = {
29+
"iddqd" = "*",
30+
"oxnet" = "0.1.0",
31+
},
32+
replace = {
33+
// It's kind of unfortunate to pull in such a complex and unstable type
34+
// as "blueprint" this way, but we have really useful functionality
35+
// (e.g., diff'ing) that's implemented on our local type.
36+
Blueprint = nexus_types::deployment::Blueprint,
37+
BlueprintPhysicalDiskConfig = nexus_types::deployment::BlueprintPhysicalDiskConfig,
38+
BlueprintPhysicalDiskDisposition = nexus_types::deployment::BlueprintPhysicalDiskDisposition,
39+
BlueprintZoneImageSource = nexus_types::deployment::BlueprintZoneImageSource,
40+
ClickhouseMode = nexus_types::deployment::ClickhouseMode,
41+
ClickhousePolicy = nexus_types::deployment::ClickhousePolicy,
42+
DatasetKind = omicron_common::api::internal::shared::DatasetKind,
43+
Generation = omicron_common::api::external::Generation,
44+
MacAddr = omicron_common::api::external::MacAddr,
45+
MgsUpdateDriverStatus = nexus_types::internal_api::views::MgsUpdateDriverStatus,
46+
Name = omicron_common::api::external::Name,
47+
NetworkInterface = omicron_common::api::internal::shared::NetworkInterface,
48+
NetworkInterfaceKind = omicron_common::api::internal::shared::NetworkInterfaceKind,
49+
OmicronPhysicalDiskConfig = omicron_common::disk::OmicronPhysicalDiskConfig,
50+
OmicronPhysicalDisksConfig = omicron_common::disk::OmicronPhysicalDisksConfig,
51+
OximeterReadMode = nexus_types::deployment::OximeterReadMode,
52+
OximeterReadPolicy = nexus_types::deployment::OximeterReadPolicy,
53+
PendingMgsUpdate = nexus_types::deployment::PendingMgsUpdate,
54+
ReconfiguratorConfig = nexus_types::deployment::ReconfiguratorConfig,
55+
ReconfiguratorConfigParam = nexus_types::deployment::ReconfiguratorConfigParam,
56+
ReconfiguratorConfigView = nexus_types::deployment::ReconfiguratorConfigView,
57+
TypedUuidForBlueprintKind = omicron_uuid_kinds::BlueprintUuid,
58+
TypedUuidForDatasetKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::DatasetKind>,
59+
TypedUuidForDemoSagaKind = omicron_uuid_kinds::DemoSagaUuid,
60+
TypedUuidForPhysicalDiskKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::PhysicalDiskKind>,
61+
TypedUuidForSledKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::SledKind>,
62+
TypedUuidForZpoolKind = omicron_uuid_kinds::TypedUuid<omicron_uuid_kinds::ZpoolKind>,
63+
UpdateStatus = nexus_types::internal_api::views::UpdateStatus,
64+
ZoneStatus = nexus_types::internal_api::views::ZoneStatus,
65+
ZoneStatusVersion = nexus_types::internal_api::views::ZoneStatusVersion,
66+
ZpoolName = omicron_common::zpool_name::ZpoolName,
67+
},
68+
patch = {
69+
ByteCount = { derives = [PartialEq, Eq] },
70+
Baseboard = { derives = [PartialEq, Eq] }
71+
}
2472
);
73+
74+
impl IdOrdItem for types::PendingSagaInfo {
75+
type Key<'a> = Uuid;
76+
77+
fn key(&self) -> Self::Key<'_> {
78+
self.saga_id
79+
}
80+
81+
id_upcast!();
82+
}
83+
84+
impl IdOrdItem for types::HeldDbClaimInfo {
85+
type Key<'a> = u64;
86+
87+
fn key(&self) -> Self::Key<'_> {
88+
self.id
89+
}
90+
91+
id_upcast!();
92+
}
93+
94+
impl From<std::time::Duration> for types::Duration {
95+
fn from(s: std::time::Duration) -> Self {
96+
Self { secs: s.as_secs(), nanos: s.subsec_nanos() }
97+
}
98+
}
99+
100+
impl From<types::Duration> for std::time::Duration {
101+
fn from(s: types::Duration) -> Self {
102+
std::time::Duration::from_nanos(
103+
s.secs * 1000000000 + u64::from(s.nanos),
104+
)
105+
}
106+
}

dev-tools/omdb/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,33 @@ http.workspace = true
3737
humantime.workspace = true
3838
iddqd.workspace = true
3939
indent_write.workspace = true
40+
indicatif.workspace = true
4041
internal-dns-resolver.workspace = true
4142
internal-dns-types.workspace = true
43+
ipnetwork.workspace = true
4244
itertools.workspace = true
43-
nexus-client.workspace = true
45+
multimap.workspace = true
4446
nexus-config.workspace = true
4547
nexus-db-errors.workspace = true
4648
nexus-db-lookup.workspace = true
4749
nexus-db-model.workspace = true
4850
nexus-db-queries.workspace = true
4951
nexus-db-schema.workspace = true
5052
nexus-inventory.workspace = true
53+
nexus-lockstep-client.workspace = true
5154
nexus-reconfigurator-preparation.workspace = true
5255
nexus-saga-recovery.workspace = true
5356
nexus-sled-agent-shared.workspace = true
5457
nexus-types.workspace = true
5558
omicron-common.workspace = true
5659
omicron-uuid-kinds.workspace = true
60+
omicron-workspace-hack.workspace = true
61+
owo-colors.workspace = true
5762
oxide-tokio-rt.workspace = true
5863
oximeter-client.workspace = true
5964
oximeter-db = { workspace = true, default-features = false, features = [ "oxql" ] }
65+
oxnet.workspace = true
66+
petgraph.workspace = true
6067
# See omicron-rpaths for more about the "pq-sys" dependency.
6168
pq-sys = "*"
6269
ratatui.workspace = true
@@ -79,13 +86,6 @@ unicode-width.workspace = true
7986
update-engine.workspace = true
8087
url.workspace = true
8188
uuid.workspace = true
82-
ipnetwork.workspace = true
83-
omicron-workspace-hack.workspace = true
84-
multimap.workspace = true
85-
indicatif.workspace = true
86-
petgraph.workspace = true
87-
oxnet.workspace = true
88-
owo-colors.workspace = true
8989

9090
[dev-dependencies]
9191
camino-tempfile.workspace = true

dev-tools/omdb/src/bin/omdb/db/saga.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ async fn get_saga_sec_status(
607607
}
608608
};
609609

610-
let client = nexus_client::Client::new(
610+
let client = nexus_lockstep_client::Client::new(
611611
&format!("http://[{addr}]:{port}/"),
612612
opctx.log.clone(),
613613
);
@@ -618,21 +618,21 @@ async fn get_saga_sec_status(
618618
}
619619

620620
Err(e) => match e {
621-
nexus_client::Error::InvalidRequest(_)
622-
| nexus_client::Error::InvalidUpgrade(_)
623-
| nexus_client::Error::ErrorResponse(_)
624-
| nexus_client::Error::ResponseBodyError(_)
625-
| nexus_client::Error::InvalidResponsePayload(_, _)
626-
| nexus_client::Error::UnexpectedResponse(_)
627-
| nexus_client::Error::PreHookError(_)
628-
| nexus_client::Error::PostHookError(_) => {
621+
nexus_lockstep_client::Error::InvalidRequest(_)
622+
| nexus_lockstep_client::Error::InvalidUpgrade(_)
623+
| nexus_lockstep_client::Error::ErrorResponse(_)
624+
| nexus_lockstep_client::Error::ResponseBodyError(_)
625+
| nexus_lockstep_client::Error::InvalidResponsePayload(_, _)
626+
| nexus_lockstep_client::Error::UnexpectedResponse(_)
627+
| nexus_lockstep_client::Error::PreHookError(_)
628+
| nexus_lockstep_client::Error::PostHookError(_) => {
629629
return SagaSecStatus::SecPingError {
630630
sec_id: current_sec,
631631
observed_error: e.to_string(),
632632
};
633633
}
634634

635-
nexus_client::Error::CommunicationError(_) => {
635+
nexus_lockstep_client::Error::CommunicationError(_) => {
636636
// Assume communication error means that it could not be
637637
// contacted.
638638
//

0 commit comments

Comments
 (0)