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

Commits on Oct 13, 2023

  1. Fix NetworkPolicy span calculation

    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 committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    8874d57 View commit details
    Browse the repository at this point in the history