-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
@@ -442,19 +442,35 @@ func (r *nodeReconciler) update(lastRealized *nodePolicyLastRealized, newRule *C | |||
ipnet := newLastRealized.ipnets[ipProtocol] | |||
prevIPSet := lastRealized.ipsets[ipProtocol] | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that why the case where ipset != "" && prevIPSet != "" && ipset != prevIPSet
is not possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
56c8285
to
1616677
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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.