Skip to content

Commit 83c6572

Browse files
leftwoAlan Hanson
andauthored
Make snapshot destination_volume_id not an Option (#2092)
Co-authored-by: Alan Hanson <[email protected]>
1 parent cdf3207 commit 83c6572

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

common/src/sql/dbinit.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ CREATE TABLE omicron.public.snapshot (
792792
volume_id UUID NOT NULL,
793793

794794
/* Where will the scrubbed blocks eventually land? */
795-
destination_volume_id UUID,
795+
destination_volume_id UUID NOT NULL,
796796

797797
gen INT NOT NULL,
798798
state omicron.public.snapshot_state NOT NULL,

nexus/db-model/src/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ table! {
7777
disk_id -> Uuid,
7878
volume_id -> Uuid,
7979

80-
destination_volume_id -> Nullable<Uuid>,
80+
destination_volume_id -> Uuid,
8181

8282
gen -> Int8,
8383
state -> crate::SnapshotStateEnum,

nexus/db-model/src/snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct Snapshot {
4848
pub volume_id: Uuid,
4949

5050
// destination of all snapshot blocks
51-
pub destination_volume_id: Option<Uuid>,
51+
pub destination_volume_id: Uuid,
5252

5353
pub gen: Generation,
5454
pub state: SnapshotState,

nexus/src/app/disk.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ impl super::Nexus {
513513

514514
// Kick off volume deletion saga(s)
515515
self.volume_delete(db_snapshot.volume_id).await?;
516-
if let Some(volume_id) = db_snapshot.destination_volume_id {
517-
self.volume_delete(volume_id).await?;
518-
}
516+
self.volume_delete(db_snapshot.destination_volume_id).await?;
519517

520518
Ok(())
521519
}

nexus/src/app/sagas/snapshot_create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ async fn ssc_create_snapshot_record(
401401
project_id: params.project_id,
402402
disk_id: disk.id(),
403403
volume_id,
404-
destination_volume_id: Some(destination_volume_id),
404+
destination_volume_id: destination_volume_id,
405405

406406
gen: db::model::Generation::new(),
407407
state: db::model::SnapshotState::Creating,

nexus/tests/integration_tests/snapshots.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ async fn test_reject_creating_disk_from_snapshot(
423423
project_id,
424424
disk_id: Uuid::new_v4(),
425425
volume_id: Uuid::new_v4(),
426-
destination_volume_id: None,
426+
destination_volume_id: Uuid::new_v4(),
427427

428428
gen: db::model::Generation::new(),
429429
state: db::model::SnapshotState::Creating,
@@ -580,7 +580,7 @@ async fn test_reject_creating_disk_from_illegal_snapshot(
580580
project_id,
581581
disk_id: Uuid::new_v4(),
582582
volume_id: Uuid::new_v4(),
583-
destination_volume_id: None,
583+
destination_volume_id: Uuid::new_v4(),
584584

585585
gen: db::model::Generation::new(),
586586
state: db::model::SnapshotState::Creating,
@@ -724,7 +724,7 @@ async fn test_create_snapshot_record_idempotent(
724724
project_id,
725725
disk_id: Uuid::new_v4(),
726726
volume_id: Uuid::new_v4(),
727-
destination_volume_id: None,
727+
destination_volume_id: Uuid::new_v4(),
728728

729729
gen: db::model::Generation::new(),
730730
state: db::model::SnapshotState::Creating,

0 commit comments

Comments
 (0)