Skip to content

Commit

Permalink
Limit size of the search range for VNIs when creating VPCs
Browse files Browse the repository at this point in the history
- Fixes #4283.
- Adds a relatively small limit to the `NextItem` query used for
  finding a free VNI during VPC creation. This limits the memory
  consumption to something very reasonable, but is big enough that we
  should be extremely unlikely to find _no_ available VNIs in the range.
- Add an application-level retry loop when inserting _customer_ VPCs,
  which catches the unlikely event that there really are no VNIs
  available, and retries a few times.
- Adds tests for the computation of the limited search range.
- Adds tests for the actual exhaustion-detection and retry behavior.
  • Loading branch information
bnaecker committed Oct 20, 2023
1 parent 9191af6 commit 9bea92c
Show file tree
Hide file tree
Showing 3 changed files with 424 additions and 47 deletions.
8 changes: 8 additions & 0 deletions nexus/db-model/src/vpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ impl IncompleteVpc {
subnet_gen: Generation::new(),
})
}

/// Create a copy of self, but with a new random VNI.
///
/// This is used to retry insertion of a VPC in the case where we can't find
/// an available VNI.
pub fn with_new_vni(self) -> Self {
Self { vni: Vni(external::Vni::random()), ..self }
}
}

impl DatastoreCollectionConfig<VpcFirewallRule> for Vpc {
Expand Down
Loading

0 comments on commit 9bea92c

Please sign in to comment.