feat(config): Remove NAT default to stateless NAT mode#1305
Merged
Fredi-raspall merged 1 commit intomainfrom Mar 3, 2026
Merged
feat(config): Remove NAT default to stateless NAT mode#1305Fredi-raspall merged 1 commit intomainfrom
Fredi-raspall merged 1 commit intomainfrom
Conversation
Fredi-raspall
approved these changes
Feb 25, 2026
Contributor
Fredi-raspall
left a comment
There was a problem hiding this comment.
The changes look good to me.
Reminder:
- we should be renaming stateless -> static
- stateful -> masquerading
Member
Author
|
Waiting for #1262 to go in first. |
ed192f2 to
07f7bcc
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Removes the implicit fallback to stateless (static) NAT when a NAT mode is not explicitly configured, aligning the dataplane config model and tests with the newer user API behavior.
Changes:
- Removes
Default/fallback NAT construction and makesVpcExpose::as_range/VpcExpose::not_asreturnResultand require NAT to be configured explicitly. - Updates k8s conversion and multiple crate tests to handle the new
Result-returning API (mostly via.unwrap()in tests). - Adjusts various NAT-related test fixtures to explicitly call
make_stateless_nat()/make_stateful_nat()before adding translated prefixes.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| nat/src/stateless/test.rs | Updates stateless NAT tests to unwrap as_range/not_as results. |
| nat/src/stateless/setup/mod.rs | Ensures exposes explicitly configure stateless NAT before setting as/not_as ranges. |
| nat/src/stateful/test.rs | Updates stateful NAT tests to unwrap as_range/not_as results. |
| nat/src/stateful/apalloc/test_alloc.rs | Updates allocator test fixtures to unwrap as_range/not_as results. |
| mgmt/src/tests/mgmt.rs | Updates mgmt tests to explicitly enable stateless NAT and unwrap as_range. |
| flow-filter/src/lib.rs | Updates flow-filter tests to unwrap as_range in manifest construction. |
| config/src/external/overlay/vpcpeering.rs | Removes default/fallback NAT creation; makes as_range/not_as require explicit NAT and return Result. |
| config/src/external/overlay/tests.rs | Updates overlay config tests to explicitly configure NAT and unwrap results. |
| config/src/converters/k8s/config/expose.rs | Updates k8s conversion to handle Result from as_range/not_as (currently mapped to InternalError). |
When the user didn't specify a NAT mode in the CRD, we used to default to static (stateless) NAT. We changed that recently, when we updated to the new user API with commit 018c3a9 ("feat(k8s-intf)!: bump to gateway v0.42.0, adjust to NAT API changes"). Now, when NAT is in use, the mode must be specified explicitly. As a consequence, we want to remove the fallback to stateless NAT in the dataplane repository. This commit began with simple changes in file config/src/external/overlay/vpcpeering.rs: we remove make_nat() and the Default trait implementation for VpcExposeNat, and update VpcExpose's as_range() and not_as() methods to use self.nat if present. This means that if self.nat is not set, we return an error: because of that, we get to update all the (numerous) calls to as_range and not_as in the tests for crates config, mgmt, flow-filter, and nat. Having to .unwrap() in the tests after each call to as_range() or not_as() is not particularly pleasant, but seems like a logical consequence from the API change (and internal changes from commit cf20117 ("feat(config,nat): Add nat config to VpcExpose"), where the as_range and not_as lists are now attached to a VpcExposeNat object): if the NAT object has not been configured, it makes no sense to set the NAT target prefixes. Signed-off-by: Quentin Monnet <qmo@qmon.net>
07f7bcc to
a4fbaf7
Compare
Member
Author
|
@Fredi-raspall Are we ready to go for this one? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the user didn't specify a NAT mode in the CRD, we used to default to static (stateless) NAT. We changed that recently, when we updated to the new user API with commit 018c3a9. Now, when NAT is in use, the mode must be specified explicitly.
As a consequence, we want to remove the fallback to stateless NAT in the dataplane repository. This commit began with simple changes in file config/src/external/overlay/vpcpeering.rs: we remove
make_nat()and theDefaulttrait implementation forVpcExposeNat, and updateVpcExpose'sas_range()andnot_as()methods to useself.natif present. This means that ifself.natis not set, we return an error: because of that, we get to update all the (numerous) calls toas_rangeandnot_asin the tests for cratesconfig,mgmt,flow-filter, andnat.Having to
.unwrap()in the tests after each call toas_range()ornot_as()is not particularly pleasant, but seems like a logical consequence from the API change (and internal changes from commit cf20117, where theas_rangeandnot_aslists are now attached to aVpcExposeNatobject): if the NAT object has not been configured, it makes no sense to set the NAT target prefixes.