ESD-1615: add matrix-aware NAT gateway speed/session validation#507
Conversation
Bump megaportgo to v1.15.0 for NATGatewaySpeedSessionSupported and use it in nat-gateway create to reject unsupported speed/session pairs before ordering, listing the valid speeds and session counts from the matrix. A matrix fetch failure or empty matrix fails open, matching the Terraform provider's handling, since the API still enforces the rule at order time. Also adds stub mock methods for the new MCRLookingGlassService ping/ traceroute interface methods introduced in the same SDK release, so the mcr package keeps compiling; implementing those commands is ESD-1614.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #507 +/- ##
=======================================
Coverage 78.52% 78.53%
=======================================
Files 192 192
Lines 18474 18493 +19
=======================================
+ Hits 14507 14523 +16
- Misses 2902 2904 +2
- Partials 1065 1066 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds pre-flight validation for NAT Gateway create so unsupported speed/session-count combinations are rejected client-side (using the SDK’s matrix-aware helper) before an order is sent to the API, while still “failing open” if the availability matrix can’t be fetched.
Changes:
- Validate requested
speed+session-countagainst the live NAT Gateway availability matrix duringnat-gateway create, returning a validation error that lists supported values when rejected. - Add unit tests covering matrix rejection (unsupported speed or session count), acceptance (supported pair), and fail-open behavior on matrix fetch failure.
- Bump
github.com/megaport/megaportgotov1.15.0and add stub methods to the MCR looking glass mock to match the updated SDK interfaces.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/commands/nat_gateway/nat_gateway_actions.go | Adds matrix-aware speed/session validation during NAT Gateway create (fail-open on fetch/empty). |
| internal/commands/nat_gateway/nat_gateway_test.go | Adds tests for matrix validation behavior (reject/allow/fail-open). |
| internal/commands/mcr/mcr_mock.go | Adds stub methods for new SDK MCR looking glass ping/traceroute interfaces to keep tests/build green. |
| go.mod | Bumps megaportgo dependency to v1.15.0. |
| go.sum | Updates checksums for the megaportgo v1.15.0 bump. |
|
Reviewed this together with #506/#508/#493 as part of a broader pass. Solid fix overall, and nice catch by the earlier reviewer on the One gap I want to flag explicitly: still sails past client-side checks straight to the API — the same class of "unsupported speed/session combination reached the API" issue this PR's description says it's closing, just still open on the update path. Do you want to pull the validation into |
Submitting a follow-up PR shortly, thanks! |
NAT gateway
createonly checked that speed and session count were positive, so an unsupported speed/session combination reached the API instead of failing pre-flight. This bumpsmegaportgoto v1.15.0 and uses itsNATGatewaySpeedSessionSupportedhelper to check the pair against the live availability matrix before ordering, listing the valid speeds and session counts if it's rejected.ListNATGatewaySessionsand validate the requested speed/session pair against it innat-gateway createmcrkeeps compiling (the commands themselves are ESD-1614)