Skip to content

Commit

Permalink
[nexus] Add virtual provisioning idempotency tests, prevent underflow (
Browse files Browse the repository at this point in the history
…#5830)

Builds on #5081 and
#5089 , but more out of
convenience than necessity.

# Summary

This PR attempts to validate that, for the "virtual provisioning
collection {insert, delete}" operations, they are idempotent. Currently,
our usage of `max_instance_gen` only **partially** prevents updates
during instance provisioning deletions:
- If `max_instance_gen` is smaller than the observed instance generation
number...
- ... we avoid deleting the `virtual_provisioning_resource` record
(which is great)
- ... but we still decrement the `virtual_provisioning_collection`
values (which is really not great).

This basically means that we can "only cause the project/silo/fleet
usage values to decrement arbitrarily, with no other changes". This has
been, mechanically, the root cause of our observed underflows (e.g,
#5525).

# Details of this change

- All the changes in
`nexus/db-queries/src/db/datastore/virtual_provisioning_collection.rs`
are tests validating idempotency of these operations.
- All the changes in
`nexus/db-queries/src/db/queries/virtual_provisioning_collection_update.rs`
are actually changes to the query which change functionality. The
objective of these changes is to preserve idempotency of the newly added
tests, and to prevent undercounting of virtual provisioning resources.
If these changes are reverted, the newly added tests start failing,
showing a lack of coverage.
  • Loading branch information
smklein authored May 30, 2024
1 parent 7633d17 commit acbeb27
Show file tree
Hide file tree
Showing 4 changed files with 556 additions and 66 deletions.
Loading

0 comments on commit acbeb27

Please sign in to comment.