Skip to content

Soft-delete volumes in a transaction, not CTE#6623

Merged
jmpesp merged 1 commit into
oxidecomputer:mainfrom
jmpesp:soft_delete_volume_with_transaction
Sep 20, 2024
Merged

Soft-delete volumes in a transaction, not CTE#6623
jmpesp merged 1 commit into
oxidecomputer:mainfrom
jmpesp:soft_delete_volume_with_transaction

Conversation

@jmpesp

@jmpesp jmpesp commented Sep 20, 2024

Copy link
Copy Markdown
Contributor

Change the process of soft-deleting a volume from a CTE into a transaction. This is done to make changes easier to apply and review.

One part of the CTE that remains is the query fragment that conditionally reduces volume references for region_snapshot rows, then returns only the rows updated. It was easier to keep this than figure out how to get it to work in diesel!

@jmpesp jmpesp requested a review from smklein September 20, 2024 19:27
} else {
// The volume was hard-deleted
return Ok(CrucibleResources::V1(
CrucibleResourcesV1::default(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Not sure this matters, but why return the oldest format here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't know, I imagine this was a holdover from the first time this code was written. If nothing else this helps us maintain the condition of "must always be able to deserialize this struct" :)

Comment on lines +906 to +911
// Even volumes with nothing to clean up should have a
// serialized CrucibleResources that contains empty
// vectors instead of None. Instead of panicing here
// though, just return the default (nothing to clean
// up).
CrucibleResources::V1(CrucibleResourcesV1::default())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this and the case above where we make a default crucible resource, should we just return an Option and bail out early?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's possible yeah. I'm inclined to pass around these empty vectors to avoid having to if let Some all over though.

@jmpesp jmpesp enabled auto-merge (squash) September 20, 2024 20:30
@jmpesp jmpesp merged commit 1067179 into oxidecomputer:main Sep 20, 2024
@jmpesp jmpesp deleted the soft_delete_volume_with_transaction branch September 20, 2024 20:59
Change the process of soft-deleting a volume from a CTE into a
transaction. This is done to make changes easier to apply and review.

One part of the CTE that remains is the query fragment that
conditionally reduces volume references for region_snapshot rows, then
returns only the rows updated. It was easier to keep this than figure
out how to get it to work in diesel!
hawkw pushed a commit that referenced this pull request Sep 21, 2024
Change the process of soft-deleting a volume from a CTE into a
transaction. This is done to make changes easier to apply and review.

One part of the CTE that remains is the query fragment that
conditionally reduces volume references for region_snapshot rows, then
returns only the rows updated. It was easier to keep this than figure
out how to get it to work in diesel!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants