Skip to content

Commit

Permalink
Don't use LookupPath here! (#7197)
Browse files Browse the repository at this point in the history
It won't be able to get deleted Snapshot objects in order to kick off
region snapshot replacements.
  • Loading branch information
jmpesp authored Dec 4, 2024
1 parent 3b77deb commit 37c7f18
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions nexus/db-queries/src/db/datastore/region_snapshot_replacement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::db;
use crate::db::datastore::SQL_BATCH_SIZE;
use crate::db::error::public_error_from_diesel;
use crate::db::error::ErrorHandler;
use crate::db::lookup::LookupPath;
use crate::db::model::RegionSnapshot;
use crate::db::model::RegionSnapshotReplacement;
use crate::db::model::RegionSnapshotReplacementState;
Expand Down Expand Up @@ -64,10 +63,19 @@ impl DataStore {
opctx: &OpContext,
request: RegionSnapshotReplacement,
) -> Result<(), Error> {
let (.., db_snapshot) = LookupPath::new(opctx, &self)
.snapshot_id(request.old_snapshot_id)
.fetch()
.await?;
// Note: if `LookupPath` is used here, it will not be able to retrieve
// deleted snapshots
let db_snapshot = match self
.snapshot_get(opctx, request.old_snapshot_id)
.await?
{
Some(db_snapshot) => db_snapshot,
None => {
return Err(Error::internal_error(
"cannot perform region snapshot replacement without snapshot volume"
));
}
};

self.insert_region_snapshot_replacement_request_with_volume_id(
opctx,
Expand Down

0 comments on commit 37c7f18

Please sign in to comment.