Skip to content

Commit 6602604

Browse files
committed
remove now-unused crucible_dataset_upsert_if_blueprint_is_current_target
1 parent bdc7160 commit 6602604

File tree

1 file changed

+0
-94
lines changed

1 file changed

+0
-94
lines changed

nexus/db-queries/src/db/datastore/crucible_dataset.rs

-94
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ use async_bb8_diesel::AsyncRunQueryDsl;
2727
use chrono::Utc;
2828
use diesel::prelude::*;
2929
use diesel::upsert::excluded;
30-
use futures::FutureExt;
3130
use omicron_common::api::external::CreateResult;
3231
use omicron_common::api::external::DataPageParams;
3332
use omicron_common::api::external::Error;
3433
use omicron_common::api::external::ListResultVec;
3534
use omicron_common::api::external::LookupResult;
3635
use omicron_common::api::external::LookupType;
3736
use omicron_common::api::external::ResourceType;
38-
use omicron_uuid_kinds::BlueprintUuid;
3937
use omicron_uuid_kinds::DatasetUuid;
4038
use omicron_uuid_kinds::GenericUuid;
4139
use uuid::Uuid;
@@ -73,31 +71,6 @@ impl DataStore {
7371
})
7472
}
7573

76-
pub async fn crucible_dataset_upsert_if_blueprint_is_current_target(
77-
&self,
78-
opctx: &OpContext,
79-
bp_id: BlueprintUuid,
80-
dataset: CrucibleDataset,
81-
) -> CreateResult<CrucibleDataset> {
82-
let conn = self.pool_connection_unauthorized().await?;
83-
84-
self.transaction_if_current_blueprint_is(
85-
&conn,
86-
"dataset_upsert_if_blueprint_is_current_target",
87-
opctx,
88-
bp_id,
89-
|conn| {
90-
let dataset = dataset.clone();
91-
async move {
92-
Self::crucible_dataset_upsert_on_connection(&conn, dataset)
93-
.await
94-
}
95-
.boxed()
96-
},
97-
)
98-
.await
99-
}
100-
10174
async fn crucible_dataset_upsert_on_connection(
10275
conn: &async_bb8_diesel::Connection<db::DbConnection>,
10376
dataset: CrucibleDataset,
@@ -277,15 +250,12 @@ impl DataStore {
277250
#[cfg(test)]
278251
mod test {
279252
use super::*;
280-
use crate::db::datastore::test::bp_insert_and_make_target;
281253
use crate::db::pub_test_utils::TestDatabase;
282254
use nexus_db_model::Generation;
283255
use nexus_db_model::SledBaseboard;
284256
use nexus_db_model::SledSystemHardware;
285257
use nexus_db_model::SledUpdate;
286-
use nexus_reconfigurator_planning::blueprint_builder::BlueprintBuilder;
287258
use omicron_test_utils::dev;
288-
use omicron_uuid_kinds::BlueprintUuid;
289259
use omicron_uuid_kinds::DatasetUuid;
290260
use omicron_uuid_kinds::PhysicalDiskUuid;
291261
use omicron_uuid_kinds::SledUuid;
@@ -418,68 +388,4 @@ mod test {
418388
db.terminate().await;
419389
logctx.cleanup_successful();
420390
}
421-
422-
fn new_dataset_on(zpool_id: ZpoolUuid) -> CrucibleDataset {
423-
CrucibleDataset::new(
424-
DatasetUuid::new_v4(),
425-
*zpool_id.as_untyped_uuid(),
426-
"[::1]:0".parse().unwrap(),
427-
)
428-
}
429-
430-
#[tokio::test]
431-
async fn test_upsert_while_blueprint_changes() {
432-
let logctx = dev::test_setup_log("upsert_while_blueprint_changes");
433-
let db = TestDatabase::new_with_datastore(&logctx.log).await;
434-
let (opctx, datastore) = (db.opctx(), db.datastore());
435-
436-
let (sled_id, zpool_id) =
437-
create_sled_and_zpool(&datastore, opctx).await;
438-
439-
// The datastore methods don't actually read the blueprint, but they do
440-
// guard against concurrent changes to the current target.
441-
//
442-
// We can test behavior by swapping between empty blueprints.
443-
let bp0 = BlueprintBuilder::build_empty_with_sleds(
444-
[sled_id].into_iter(),
445-
"test",
446-
);
447-
bp_insert_and_make_target(&opctx, &datastore, &bp0).await;
448-
449-
let bp1 = {
450-
let mut bp1 = bp0.clone();
451-
bp1.id = BlueprintUuid::new_v4();
452-
bp1.parent_blueprint_id = Some(bp0.id);
453-
bp1
454-
};
455-
bp_insert_and_make_target(&opctx, &datastore, &bp1).await;
456-
457-
let old_blueprint_id = bp0.id;
458-
let current_blueprint_id = bp1.id;
459-
460-
// Upsert referencing old blueprint: Error
461-
datastore
462-
.crucible_dataset_upsert_if_blueprint_is_current_target(
463-
&opctx,
464-
old_blueprint_id,
465-
new_dataset_on(zpool_id),
466-
)
467-
.await
468-
.expect_err(
469-
"Shouldn't be able to insert referencing old blueprint",
470-
);
471-
472-
// Upsert referencing current blueprint: OK
473-
datastore
474-
.crucible_dataset_upsert_if_blueprint_is_current_target(
475-
&opctx,
476-
current_blueprint_id,
477-
new_dataset_on(zpool_id),
478-
)
479-
.await
480-
.expect("Should be able to insert while blueprint is active");
481-
482-
db.terminate().await;
483-
logctx.cleanup_successful();
484-
}
485391
}

0 commit comments

Comments
 (0)