Skip to content

Commit

Permalink
Prune inv_zpool when pruning collections (#5301)
Browse files Browse the repository at this point in the history
Noticed this while investigating #5299; I am unsure whether this will
actually resolve #5299 though.

I made this same mistake the first time I added something new to
inventory; @davepacheco and I discussed the issues with trying to test
for this at
#4496 (comment).
I'm not sure anything has materially changed there, but maybe testing
this warrants a closer look.
  • Loading branch information
jgallagher authored Mar 21, 2024
1 parent 0d5d5c0 commit 8cdfa1c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions nexus/db-queries/src/db/datastore/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ impl DataStore {
nsled_agent_zones,
nzones,
nnics,
nzpools,
nerrors,
) = conn
.transaction_async(|conn| async move {
Expand Down Expand Up @@ -1206,6 +1207,16 @@ impl DataStore {
.await?
};

let nzpools = {
use db::schema::inv_zpool::dsl;
diesel::delete(
dsl::inv_zpool
.filter(dsl::inv_collection_id.eq(collection_id)),
)
.execute_async(&conn)
.await?
};

// Remove rows for errors encountered.
let nerrors = {
use db::schema::inv_collection_error::dsl;
Expand All @@ -1228,6 +1239,7 @@ impl DataStore {
nsled_agent_zones,
nzones,
nnics,
nzpools,
nerrors,
))
})
Expand All @@ -1251,6 +1263,7 @@ impl DataStore {
"nsled_agent_zones" => nsled_agent_zones,
"nzones" => nzones,
"nnics" => nnics,
"nzpools" => nzpools,
"nerrors" => nerrors,
);

Expand Down

0 comments on commit 8cdfa1c

Please sign in to comment.