Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14734 +/- ##
============================================
+ Coverage 20.81% 20.83% +0.02%
- Complexity 20923 20975 +52
============================================
Files 6053 6053
Lines 548451 548562 +111
Branches 73279 73303 +24
============================================
+ Hits 114138 114300 +162
+ Misses 420948 420849 -99
- Partials 13365 13413 +48
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2 of 14 tasks
…d routes NetworkExtensionElement implements every other VpcProvider method by delegating to the extension script, but four of them throw UnsupportedOperationException: createPrivateGateway, deletePrivateGateway, applyStaticRoutes and applyACLItemsToPrivateGw. The restriction is at the framework level, so it applies to every network extension whatever its backend can do, and an extension-backed VPC cannot reach parity with the VPC virtual router. This wires them up the same way as their neighbours, adding four script commands: create-private-gateway delete-private-gateway apply-static-routes apply-private-gw-acl Private gateway operations resolve the owning VPC and go through the existing VPC-level script path, carrying the gateway's id, uuid, address, netmask, broadcast URI and derived VLAN alongside the usual VPC fields. applyStaticRoutes and applyACLItemsToPrivateGw are full rebuilds that send the complete non-revoked set on every call, matching applyFWRules and applyNetworkACLs rather than the per-object style of add-static-nat; a backend reconciles instead of tracking deltas. An extension that does not implement these verbs is unaffected: the commands are new, and before this change the operations failed with UnsupportedOperationException regardless of the script, so no previously working behaviour changes. addPrivateGatewayToPayload documents gateway_vlan as conditional but emitted it unconditionally whenever a broadcast URI was present. BroadcastDomainType returns null for a URI whose scheme it does not recognise, so a non-VLAN gateway shipped "gateway_vlan": "" to the script. It is now emitted only when it has a value, which is what the javadoc already claimed and what every neighbouring field does. Adds NetworkExtensionElementTest, the first unit test this class has had. 26 cases over the four methods: the payload fields each sends, the VPC and gateway identity the script needs to find the router, the omit-when-blank branch of every optional field, both failure styles (createPrivateGateway and deletePrivateGateway return false, applyStaticRoutes and applyACLItemsToPrivateGw throw ResourceUnavailableException), full serialisation of a static route and of an ACL rule, rule ordering by number and routes by CIDR, and a null CIDR through the route comparator. The command name constants are asserted against their literals, since they are the wire contract with every deployed script. Adds NetworkExtensionElementPayloadContractTest, 6 more. It asserts the keys the script cannot run without -- a transcription of a reference implementation's require_arg calls, with the source named in each test -- and writes the payloads this class actually produces to target/extension-payloads/. The unit tests assert what this class writes and an extension's own tests assert what it reads, each checked against a fixture written by the same hand, so both would pass if a key name drifted between them. Replaying the real payloads against a real backend is what closes that: the six captured payloads pass 21 assertions against a live OVN northbound database, including that ovn-northd resolves the static routes this class emitted. 377 tests pass in framework/extensions.
kiwiflyer
force-pushed
the
ovn-support
branch
from
November 19, 2026 12:45
a7fd193 to
a00e19c
Compare
Member
|
great, thanks @kiwiflyer ! |
This branch has not been deployed
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.
Description
This PR lets a NetworkOrchestrator network extension implement VPC private gateways,
VPC static routes and private gateway ACLs.
NetworkExtensionElementimplements every otherVpcProvidermethod by building aJSON payload and handing it to the extension script, but four of them throw
UnsupportedOperationException:The restriction is at the framework level, so it applies to every network extension
whatever its backend can do. An extension-backed VPC cannot reach parity with the VPC
virtual router today, and no extension author can fix that on their own side.
Functional change. The four methods are wired up the same way as their
neighbours, adding four commands to the script protocol:
create-private-gatewaydelete-private-gatewayapply-static-routesapply-private-gw-aclAn extension that does not implement these verbs is unaffected: the commands are new,
so nothing dispatches them to a script that has not been updated, and the existing
behaviour of every other command is unchanged. Before this PR these operations failed
with
UnsupportedOperationExceptionregardless of the script, so there is no casewhere previously-working behaviour changes.
Private gateway operations resolve the owning VPC and go through the existing
VPC-level script path, carrying the gateway's id, uuid, address, netmask, broadcast
URI and derived VLAN alongside the usual VPC fields.
applyStaticRoutesandapplyACLItemsToPrivateGware full rebuilds that send the complete non-revoked set onevery call, matching
applyFWRulesandapplyNetworkACLsrather than the per-objectstyle of
add-static-nat; the backend reconciles instead of tracking deltas.One behavioural fix is included.
addPrivateGatewayToPayloaddocumentsgateway_vlanas conditional but emitted it unconditionally whenever a broadcast URIwas present.
BroadcastDomainType.getValue()returns null for a URI whose scheme itdoes not recognise, so a non-VLAN gateway shipped
"gateway_vlan": ""to the script.It is now emitted only when it has a value, which is what the javadoc already claimed
and what every neighbouring field does.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
n/a
How Has This Been Tested?
Unit tests.
NetworkExtensionElementTestis new — this 2600-line class had no unittest at all before. 26 cases covering the four methods: the payload fields each one
sends, the VPC and gateway identity the script needs to find the router, the
omit-when-blank branch of every optional field, both failure styles (
createPrivateGatewayand
deletePrivateGatewayreturn false,applyStaticRoutesandapplyACLItemsToPrivateGwthrow
ResourceUnavailableException), full serialisation of a static route and of an ACLrule, rule ordering by number and routes by CIDR, and a null CIDR passing through the
route comparator.
NetworkExtensionElementPayloadContractTestadds 6 more. It asserts the keys thescript cannot run without — a transcription of the reference implementation's
require_argcalls, with the source named in each test — and writes the payloads thisclass actually produces to
target/extension-payloads/.The whole
framework/extensionsmodule: 377 tests, 0 failures, checkstyle clean.Against a real OVN. The payloads captured above were replayed against a live OVN
24.03 northbound database with
ovn-northdrunning, using a reference extension thatimplements the four commands. 21 assertions: the element's
create-private-gatewaypayload produces a router port carrying its address, its
apply-static-routespayloadinstalls routes that northd resolves into logical flows, its
apply-network-aclpayload produces ACLs with rule 10 ahead of rule 20 at the right OVN priority and the
source CIDRs intact, its
apply-private-gw-aclpayload builds the gateway ACLs, andits
delete-private-gatewaypayload removes the port.implement-vpcis included,captured in the state a VPC is first implemented in — no source NAT IP yet.
That replay exists because the unit tests assert what this class writes and an
extension's tests assert what it reads, with each side checked against a fixture
written by the same hand. Both suites would still pass if a key name drifted between
them. Feeding the real payloads to a real backend is what closes that.
Not tested: this has not run on a CloudStack management server driving a real zone.
The reference extension is not part of this PR.
How did you try to break this feature and the system with this change?
Adversarial cases, all now regression tests:
vpcId, and a gateway whosevpcIdpoints at a VPC that no longer exists. Both must return false and must not reach the
script. Verified with
verify(..., never())rather than by return value alone."",nulland" "for itsaddress, gateway, netmask and broadcast URI, and a null state. Blank is not the same
as absent: a script testing
-n "$gateway_ip_address"must not see an empty stringand configure a port with it. Asserts the keys are missing, and that the mandatory
ones survive.
vlan://bad hostthrowsURISyntaxExceptioninsideaddPrivateGatewayToPayload. The call must not abort and the raw value must still goout; only the derived VLAN is dropped. A schemeless URI (
untagged) is the case thatexposed the empty-string bug above.
not omit the key — an empty array means "no routes", a missing key means "unchanged",
and the two are not interchangeable to a reconciling backend.
cannot NPE on a route that is mid-construction.
VpcProviderand is easy to "fix" wrongly in either direction.gateway_vlanchange makestestPrivateGatewayPayloadOmitsVlanWhenBroadcastUriCarriesNonefail, confirming thetest is not vacuous.
Two things found while writing these, worth flagging to reviewers:
0, notnull, for an unstubbed boxedInteger. The first versionof the ACL serialisation test passed for the wrong reason — the omit-when-null branch
looked taken when it was not. The test now stubs the nulls explicitly and says why.
wire contract with every deployed script, so a rename should break a test here rather
than break deployments silently.
Blast radius. The four methods previously threw unconditionally, so no existing
deployment can be executing them.
addPrivateGatewayToPayload,buildStaticRoutesArrayand
getVpcForPrivateGatewayare new and private. The only pre-existing code pathtouched is the
gateway_vlanemission described above, which is reachable only fromthe new methods.
buildAclRulesArrayis reused unchanged and is still covered by theexisting
apply-network-aclpath.