[4.22] Prevent Load Balancer rule creation when adding a VM from a different network#12785
[4.22] Prevent Load Balancer rule creation when adding a VM from a different network#12785nvazquez wants to merge 1 commit intoapache:4.22from
Conversation
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 17082 |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17083 |
|
@blueorangutan test |
|
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12785 +/- ##
============================================
- Coverage 17.61% 17.61% -0.01%
- Complexity 15664 15665 +1
============================================
Files 5917 5917
Lines 531402 531410 +8
Branches 64971 64971
============================================
Hits 93596 93596
- Misses 427252 427260 +8
Partials 10554 10554
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } | ||
| /** | ||
|
|
||
| protected void verifyLoadBalancerRuleNetwork(String lbName, Network network, IPAddressVO ipVO) { |
There was a problem hiding this comment.
why protected? private seems apropriate.
|
[SF] Trillian test result (tid-15602)
|
There was a problem hiding this comment.
Backport Verification - Silent networkId Override Fix on 4.22
LGTM
- Silent networkId override: Fixed on 4.22 backport. LB rule creation with a mismatched networkid now returns a proper error instead of silently creating the rule on the IP's associated network.
- Regressions: None found. Existing 4.22 VPC operations are unaffected by the backported fix - same-tier LB creation, LB on unassociated IPs, multiple LB rules on the same tier, and PF with mismatched networkid rejection all work as expected.
Fix Verification
Setup:
- VPC with Default VPC offering
- Two tiers: tier1 (4ef87ed3), tier2 (9686d3ec)
- VMs: vm1 on tier1, vm2 on tier2
- Public IP 10.0.58.224 acquired, PF rule created on tier1 (IP associated with tier1)
Test: Create LB rule specifying networkid=tier2 on IP already associated with tier1
(localcloud) 🐱 > create portforwardingrule ipaddressid=0b015042-204c-4779-a2a5-f8be3b9b8d56 networkid=4ef87ed3-d26b-441b-9690-a97480c9193f virtualmachineid=6295caa3-c373-4e5b-9d00-e10de1c5f3e6 publicport=22 privateport=22 protocol=TCP openfirewall=false
"state": "Active",
"networkid": "4ef87ed3-d26b-441b-9690-a97480c9193f"
(localcloud) 🐱 > create loadbalancerrule publicipid=0b015042-204c-4779-a2a5-f8be3b9b8d56 networkid=9686d3ec-c3bd-4592-8086-d1fab1aaa4cf name=lb-cross-test algorithm=roundrobin publicport=80 privateport=80
Error (HTTP 431, error code 9999): Cannot create Load Balancer rule lb-cross-test as the IP address 10.0.58.224 is not associated with the network tier2 (ID=9686d3ec-c3bd-4592-8086-d1fab1aaa4cf)
Result: FIXED. API correctly rejects LB rule creation when the specified networkid does not match the IP's associated network. Previously the networkid was silently overridden and the rule was created on the wrong tier without any error. Same fix as verified on 4.23.
Regression Testing - No Regressions Found
| # | Test | Expected | Result |
|---|---|---|---|
| 1 | LB on same tier (same IP, port 80) | Rule created on tier1 | PASSED |
| 2 | LB on same tier, different port (same IP, port 8080) | Rule created on tier1 | PASSED |
| 3 | LB on fresh IP with no prior association (new IP, tier2, port 8080) | Rule created on tier2 | PASSED |
| 4 | PF with mismatched networkid (same IP, tier2 VM) | Error - VM not on associated network | PASSED |
# Regression 1: LB on same tier (should succeed)
(localcloud) 🐱 > create loadbalancerrule publicipid=0b015042-204c-4779-a2a5-f8be3b9b8d56 networkid=4ef87ed3-d26b-441b-9690-a97480c9193f name=lb-same-tier algorithm=roundrobin publicport=80 privateport=80
"state": "Add",
"networkid": "4ef87ed3-d26b-441b-9690-a97480c9193f"
# Regression 2: LB on same tier, different port (should succeed)
(localcloud) 🐱 > create loadbalancerrule publicipid=0b015042-204c-4779-a2a5-f8be3b9b8d56 networkid=4ef87ed3-d26b-441b-9690-a97480c9193f name=lb-same-tier-2 algorithm=roundrobin publicport=8080 privateport=8080
"state": "Add",
"networkid": "4ef87ed3-d26b-441b-9690-a97480c9193f"
# Regression 3: LB on fresh IP, no prior network association (should succeed)
(localcloud) 🐱 > associate ipaddress vpcid=13a939f4-49e4-4842-ae71-9c2e11402404 zoneid=e4fc5e7e-6a75-4f18-b914-274429fa9db9
"id": "cb0bf99e-c9ea-4ef0-b08f-2543c3b4bc15",
"ipaddress": "10.0.58.225"
(localcloud) 🐱 > create loadbalancerrule publicipid=cb0bf99e-c9ea-4ef0-b08f-2543c3b4bc15 networkid=9686d3ec-c3bd-4592-8086-d1fab1aaa4cf name=lb-fresh-ip algorithm=roundrobin publicport=8080 privateport=8080
"state": "Add",
"networkid": "9686d3ec-c3bd-4592-8086-d1fab1aaa4cf"
# Regression 4: PF with mismatched networkid (should fail - existing 4.22 behavior)
(localcloud) 🐱 > create portforwardingrule ipaddressid=0b015042-204c-4779-a2a5-f8be3b9b8d56 networkid=9686d3ec-c3bd-4592-8086-d1fab1aaa4cf virtualmachineid=6ea616d3-9421-462e-82cc-31babfc92227 publicport=80 privateport=80 protocol=TCP openfirewall=false
Error (HTTP 431, error code 4350): Vm doesn't belong to network associated with ipAddress
Description
This PR backports an issue fixed by PR #12487 for VPCs not using conserve mode. Since VPC Conserve mode is added on 4.23, only the logic that applies to this issue has been backported from the commit: b6fbdc3
To reproduce the issue:
The issue has been detected using cmk (UI does not allow adding a VM to a LB from a different network).
Before the fix: CloudStack allows the addition of VMs from different networks to the load balancer
After the fix:
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?