Skip to content

feat(config): Remove NAT default to stateless NAT mode#1305

Merged
Fredi-raspall merged 1 commit intomainfrom
pr/qmonnet/nat-no-default
Mar 3, 2026
Merged

feat(config): Remove NAT default to stateless NAT mode#1305
Fredi-raspall merged 1 commit intomainfrom
pr/qmonnet/nat-no-default

Conversation

@qmonnet
Copy link
Member

@qmonnet qmonnet commented Feb 24, 2026

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 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, 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.

@qmonnet qmonnet self-assigned this Feb 24, 2026
@qmonnet qmonnet requested a review from a team as a code owner February 24, 2026 17:13
@qmonnet qmonnet added the area/nat Related to Network Address Translation (NAT) label Feb 24, 2026
Copy link
Contributor

@Fredi-raspall Fredi-raspall left a comment

Choose a reason for hiding this comment

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

The changes look good to me.
Reminder:

  • we should be renaming stateless -> static
  • stateful -> masquerading

@Fredi-raspall Fredi-raspall added the dont-merge Do not merge this Pull Request label Feb 25, 2026
@qmonnet
Copy link
Member Author

qmonnet commented Feb 25, 2026

Waiting for #1262 to go in first.

Copilot AI review requested due to automatic review settings March 2, 2026 22:09
@qmonnet qmonnet force-pushed the pr/qmonnet/nat-no-default branch from ed192f2 to 07f7bcc Compare March 2, 2026 22:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 makes VpcExpose::as_range / VpcExpose::not_as return Result and 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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@qmonnet
Copy link
Member Author

qmonnet commented Mar 3, 2026

@Fredi-raspall Are we ready to go for this one?

@Fredi-raspall Fredi-raspall removed the dont-merge Do not merge this Pull Request label Mar 3, 2026
@Fredi-raspall Fredi-raspall added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@Fredi-raspall Fredi-raspall added this pull request to the merge queue Mar 3, 2026
Merged via the queue into main with commit cb70262 Mar 3, 2026
25 of 26 checks passed
@Fredi-raspall Fredi-raspall deleted the pr/qmonnet/nat-no-default branch March 3, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/nat Related to Network Address Translation (NAT)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants