Skip to content

Commit 9d63409

Browse files
authored
rustfmt bails out in blueprint_delete() (#8440)
1 parent 66016ca commit 9d63409

File tree

1 file changed

+185
-134
lines changed

1 file changed

+185
-134
lines changed

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

Lines changed: 185 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,149 +1032,200 @@ impl DataStore {
10321032
nclickhouse_keepers,
10331033
nclickhouse_servers,
10341034
noximeter_policy,
1035-
) = self.transaction_retry_wrapper("blueprint_delete")
1035+
) = self
1036+
.transaction_retry_wrapper("blueprint_delete")
10361037
.transaction(&conn, |conn| {
10371038
let err = err.clone();
10381039
async move {
1039-
// Ensure that blueprint we're about to delete is not the
1040-
// current target.
1041-
let current_target = Self::blueprint_current_target_only(&conn)
1042-
.await
1043-
.map_err(|txn_err| txn_err.into_diesel(&err))?;
1040+
// Ensure that blueprint we're about to delete is not the
1041+
// current target.
1042+
let current_target =
1043+
Self::blueprint_current_target_only(&conn)
1044+
.await
1045+
.map_err(|txn_err| txn_err.into_diesel(&err))?;
10441046

1045-
if current_target.target_id == blueprint_id {
1046-
return Err(err.bail(TransactionError::CustomError(
1047-
Error::conflict(format!(
1048-
"blueprint {blueprint_id} is the \
1047+
if current_target.target_id == blueprint_id {
1048+
return Err(err.bail(TransactionError::CustomError(
1049+
Error::conflict(format!(
1050+
"blueprint {blueprint_id} is the \
10491051
current target and cannot be deleted",
1050-
)),
1051-
)));
1052-
}
1052+
)),
1053+
)));
1054+
}
10531055

1054-
// Remove the record describing the blueprint itself.
1055-
let nblueprints = {
1056-
use nexus_db_schema::schema::blueprint::dsl;
1057-
diesel::delete(
1058-
dsl::blueprint.filter(dsl::id.eq(to_db_typed_uuid(blueprint_id))),
1059-
)
1060-
.execute_async(&conn)
1061-
.await?
1062-
};
1063-
1064-
// Bail out if this blueprint didn't exist; there won't be
1065-
// references to it in any of the remaining tables either, since
1066-
// deletion always goes through this transaction.
1067-
if nblueprints == 0 {
1068-
return Err(err.bail(TransactionError::CustomError(
1069-
authz_blueprint.not_found(),
1070-
)));
1071-
}
1056+
// Remove the record describing the blueprint itself.
1057+
let nblueprints =
1058+
{
1059+
use nexus_db_schema::schema::blueprint::dsl;
1060+
diesel::delete(dsl::blueprint.filter(
1061+
dsl::id.eq(to_db_typed_uuid(blueprint_id)),
1062+
))
1063+
.execute_async(&conn)
1064+
.await?
1065+
};
1066+
1067+
// Bail out if this blueprint didn't exist; there won't be
1068+
// references to it in any of the remaining tables either,
1069+
// since deletion always goes through this transaction.
1070+
if nblueprints == 0 {
1071+
return Err(err.bail(TransactionError::CustomError(
1072+
authz_blueprint.not_found(),
1073+
)));
1074+
}
10721075

1073-
// Remove rows associated with sled metadata.
1074-
let nsled_metadata = {
1075-
use nexus_db_schema::schema::bp_sled_metadata::dsl;
1076-
diesel::delete(
1077-
dsl::bp_sled_metadata
1078-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1079-
)
1080-
.execute_async(&conn)
1081-
.await?
1082-
};
1083-
1084-
// Remove rows associated with Omicron physical disks
1085-
let nphysical_disks = {
1086-
use nexus_db_schema::schema::bp_omicron_physical_disk::dsl;
1087-
diesel::delete(
1088-
dsl::bp_omicron_physical_disk
1089-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1090-
)
1091-
.execute_async(&conn)
1092-
.await?
1093-
};
1094-
1095-
// Remove rows associated with Omicron datasets
1096-
let ndatasets = {
1097-
use nexus_db_schema::schema::bp_omicron_dataset::dsl;
1098-
diesel::delete(
1099-
dsl::bp_omicron_dataset
1100-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1101-
)
1102-
.execute_async(&conn)
1103-
.await?
1104-
};
1105-
1106-
// Remove rows associated with Omicron zones
1107-
let nzones = {
1108-
use nexus_db_schema::schema::bp_omicron_zone::dsl;
1109-
diesel::delete(
1110-
dsl::bp_omicron_zone
1111-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1112-
)
1113-
.execute_async(&conn)
1114-
.await?
1115-
};
1116-
1117-
let nnics = {
1118-
use nexus_db_schema::schema::bp_omicron_zone_nic::dsl;
1119-
diesel::delete(
1120-
dsl::bp_omicron_zone_nic
1121-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1122-
)
1123-
.execute_async(&conn)
1124-
.await?
1125-
};
1126-
1127-
let nclickhouse_cluster_configs = {
1128-
use nexus_db_schema::schema::bp_clickhouse_cluster_config::dsl;
1129-
diesel::delete(
1130-
dsl::bp_clickhouse_cluster_config
1131-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1132-
)
1133-
.execute_async(&conn)
1134-
.await?
1135-
};
1076+
// Remove rows associated with sled metadata.
1077+
let nsled_metadata = {
1078+
// Skip rustfmt because it bails out on this long line.
1079+
#[rustfmt::skip]
1080+
use nexus_db_schema::schema::
1081+
bp_sled_metadata::dsl;
1082+
diesel::delete(
1083+
dsl::bp_sled_metadata.filter(
1084+
dsl::blueprint_id
1085+
.eq(to_db_typed_uuid(blueprint_id)),
1086+
),
1087+
)
1088+
.execute_async(&conn)
1089+
.await?
1090+
};
11361091

1137-
let nclickhouse_keepers = {
1138-
use nexus_db_schema::schema::bp_clickhouse_keeper_zone_id_to_node_id::dsl;
1139-
diesel::delete(dsl::bp_clickhouse_keeper_zone_id_to_node_id
1140-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1141-
)
1142-
.execute_async(&conn)
1143-
.await?
1144-
};
1092+
// Remove rows associated with Omicron physical disks
1093+
let nphysical_disks = {
1094+
// Skip rustfmt because it bails out on this long line.
1095+
#[rustfmt::skip]
1096+
use nexus_db_schema::schema::
1097+
bp_omicron_physical_disk::dsl;
1098+
diesel::delete(
1099+
dsl::bp_omicron_physical_disk.filter(
1100+
dsl::blueprint_id
1101+
.eq(to_db_typed_uuid(blueprint_id)),
1102+
),
1103+
)
1104+
.execute_async(&conn)
1105+
.await?
1106+
};
11451107

1146-
let nclickhouse_servers = {
1147-
use nexus_db_schema::schema::bp_clickhouse_server_zone_id_to_node_id::dsl;
1148-
diesel::delete(dsl::bp_clickhouse_server_zone_id_to_node_id
1149-
.filter(dsl::blueprint_id.eq(to_db_typed_uuid(blueprint_id))),
1150-
)
1151-
.execute_async(&conn)
1152-
.await?
1153-
};
1154-
1155-
let noximeter_policy = {
1156-
use nexus_db_schema::schema::
1157-
bp_oximeter_read_policy::dsl;
1158-
diesel::delete(dsl::bp_oximeter_read_policy
1159-
.filter(dsl::blueprint_id.eq(
1160-
to_db_typed_uuid(blueprint_id))),
1161-
)
1162-
.execute_async(&conn)
1163-
.await?
1164-
};
1165-
1166-
Ok((
1167-
nblueprints,
1168-
nsled_metadata,
1169-
nphysical_disks,
1170-
ndatasets,
1171-
nzones,
1172-
nnics,
1173-
nclickhouse_cluster_configs,
1174-
nclickhouse_keepers,
1175-
nclickhouse_servers,
1176-
noximeter_policy,
1177-
))
1108+
// Remove rows associated with Omicron datasets
1109+
let ndatasets = {
1110+
// Skip rustfmt because it bails out on this long line.
1111+
#[rustfmt::skip]
1112+
use nexus_db_schema::schema::
1113+
bp_omicron_dataset::dsl;
1114+
diesel::delete(
1115+
dsl::bp_omicron_dataset.filter(
1116+
dsl::blueprint_id
1117+
.eq(to_db_typed_uuid(blueprint_id)),
1118+
),
1119+
)
1120+
.execute_async(&conn)
1121+
.await?
1122+
};
1123+
1124+
// Remove rows associated with Omicron zones
1125+
let nzones = {
1126+
// Skip rustfmt because it bails out on this long line.
1127+
#[rustfmt::skip]
1128+
use nexus_db_schema::schema::
1129+
bp_omicron_zone::dsl;
1130+
diesel::delete(
1131+
dsl::bp_omicron_zone.filter(
1132+
dsl::blueprint_id
1133+
.eq(to_db_typed_uuid(blueprint_id)),
1134+
),
1135+
)
1136+
.execute_async(&conn)
1137+
.await?
1138+
};
1139+
1140+
let nnics = {
1141+
// Skip rustfmt because it bails out on this long line.
1142+
#[rustfmt::skip]
1143+
use nexus_db_schema::schema::
1144+
bp_omicron_zone_nic::dsl;
1145+
diesel::delete(
1146+
dsl::bp_omicron_zone_nic.filter(
1147+
dsl::blueprint_id
1148+
.eq(to_db_typed_uuid(blueprint_id)),
1149+
),
1150+
)
1151+
.execute_async(&conn)
1152+
.await?
1153+
};
1154+
1155+
let nclickhouse_cluster_configs = {
1156+
// Skip rustfmt because it bails out on this long line.
1157+
#[rustfmt::skip]
1158+
use nexus_db_schema::schema::
1159+
bp_clickhouse_cluster_config::dsl;
1160+
diesel::delete(
1161+
dsl::bp_clickhouse_cluster_config.filter(
1162+
dsl::blueprint_id
1163+
.eq(to_db_typed_uuid(blueprint_id)),
1164+
),
1165+
)
1166+
.execute_async(&conn)
1167+
.await?
1168+
};
1169+
1170+
let nclickhouse_keepers = {
1171+
// Skip rustfmt because it bails out on this long line.
1172+
#[rustfmt::skip]
1173+
use nexus_db_schema::schema::
1174+
bp_clickhouse_keeper_zone_id_to_node_id::dsl;
1175+
diesel::delete(
1176+
dsl::bp_clickhouse_keeper_zone_id_to_node_id
1177+
.filter(
1178+
dsl::blueprint_id
1179+
.eq(to_db_typed_uuid(blueprint_id)),
1180+
),
1181+
)
1182+
.execute_async(&conn)
1183+
.await?
1184+
};
1185+
1186+
let nclickhouse_servers = {
1187+
// Skip rustfmt because it bails out on this long line.
1188+
#[rustfmt::skip]
1189+
use nexus_db_schema::schema::
1190+
bp_clickhouse_server_zone_id_to_node_id::dsl;
1191+
diesel::delete(
1192+
dsl::bp_clickhouse_server_zone_id_to_node_id
1193+
.filter(
1194+
dsl::blueprint_id
1195+
.eq(to_db_typed_uuid(blueprint_id)),
1196+
),
1197+
)
1198+
.execute_async(&conn)
1199+
.await?
1200+
};
1201+
1202+
let noximeter_policy = {
1203+
// Skip rustfmt because it bails out on this long line.
1204+
#[rustfmt::skip]
1205+
use nexus_db_schema::schema::
1206+
bp_oximeter_read_policy::dsl;
1207+
diesel::delete(
1208+
dsl::bp_oximeter_read_policy.filter(
1209+
dsl::blueprint_id
1210+
.eq(to_db_typed_uuid(blueprint_id)),
1211+
),
1212+
)
1213+
.execute_async(&conn)
1214+
.await?
1215+
};
1216+
1217+
Ok((
1218+
nblueprints,
1219+
nsled_metadata,
1220+
nphysical_disks,
1221+
ndatasets,
1222+
nzones,
1223+
nnics,
1224+
nclickhouse_cluster_configs,
1225+
nclickhouse_keepers,
1226+
nclickhouse_servers,
1227+
noximeter_policy,
1228+
))
11781229
}
11791230
})
11801231
.await

0 commit comments

Comments
 (0)