Skip to content

Commit d5d74a6

Browse files
committed
and the column gets a s/boot_disk/boot_disk_id/g
1 parent 4eb1ff5 commit d5d74a6

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

nexus/db-model/src/instance.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ pub struct Instance {
6464
pub auto_restart_policy: Option<InstanceAutoRestart>,
6565

6666
/// The primary boot disk for this instance.
67-
#[diesel(column_name = boot_disk)]
68-
pub boot_disk: Option<Uuid>,
67+
#[diesel(column_name = boot_disk_id)]
68+
pub boot_disk_id: Option<Uuid>,
6969

7070
#[diesel(embed)]
7171
pub runtime_state: InstanceRuntimeState,
@@ -117,9 +117,9 @@ impl Instance {
117117
// TODO(eliza): allow this to be configured via the instance-create
118118
// params...
119119
auto_restart_policy: None,
120-
// Intentionally ignore `params.boot_disk` here: we can't set
121-
// `boot_disk` until the referenced disk is attached.
122-
boot_disk: None,
120+
// Intentionally ignore `params.boot_disk_id` here: we can't set
121+
// `boot_disk_id` until the referenced disk is attached.
122+
boot_disk_id: None,
123123
runtime_state,
124124

125125
updater_gen: Generation::new(),
@@ -235,6 +235,6 @@ impl InstanceRuntimeState {
235235
#[derive(Clone, Debug, AsChangeset, Serialize, Deserialize)]
236236
#[diesel(table_name = instance, treat_none_as_null = true)]
237237
pub struct InstanceUpdate {
238-
#[diesel(column_name = boot_disk)]
239-
pub boot_disk: Option<Uuid>,
238+
#[diesel(column_name = boot_disk_id)]
239+
pub boot_disk_id: Option<Uuid>,
240240
}

nexus/db-model/src/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ table! {
408408
memory -> Int8,
409409
hostname -> Text,
410410
auto_restart_policy -> Nullable<crate::InstanceAutoRestartEnum>,
411-
boot_disk -> Nullable<Uuid>,
411+
boot_disk_id -> Nullable<Uuid>,
412412
time_state_updated -> Timestamptz,
413413
state_generation -> Int8,
414414
active_propolis_id -> Nullable<Uuid>,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ impl DataStore {
337337
.eq_any(ok_to_detach_instance_states)
338338
.and(instance::dsl::active_propolis_id.is_null())
339339
.and(
340-
instance::dsl::boot_disk.ne(authz_disk.id())
341-
.or(instance::dsl::boot_disk.is_null())
340+
instance::dsl::boot_disk_id.ne(authz_disk.id())
341+
.or(instance::dsl::boot_disk_id.is_null())
342342
)),
343343
disk::table
344344
.into_boxed()
@@ -392,7 +392,7 @@ impl DataStore {
392392
// Ok-to-be-detached instance states:
393393
api::external::InstanceState::Creating |
394394
api::external::InstanceState::Stopped => {
395-
if collection.boot_disk == Some(authz_disk.id()) {
395+
if collection.boot_disk_id == Some(authz_disk.id()) {
396396
return Err(Error::conflict(
397397
"boot disk cannot be detached"
398398
));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl From<InstanceAndActiveVmm> for external::Instance {
206206
.hostname
207207
.parse()
208208
.expect("found invalid hostname in the database"),
209-
boot_disk_id: value.instance.boot_disk.into(),
209+
boot_disk_id: value.instance.boot_disk_id.into(),
210210
runtime: external::InstanceRuntimeState {
211211
run_state: value.effective_state(),
212212
time_run_state_updated,
@@ -940,7 +940,7 @@ impl DataStore {
940940
}
941941
}
942942

943-
if let Some(disk_id) = update.boot_disk.clone() {
943+
if let Some(disk_id) = update.boot_disk_id.clone() {
944944
// Ensure the disk is currently attached before updating
945945
// the database.
946946
let expected_state = api::external::DiskState::Attached(
@@ -972,7 +972,7 @@ impl DataStore {
972972
// here.
973973
//
974974
// NOTE: from this point forward it is OK if we update the
975-
// instance's `boot_disk` column with the updated value
975+
// instance's `boot_disk_id` column with the updated value
976976
// again. It will have already been assigned with constraint
977977
// checking performed above, so updates will just be
978978
// repetitive, not harmful.
@@ -1774,7 +1774,7 @@ mod tests {
17741774
params::InstanceNetworkInterfaceAttachment::None,
17751775
external_ips: Vec::new(),
17761776
disks: Vec::new(),
1777-
boot_disk: None,
1777+
boot_disk_id: None,
17781778
ssh_public_keys: None,
17791779
start: false,
17801780
},

nexus/src/app/instance.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl super::Nexus {
304304
let (.., authz_project, authz_instance) =
305305
instance_lookup.lookup_for(authz::Action::Modify).await?;
306306

307-
let boot_disk = match params.boot_disk.clone() {
307+
let boot_disk_id = match params.boot_disk.clone() {
308308
Some(disk) => {
309309
let selector = params::DiskSelector {
310310
project: match &disk {
@@ -323,7 +323,7 @@ impl super::Nexus {
323323
None => None,
324324
};
325325

326-
let update = InstanceUpdate { boot_disk };
326+
let update = InstanceUpdate { boot_disk_id };
327327
self.datastore()
328328
.reconfigure_instance(opctx, &authz_instance, update)
329329
.await
@@ -1054,7 +1054,7 @@ impl super::Nexus {
10541054

10551055
// Propolis wants the name of the boot disk rather than ID, because we send names
10561056
// rather than IDs in the disk requsts as assembled below.
1057-
if db_instance.boot_disk == Some(disk.id()) {
1057+
if db_instance.boot_disk_id == Some(disk.id()) {
10581058
boot_disk_name = Some(disk.name().to_string());
10591059
}
10601060

@@ -1079,16 +1079,16 @@ impl super::Nexus {
10791079
// look up a name when assembling the Propolis request, we might as well
10801080
// remove this check; we can just pass the ID and rely on Propolis' own
10811081
// check that the boot disk is attached.
1082-
if let Some(instance_boot_disk) = db_instance.boot_disk.as_ref() {
1082+
if let Some(instance_boot_disk_id) = db_instance.boot_disk_id.as_ref() {
10831083
if boot_disk_name.is_none() {
10841084
error!(self.log, "instance boot disk is not attached";
1085-
"boot_disk" => ?instance_boot_disk,
1085+
"boot_disk_id" => ?instance_boot_disk_id,
10861086
"instance id" => %db_instance.id());
10871087

10881088
return Err(InstanceStateChangeError::Other(Error::internal_error(&format!(
10891089
"instance {} has boot disk {:?} but it is not attached",
10901090
db_instance.id(),
1091-
db_instance.boot_disk.as_ref(),
1091+
db_instance.boot_disk_id.as_ref(),
10921092
))));
10931093
}
10941094
}

nexus/src/app/sagas/instance_create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ async fn sic_set_boot_disk(
10661066
};
10671067

10681068
let initial_configuration =
1069-
nexus_db_model::InstanceUpdate { boot_disk: Some(authz_disk.id()) };
1069+
nexus_db_model::InstanceUpdate { boot_disk_id: Some(authz_disk.id()) };
10701070

10711071
datastore
10721072
.reconfigure_instance(&opctx, &authz_instance, initial_configuration)
@@ -1098,7 +1098,7 @@ async fn sic_set_boot_disk_undo(
10981098
// If there was a boot disk, clear it. If there was not a boot disk,
10991099
// this is a no-op.
11001100
let undo_configuration =
1101-
nexus_db_model::InstanceUpdate { boot_disk: None };
1101+
nexus_db_model::InstanceUpdate { boot_disk_id: None };
11021102

11031103
datastore
11041104
.reconfigure_instance(&opctx, &authz_instance, undo_configuration)

schema/crdb/dbinit.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ CREATE TABLE IF NOT EXISTS omicron.public.instance (
11141114
* does not want our policy, and instead should be permitted control over
11151115
* its boot-time fates.
11161116
*/
1117-
boot_disk UUID,
1117+
boot_disk_id UUID,
11181118

11191119
CONSTRAINT vmm_iff_active_propolis CHECK (
11201120
((state = 'vmm') AND (active_propolis_id IS NOT NULL)) OR

0 commit comments

Comments
 (0)