Skip to content
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

Automated cherry pick of #5554: Fix NetworkPolicy span calculation #5574

Conversation

tnqn
Copy link
Member

@tnqn tnqn commented Oct 13, 2023

Cherry pick of #5554 on release-1.11.

#5554: Fix NetworkPolicy span calculation

For details on the cherry pick process, see the cherry pick requests page.

@tnqn tnqn added the kind/cherry-pick Categorizes issue or PR as related to the cherry-pick of a bug fix from the main branch to a release label Oct 13, 2023
A NetworkPolicy's span is calculated in internalNetworkPolicyWorker,
based on the span of the AppliedToGroups it refers to, while the span of
AppliedToGroup is calculated in appliedToGroupWorker which runs in
parallel with internalNetworkPolicyWorker. It could happen that the
calcuated span is out of date if AppliedToGroups' span is updated after
internalNetworkPolicyWorker calculates a NetworkPolicy's span, and the
NetworkPolicy wouldn't be enqueued for another sync if it's not
committed to the storage yet.

On the other hand, if we commit the NetworkPolicy to the storage before
calculating the NetworkPolicy's span, it would have to use a stale span
first and might need to update the NetworkPolicy twice and generate two
update events in one sync.

To fix the issue without generating extra events, we introduce a
separate subscription mechanism that allows subscribing to update of
AppliedToGroup for NetworkPolicy. With the subscription, we can still
calculate the NetworkPolicy's span first, then commit it to the storage.
If any of the subscribed AppliedToGroups are updated, the NetworkPolicy
will be notified and resynced.

Signed-off-by: Quan Tian <[email protected]>
@tnqn tnqn force-pushed the automated-cherry-pick-of-#5554-upstream-release-1.11 branch from 64a9a25 to 8874d57 Compare October 13, 2023 05:58
@tnqn
Copy link
Member Author

tnqn commented Oct 16, 2023

/skip-all

@tnqn tnqn merged commit d50633c into antrea-io:release-1.11 Oct 16, 2023
51 of 58 checks passed
@tnqn tnqn deleted the automated-cherry-pick-of-#5554-upstream-release-1.11 branch October 16, 2023 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cherry-pick Categorizes issue or PR as related to the cherry-pick of a bug fix from the main branch to a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants