[fix]: Chunked cloud firewall rules of only 1 addr type result in empty rule and failed updates - #620
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #620 +/- ##
==========================================
+ Coverage 75.89% 75.91% +0.01%
==========================================
Files 18 18
Lines 2809 2811 +2
==========================================
+ Hits 2132 2134 +2
Misses 464 464
Partials 213 213 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
While this change works, I'm thinking we'll want to fix chunkIPs to actually return nil if the length of the ips is zero instead of just adding the checks here. WDYT? |
processACL created an empty inbound rule for the IP family with no addresses when the other family exceeded maxIPsPerFirewall, because chunkIPs returns a single chunk for an empty slice. Only chunk and emit rules for a family that actually has addresses.
Strengthen TestProcessACLNoEmptyRuleForMissingFamily to assert the exact expected grouping for 256 addresses (two inbound rules with chunk sizes 255 and 1) instead of only checking for absent empty-address rules. Convert the test to table-driven form and add a symmetric IPv6-only case so the IPv4-empty guard in processACL is directly exercised, not just the IPv6-empty guard covered by the IPv4-only case.
e467f35 to
9135a64
Compare
Good point — I switched the approach so that chunkIPs will return |
General:
Pull Request Guidelines:
Description
tl;dr — if you have a large firewall that exceeds the 255 address limit and kicks in the chunking logic, if that large firewall rule contains only 1 address type (i.e. all IPv4 or all IPv6) then the CCM still tries to add an empty rule for the address type.
This does the dumb, simple thing of just checking the length of the rules for each addr type before chunking them.
Example with a big rule of only IPv4 addrs: