Fix issue with ipset or iptables chain removal during NodeNetworkPolicy updates or deletions#6707
Conversation
8f58f0f to
569fa36
Compare
|
@hongliangl please fix the commit title / PR title (it's not a correct sentence), and add a commit message that explains what the issue was and what your change is doing. |
Will do. |
569fa36 to
87da3fe
Compare
| ipset := newLastRealized.ipsets[ipProtocol] | ||
|
|
||
| shouldUpdateCoreIPTRules := prevIPSet != ipset || prevIPNet != ipnet | ||
| // The name of ipset for a rule will not change during updates. |
There was a problem hiding this comment.
is that why the case where ipset != "" && prevIPSet != "" && ipset != prevIPSet is not possible?
There was a problem hiding this comment.
Exactly. Here are the cases:
- Single IP change: A -> B (prevIPSet = "", ipset = "", prevIPNet = A, ipnet = B).
- Transition from multiple addresses to a single IP: {A, B} -> A (prevIPSet = "ipset name", ipset = "", prevIPNet = "", ipnet = A).
- Transition from a single IP to multiple addresses: A -> {A, B} (prevIPNet = A, ipnet = "", prevIPSet = "", ipset = "ipset name").
There was a problem hiding this comment.
The ipset name is based on the rule ID, which determines that it will not change for a given rule.
| s2p1 := mockRouteClient.DeleteNodeNetworkPolicyIPTables([]string{"ANTREA-POL-INGRESSRULE1"}, false).Times(1) | ||
| s2p2 := mockRouteClient.DeleteNodeNetworkPolicyIPSet("ANTREA-POL-INGRESSRULE1-4", false) | ||
| s2p3 := mockRouteClient.AddOrUpdateNodeNetworkPolicyIPTables([]string{"ANTREA-POL-INGRESS-RULES"}, [][]string{nil}, false).Times(1) | ||
| s1p2.After(s1p1) |
There was a problem hiding this comment.
is there any chance that we can use gomock.InOrder for those? Maybe not because of the last one (s2p3.After(s1p2))?
There was a problem hiding this comment.
gomock.InOrder is a great way for these test cases! It can be used to optimize all the existing test cases.
58ceb7a to
56c8285
Compare
…cy updates or deletions This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
56c8285 to
1616677
Compare
|
/test-kind-all |
…cy updates or deletions (antrea-io#6707) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
…cy updates or deletions (antrea-io#6707) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
…cy updates or deletions (antrea-io#6707) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
…cy updates or deletions (#6707) (#6728) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
…cy updates or deletions (#6707) (#6727) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
…cy updates or deletions (#6707) (#6726) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
…cy updates or deletions (antrea-io#6707) This commit addresses an issue where stale ipset or iptables chain is not deleted during NodeNetworkPolicy updates or deletions. The root cause is that the ipset or iptables chain is still referenced by other iptables rules during the deletion or update attempt. The fix ensures proper order of ipset and iptables synchronization. Signed-off-by: Hongliang Liu <hongliang.liu@broadcom.com>
Fix #6706
This commit addresses an issue where stale ipset or iptables chain is
not deleted during NodeNetworkPolicy updates or deletions. The root cause
is that the ipset or iptables chain is still referenced by other iptables
rules during the deletion or update attempt. The fix ensures proper order
of ipset and iptables synchronization.