Skip to content

Add conserve mode for VPC offerings#12487

Open
nvazquez wants to merge 11 commits intoapache:mainfrom
shapeblue:423-source-nat-vpc-conserve
Open

Add conserve mode for VPC offerings#12487
nvazquez wants to merge 11 commits intoapache:mainfrom
shapeblue:423-source-nat-vpc-conserve

Conversation

@nvazquez
Copy link
Contributor

@nvazquez nvazquez commented Jan 21, 2026

Description

This PR extends the conserve mode for VPCs tiers added on the previous PRs: #8309, #10744 by allowing:

  • If the VPC tier offering uses conserve mode, then the public IP used for Source NAT can be reused for multiple services (it was previously restricted to Source NAT only)

This PR also introduces the following changes:

  • Introduce conserve mode for VPC offerings
  • When a VPC is created from a VPC offering using conserve mode: public IP rules can be created on different VPC tiers (when conserve mode = false, the rules are restricted to a single VPC tier).

Fixes: #8317

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  • Create a VPC Offering with Conserve mode enabled selecting:
    • Conserve mode = True
    • Services: Dns, Dhcp, Vpn, UserData, StaticNat, SourceNat, NetworkACL, Portforwarding, Lb as VpcVirtualRouter
  • Create VPC selecting the previous VPC Offering
  • Create VPC tiers with the default isolated network offering for VPC and deploy VMs on each tier
  • Observe the Source NAT IP address can be used for multiple services, create different rules
  • Acquire new Public IP address and create rules across different VPC tiers for the same Public IP address

How did you try to break this feature and the system with this change?

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 30.43478% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.92%. Comparing base (1b0a036) to head (1367e43).
⚠️ Report is 180 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/com/cloud/network/IpAddressManagerImpl.java 0.00% 8 Missing and 2 partials ⚠️
...e/cloudstack/api/response/VpcOfferingResponse.java 0.00% 6 Missing ⚠️
...main/java/com/cloud/network/vpc/VpcOfferingVO.java 0.00% 6 Missing ⚠️
...om/cloud/network/firewall/FirewallManagerImpl.java 76.00% 1 Missing and 5 partials ⚠️
...ck/api/command/admin/vpc/CreateVPCOfferingCmd.java 0.00% 3 Missing ⚠️
...rg/apache/cloudstack/api/response/VpcResponse.java 0.00% 3 Missing ⚠️
...java/com/cloud/api/query/vo/VpcOfferingJoinVO.java 0.00% 3 Missing ⚠️
...loud/network/lb/LoadBalancingRulesManagerImpl.java 0.00% 3 Missing ⚠️
...ain/java/com/cloud/network/vpc/VpcManagerImpl.java 40.00% 2 Missing and 1 partial ⚠️
...and/user/firewall/CreatePortForwardingRuleCmd.java 0.00% 1 Missing ⚠️
... and 4 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12487      +/-   ##
============================================
+ Coverage     17.84%   17.92%   +0.08%     
- Complexity    15980    16164     +184     
============================================
  Files          5929     5939      +10     
  Lines        531084   533262    +2178     
  Branches      64914    65252     +338     
============================================
+ Hits          94783    95610     +827     
- Misses       425686   426908    +1222     
- Partials      10615    10744     +129     
Flag Coverage Δ
uitests 3.66% <ø> (+0.08%) ⬆️
unittests 19.04% <30.43%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16471

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 16473

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 16475

@nvazquez
Copy link
Contributor Author

@blueorangutan test keepEnv

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-15239)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 55566 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12487-t15239-kvm-ol8.zip
Smoke tests completed. 147 look OK, 3 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_03_deploy_and_scale_kubernetes_cluster Failure 26.70 test_kubernetes_clusters.py
test_02_list_cpvm_vm Failure 0.03 test_ssvm.py
test_04_cpvm_internals Failure 0.04 test_ssvm.py
test_01_redundant_vpc_site2site_vpn Failure 392.36 test_vpc_vpn.py

@nvazquez nvazquez marked this pull request as ready for review January 27, 2026 05:09
@nvazquez nvazquez added this to the 4.23.0 milestone Jan 27, 2026
@nvazquez nvazquez changed the title Fix conserve mode for VPC Source NAT IP and extend rules for VPC tiers Fix conserve mode for VPC Source NAT IP and extend conserve mode for VPC offerings Jan 27, 2026
@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@nvazquez nvazquez marked this pull request as ready for review February 24, 2026 22:39
@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16930

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15519)

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15520)

@blueorangutan
Copy link

[SF] Trillian test result (tid-15521)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 49215 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12487-t15521-kvm-ol8.zip
Smoke tests completed. 146 look OK, 5 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_LoginApiDomain Error 7.10 test_accounts.py
ContextSuite context=TestListIdsParams>:teardown Error 1.12 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 4.96 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 46.63 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 46.63 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 27.56 test_snapshots.py
test_01_snapshot_usage Error 19.70 test_usage.py
test_01_vpn_usage Error 1.11 test_usage.py
ContextSuite context=TestVPCConserveModeRules>:setup Error 0.00 test_vpc_conserve_mode.py

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16948

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16950

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Long ntwkId = null;

if (ip.getAssociatedWithNetworkId() != null) {
if (ip.getVpcId() == null && ip.getAssociatedWithNetworkId() != null) {
Copy link
Member

Choose a reason for hiding this comment

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

with this change, networkId becomes mandatory for vpcs , right ?

for existing vpc (created in older versions), will this cause an issue ? as the IP might be already associated to a network (vpc tier).

for example, in VPC

  • IP is associated to a VPC tier (in a old version), now create portwarding rule without networkId (currently it is not needed)
  • IP is associated to a VPC tier (in a old version), now create portwarding rule with another networkId (vpc tier). this is not supported in the past

Copy link
Member

Choose a reason for hiding this comment

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

@nvazquez
I asked this question as it might be possible that users might update the vpc by changing the conserve_mode of in the vpc_offerings table, or change the vpc_offering_id in the vpc table.
they are not normal use cases. currently no API to update offering of a vpc.

if (ip.getAssociatedWithNetworkId() != null) {
if (ip.getVpcId() == null && ip.getAssociatedWithNetworkId() != null) {
ntwkId = ip.getAssociatedWithNetworkId();
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else {
} else if (ip.getAssociatedWithNetworkId() == null) {
ntwkId = networkId;
} else if (networkId == null) {
ntwkId = ip.getAssociatedWithNetworkId();
} else {
// TODO: check if ip.getAssociatedWithNetworkId() and networkId are the same ? is it needed ?
}

_accountMgr.checkAccess(caller.getCallingAccount(), null, true, ipAddr);

final Long networkId = ipAddr.getAssociatedWithNetworkId();
final Long networkId = ipAddr.getVpcId() == null ? ipAddr.getAssociatedWithNetworkId() : networkIdParam;
Copy link
Member

Choose a reason for hiding this comment

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

if the ip is associated with a vpc tier, should we allow a different networkId ?

self.fail(
"Expected cross-tier Port Forwarding rule to succeed with "
"conserveMode=True, but got exception: %s" % e
)
Copy link
Member

Choose a reason for hiding this comment

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

try to add a lb rule too ?


@attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
def test_01_vpc_conserve_mode_cross_tier_rules_allowed(self):
"""With conserveMode=True, LB rule on VPC Tier 1 and Port Forwarding rule on VPC Tier 2 can
Copy link
Member

Choose a reason for hiding this comment

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

any chance to update one of the existing smoke tests to test the same behaviour (which should expect an exception as the default vpc offering does not support conserve mode) ?

# ls test/integration/smoke/test_*vpc*
test/integration/smoke/test_domain_vpc_offerings.py  test/integration/smoke/test_vpc_redundant.py    test/integration/smoke/test_vpc_vpn.py
test/integration/smoke/test_vpc_ipv6.py              test/integration/smoke/test_vpc_router_nics.py

# test/integration/smoke/test_*acl*
test/integration/smoke/test_global_acls.py  test/integration/smoke/test_privategw_acl_ovs_gre.py
test/integration/smoke/test_network_acl.py  test/integration/smoke/test_privategw_acl.py

@weizhouapache
Copy link
Member

@nvazquez
any doc PR linked ?

@blueorangutan
Copy link

[SF] Trillian test result (tid-15531)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 54970 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12487-t15531-kvm-ol8.zip
Smoke tests completed. 147 look OK, 4 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_LoginApiDomain Error 7.77 test_accounts.py
ContextSuite context=TestListIdsParams>:teardown Error 1.17 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 6.04 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 49.85 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 49.85 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 28.80 test_snapshots.py
test_01_snapshot_usage Error 30.00 test_usage.py
test_01_vpn_usage Error 1.09 test_usage.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VPC SourceNAT IPs can't be used for services (PF, LB, etc...)

7 participants