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

[sled-agent][sim] Use a shared support bundle implementation #7264

Merged
merged 71 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
cd3aabd
Add support bundle API skeleton to Nexus
smklein Nov 7, 2024
3774ecb
fmt
smklein Nov 7, 2024
33787b8
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 7, 2024
0b3fd29
EXPECTORATE
smklein Nov 7, 2024
9eb91bf
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 8, 2024
0f9ff1c
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 8, 2024
ec897f7
Add database schema for support bundles
smklein Nov 8, 2024
38b6ea8
Add failure reason
smklein Nov 8, 2024
a938a82
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 8, 2024
908f661
Merge reason for failure
smklein Nov 8, 2024
aa3978f
Fix SQL, moving forward on tests
smklein Nov 12, 2024
d6d53c9
Refactor state machine
smklein Nov 13, 2024
483801a
Clippy, schema changes
smklein Nov 13, 2024
5f78af9
more clippy
smklein Nov 13, 2024
8dba975
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 13, 2024
69e04ae
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 13, 2024
92b7d62
Strongly-typed UUID
smklein Nov 13, 2024
bc10ee1
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 13, 2024
6c529d1
Add list-by-nexus method, test it
smklein Nov 14, 2024
6972b2f
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 25, 2024
adf956c
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 25, 2024
e61365a
merge
smklein Nov 25, 2024
07159ad
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 25, 2024
81c7121
Merge UUID changes
smklein Nov 25, 2024
9baae20
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 27, 2024
60f92dd
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 27, 2024
7c33f19
fix typed uuid merge
smklein Nov 27, 2024
affa4c7
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 27, 2024
10c3745
more typed UUID merges
smklein Nov 27, 2024
2b42d0e
API updates pulled from 7187 as I built it
smklein Nov 28, 2024
2371630
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Nov 28, 2024
356225c
Merge branch 'main' into nexus-support-bundles-api
smklein Nov 28, 2024
1fccea8
expectorate
smklein Dec 2, 2024
b33ed31
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 2, 2024
b77c23a
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 6, 2024
0b939f2
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 6, 2024
0461260
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 9, 2024
490d648
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 9, 2024
a8ed3d3
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 10, 2024
abedbb2
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 10, 2024
01bc1c1
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 13, 2024
9795bfe
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 13, 2024
5866f48
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 13, 2024
55e9c24
use path params more
smklein Dec 13, 2024
7d87a27
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 13, 2024
efca596
Review feedback
smklein Dec 13, 2024
e29733d
Add to uncovered endpoints, since these aren't impl'd yet
smklein Dec 13, 2024
0464f25
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 13, 2024
2232690
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 16, 2024
f97bfc5
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 16, 2024
adea822
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 17, 2024
0ad466d
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 17, 2024
d16fda0
Use a shared support bundle implementation for the simulated sled agent
smklein Dec 17, 2024
60c27d3
cleanup println
smklein Dec 17, 2024
2a24dd2
Merge branch 'main' into nexus-support-bundles-api
smklein Dec 19, 2024
50917c7
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Dec 19, 2024
053adca
Merge branch 'support-bundles-crdb' into support-bundle-simulated-imp…
smklein Dec 19, 2024
28130e5
Merge branch 'main' into nexus-support-bundles-api
smklein Jan 6, 2025
9bf57a4
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Jan 6, 2025
28795f6
Merge branch 'support-bundles-crdb' into support-bundle-simulated-imp…
smklein Jan 6, 2025
1506c87
merging
smklein Jan 6, 2025
a0f45c1
Merge branch 'support-bundles-crdb' into support-bundle-simulated-imp…
smklein Jan 6, 2025
9d416b1
Fix simulated nested datasets, add tests
smklein Jan 6, 2025
a8b263a
Merge branch 'main' into nexus-support-bundles-api
smklein Jan 6, 2025
bdaab3e
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Jan 6, 2025
8b58c16
Merge branch 'support-bundles-crdb' into support-bundle-simulated-imp…
smklein Jan 6, 2025
5746fbf
Merge branch 'main' into nexus-support-bundles-api
smklein Jan 8, 2025
7c1457f
Merge branch 'nexus-support-bundles-api' into support-bundles-crdb
smklein Jan 8, 2025
69e0f46
Merge branch 'support-bundles-crdb' into support-bundle-simulated-imp…
smklein Jan 8, 2025
ac36cf6
Merge branch 'main' into support-bundle-simulated-implementation
smklein Jan 9, 2025
f73f081
Merge branch 'main' into support-bundle-simulated-implementation
smklein Jan 13, 2025
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
11 changes: 4 additions & 7 deletions nexus/src/app/sagas/disk_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,15 +1034,12 @@ pub(crate) mod test {
true
}

async fn no_regions_ensured(
sled_agent: &SledAgent,
test: &DiskTest<'_>,
) -> bool {
fn no_regions_ensured(sled_agent: &SledAgent, test: &DiskTest<'_>) -> bool {
for zpool in test.zpools() {
for dataset in &zpool.datasets {
let crucible_dataset =
sled_agent.get_crucible_dataset(zpool.id, dataset.id).await;
if !crucible_dataset.is_empty().await {
sled_agent.get_crucible_dataset(zpool.id, dataset.id);
if !crucible_dataset.is_empty() {
return false;
}
}
Expand Down Expand Up @@ -1073,7 +1070,7 @@ pub(crate) mod test {
.await
);
assert!(no_region_allocations_exist(datastore, &test).await);
assert!(no_regions_ensured(&sled_agent, &test).await);
assert!(no_regions_ensured(&sled_agent, &test));

assert!(test.crucible_resources_deleted().await);
}
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/instance_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ pub mod test {
assert!(disk_is_detached(datastore).await);
assert!(no_instances_or_disks_on_sled(&sled_agent).await);

let v2p_mappings = &*sled_agent.v2p_mappings.lock().await;
let v2p_mappings = &*sled_agent.v2p_mappings.lock().unwrap();
assert!(v2p_mappings.is_empty());
}

Expand Down
20 changes: 11 additions & 9 deletions nexus/src/app/sagas/instance_ip_attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ pub(crate) mod test {
&instance_id,
)
.await;
let mut eips = sled_agent.external_ips.lock().await;
let my_eips = eips.entry(vmm_id).or_default();
assert!(my_eips
.iter()
.any(|v| matches!(v, InstanceExternalIpBody::Floating(_))));
assert!(my_eips
.iter()
.any(|v| matches!(v, InstanceExternalIpBody::Ephemeral(_))));
{
let mut eips = sled_agent.external_ips.lock().unwrap();
let my_eips = eips.entry(vmm_id).or_default();
assert!(my_eips
.iter()
.any(|v| matches!(v, InstanceExternalIpBody::Floating(_))));
assert!(my_eips
.iter()
.any(|v| matches!(v, InstanceExternalIpBody::Ephemeral(_))));
}

// DB has records for SNAT plus the new IPs.
let db_eips = datastore
Expand Down Expand Up @@ -497,7 +499,7 @@ pub(crate) mod test {
&instance_id,
)
.await;
let mut eips = sled_agent.external_ips.lock().await;
let mut eips = sled_agent.external_ips.lock().unwrap();
let my_eips = eips.entry(vmm_id).or_default();
assert!(my_eips.is_empty());
}
Expand Down
10 changes: 6 additions & 4 deletions nexus/src/app/sagas/instance_ip_detach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,11 @@ pub(crate) mod test {
&instance_id,
)
.await;
let mut eips = sled_agent.external_ips.lock().await;
let my_eips = eips.entry(vmm_id).or_default();
assert!(my_eips.is_empty());
{
let mut eips = sled_agent.external_ips.lock().unwrap();
let my_eips = eips.entry(vmm_id).or_default();
assert!(my_eips.is_empty());
}

// DB only has record for SNAT.
let db_eips = datastore
Expand Down Expand Up @@ -467,7 +469,7 @@ pub(crate) mod test {
assert!(db_eips.iter().any(|v| v.kind == IpKind::SNat));

// No IP bindings remain on sled-agent.
let eips = &*sled_agent.external_ips.lock().await;
let eips = &*sled_agent.external_ips.lock().unwrap();
for (_nic_id, eip_set) in eips {
assert_eq!(eip_set.len(), 2);
}
Expand Down
10 changes: 4 additions & 6 deletions nexus/src/app/sagas/region_snapshot_replacement_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,8 @@ pub(crate) mod test {
for zpool in test.zpools() {
for dataset in &zpool.datasets {
let crucible_dataset =
sled_agent.get_crucible_dataset(zpool.id, dataset.id).await;
for region in crucible_dataset.list().await {
sled_agent.get_crucible_dataset(zpool.id, dataset.id);
for region in crucible_dataset.list() {
match region.state {
crucible_agent_client::types::State::Tombstoned
| crucible_agent_client::types::State::Destroyed => {
Expand Down Expand Up @@ -1745,8 +1745,7 @@ pub(crate) mod test {
.as_ref()
.unwrap()
.pantry
.set_auto_activate_volumes()
.await;
.set_auto_activate_volumes();

// Create a disk and a snapshot
let client = &cptestctx.external_client;
Expand Down Expand Up @@ -1904,8 +1903,7 @@ pub(crate) mod test {
.as_ref()
.unwrap()
.pantry
.set_auto_activate_volumes()
.await;
.set_auto_activate_volumes();

// Create a disk and a snapshot
let client = &cptestctx.external_client;
Expand Down
65 changes: 28 additions & 37 deletions nexus/test-utils/src/resource_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,26 +1282,24 @@ impl<'a, N: NexusServer> DiskTest<'a, N> {
// Tell the simulated sled agent to create the disk and zpool containing
// these datasets.

sled_agent
.create_external_physical_disk(
physical_disk_id,
disk_identity.clone(),
)
.await;
sled_agent
.create_zpool(zpool.id, physical_disk_id, zpool.size.to_bytes())
.await;
sled_agent.create_external_physical_disk(
physical_disk_id,
disk_identity.clone(),
);
sled_agent.create_zpool(
zpool.id,
physical_disk_id,
zpool.size.to_bytes(),
);

for dataset in &zpool.datasets {
// Sled Agent side: Create the Dataset, make sure regions can be
// created immediately if Nexus requests anything.
let address =
sled_agent.create_crucible_dataset(zpool.id, dataset.id).await;
sled_agent.create_crucible_dataset(zpool.id, dataset.id);
let crucible =
sled_agent.get_crucible_dataset(zpool.id, dataset.id).await;
crucible
.set_create_callback(Box::new(|_| RegionState::Created))
.await;
sled_agent.get_crucible_dataset(zpool.id, dataset.id);
crucible.set_create_callback(Box::new(|_| RegionState::Created));

// Nexus side: Notify Nexus of the physical disk/zpool/dataset
// combination that exists.
Expand Down Expand Up @@ -1381,23 +1379,19 @@ impl<'a, N: NexusServer> DiskTest<'a, N> {
for dataset in &zpool.datasets {
let crucible = self
.get_sled(*sled_id)
.get_crucible_dataset(zpool.id, dataset.id)
.await;
.get_crucible_dataset(zpool.id, dataset.id);
let called = std::sync::atomic::AtomicBool::new(false);
crucible
.set_create_callback(Box::new(move |_| {
if !called.load(std::sync::atomic::Ordering::SeqCst)
{
called.store(
true,
std::sync::atomic::Ordering::SeqCst,
);
RegionState::Requested
} else {
RegionState::Created
}
}))
.await;
crucible.set_create_callback(Box::new(move |_| {
if !called.load(std::sync::atomic::Ordering::SeqCst) {
called.store(
true,
std::sync::atomic::Ordering::SeqCst,
);
RegionState::Requested
} else {
RegionState::Created
}
}));
}
}
}
Expand All @@ -1409,11 +1403,9 @@ impl<'a, N: NexusServer> DiskTest<'a, N> {
for dataset in &zpool.datasets {
let crucible = self
.get_sled(*sled_id)
.get_crucible_dataset(zpool.id, dataset.id)
.await;
.get_crucible_dataset(zpool.id, dataset.id);
crucible
.set_create_callback(Box::new(|_| RegionState::Failed))
.await;
.set_create_callback(Box::new(|_| RegionState::Failed));
}
}
}
Expand All @@ -1430,9 +1422,8 @@ impl<'a, N: NexusServer> DiskTest<'a, N> {
for dataset in &zpool.datasets {
let crucible = self
.get_sled(*sled_id)
.get_crucible_dataset(zpool.id, dataset.id)
.await;
if !crucible.is_empty().await {
.get_crucible_dataset(zpool.id, dataset.id);
if !crucible.is_empty() {
return false;
}
}
Expand Down
10 changes: 3 additions & 7 deletions nexus/tests/integration_tests/crucible_replacements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ mod region_replacement {
.activate_background_attachment(
region_replacement.volume_id.to_string(),
)
.await
.unwrap();
}

Expand Down Expand Up @@ -1816,8 +1815,7 @@ async fn test_replacement_sanity(cptestctx: &ControlPlaneTestContext) {
.as_ref()
.unwrap()
.pantry
.set_auto_activate_volumes()
.await;
.set_auto_activate_volumes();

// Now, run all replacement tasks to completion
let internal_client = &cptestctx.internal_client;
Expand Down Expand Up @@ -1854,8 +1852,7 @@ async fn test_region_replacement_triple_sanity(
.as_ref()
.unwrap()
.pantry
.set_auto_activate_volumes()
.await;
.set_auto_activate_volumes();

// Create a disk and a snapshot and a disk from that snapshot
let client = &cptestctx.external_client;
Expand Down Expand Up @@ -1966,8 +1963,7 @@ async fn test_region_replacement_triple_sanity_2(
.as_ref()
.unwrap()
.pantry
.set_auto_activate_volumes()
.await;
.set_auto_activate_volumes();

// Create a disk and a snapshot and a disk from that snapshot
let client = &cptestctx.external_client;
Expand Down
10 changes: 3 additions & 7 deletions nexus/tests/integration_tests/disks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,9 +1340,7 @@ async fn test_disk_virtual_provisioning_collection_failed_delete(
.sled_agent
.sled_agent
.get_crucible_dataset(zpool.id, dataset.id)
.await
.set_region_deletion_error(true)
.await;
.set_region_deletion_error(true);

// Delete the disk - expect this to fail
NexusRequest::new(
Expand Down Expand Up @@ -1378,9 +1376,7 @@ async fn test_disk_virtual_provisioning_collection_failed_delete(
.sled_agent
.sled_agent
.get_crucible_dataset(zpool.id, dataset.id)
.await
.set_region_deletion_error(false)
.await;
.set_region_deletion_error(false);

// Request disk delete again
NexusRequest::new(
Expand Down Expand Up @@ -2478,7 +2474,7 @@ async fn test_no_halt_disk_delete_one_region_on_expunged_agent(
let zpool = disk_test.zpools().next().expect("Expected at least one zpool");
let dataset = &zpool.datasets[0];

cptestctx.sled_agent.sled_agent.drop_dataset(zpool.id, dataset.id).await;
cptestctx.sled_agent.sled_agent.drop_dataset(zpool.id, dataset.id);

// Spawn a task that tries to delete the disk
let disk_url = get_disk_url(DISK_NAME);
Expand Down
8 changes: 4 additions & 4 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ async fn test_instance_start_creates_networking_state(

sled_agents.push(&cptestctx.sled_agent.sled_agent);
for agent in &sled_agents {
agent.v2p_mappings.lock().await.clear();
agent.v2p_mappings.lock().unwrap().clear();
}

// Start the instance and make sure that it gets to Running.
Expand Down Expand Up @@ -6251,7 +6251,7 @@ async fn test_instance_v2p_mappings(cptestctx: &ControlPlaneTestContext) {
// Validate that every sled no longer has the V2P mapping for this instance
for sled_agent in &sled_agents {
let condition = || async {
let v2p_mappings = sled_agent.v2p_mappings.lock().await;
let v2p_mappings = sled_agent.v2p_mappings.lock().unwrap();
if v2p_mappings.is_empty() {
Ok(())
} else {
Expand Down Expand Up @@ -6508,7 +6508,7 @@ async fn assert_sled_v2p_mappings(
vni: Vni,
) {
let condition = || async {
let v2p_mappings = sled_agent.v2p_mappings.lock().await;
let v2p_mappings = sled_agent.v2p_mappings.lock().unwrap();
let mapping = v2p_mappings.iter().find(|mapping| {
mapping.virtual_ip == nic.ip
&& mapping.virtual_mac == nic.mac
Expand Down Expand Up @@ -6580,7 +6580,7 @@ pub async fn assert_sled_vpc_routes(
kind: RouterKind::Custom(db_subnet.ipv4_block.0.into()),
};

let vpc_routes = sled_agent.vpc_routes.lock().await;
let vpc_routes = sled_agent.vpc_routes.lock().unwrap();
let sys_routes_found = vpc_routes
.iter()
.any(|(id, set)| *id == sys_key && set.routes == system_routes);
Expand Down
4 changes: 1 addition & 3 deletions nexus/tests/integration_tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,7 @@ async fn test_snapshot_unwind(cptestctx: &ControlPlaneTestContext) {
.sled_agent
.sled_agent
.get_crucible_dataset(zpool.id, dataset.id)
.await
.set_creating_a_running_snapshot_should_fail()
.await;
.set_creating_a_running_snapshot_should_fail();

// Issue snapshot request, expecting it to fail
let snapshots_url = format!("/v1/snapshots?project={}", PROJECT_NAME);
Expand Down
12 changes: 2 additions & 10 deletions nexus/tests/integration_tests/volume_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2529,9 +2529,7 @@ async fn test_disk_create_saga_unwinds_correctly(
.sled_agent
.sled_agent
.get_crucible_dataset(zpool.id, dataset.id)
.await
.set_region_creation_error(true)
.await;
.set_region_creation_error(true);

let disk_size = ByteCount::from_gibibytes_u32(2);
let base_disk = params::DiskCreate {
Expand Down Expand Up @@ -2599,9 +2597,7 @@ async fn test_snapshot_create_saga_unwinds_correctly(
.sled_agent
.sled_agent
.get_crucible_dataset(zpool.id, dataset.id)
.await
.set_region_creation_error(true)
.await;
.set_region_creation_error(true);

// Create a snapshot
let snapshot_create = params::SnapshotCreate {
Expand Down Expand Up @@ -4227,11 +4223,9 @@ async fn test_read_only_region_reference_counting(
TypedUuid::from_untyped_uuid(db_read_only_dataset.pool_id),
db_read_only_dataset.id(),
)
.await
.get(crucible_agent_client::types::RegionId(
read_only_region.id().to_string()
))
.await
.unwrap()
.state,
crucible_agent_client::types::State::Created
Expand Down Expand Up @@ -4299,11 +4293,9 @@ async fn test_read_only_region_reference_counting(
TypedUuid::from_untyped_uuid(db_read_only_dataset.pool_id),
db_read_only_dataset.id(),
)
.await
.get(crucible_agent_client::types::RegionId(
read_only_region.id().to_string()
))
.await
.unwrap()
.state,
crucible_agent_client::types::State::Destroyed
Expand Down
Loading
Loading