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

resource: Work around a rare race in initial sync #23292

Merged
merged 1 commit into from
Feb 1, 2023

Commits on Jan 24, 2023

  1. resource: Work around a rare race in initial sync

    TestResource_WithFakeClient is sometimes failing due to seeing
    two Upserts instead of Upsert+Sync. This is due to the fact that
    we add the initial set of keys from the store to the queue when
    subscribing in Events() and the fact that adding to the store is
    happening before our event handler runs. The sequence of events
    looks like this:
    
      [informer 1/2] add object A to store
      [resource] subscribe and add object with key A to queue
      [resource] dequeue A and emit Event{Upsert, A}
      [informer 2/2] call AddFunc handler for A and queue A
      [resource] dequeue A and emit Event{Upsert, A}
    
    Work around the issue by allowing the extra Upsert event in
    the test case.
    
    Proper fix for this would be to either detect a duplicate using
    ResourceVersion, or implementing a custom Process function that
    synchronizes the updating of the store with subscribing
    (e.g. pkg/k8s/informer/informer.go).
    
    Fixes: cilium#23079
    Fixes: 4101e2c ("k8s: Add resource package")
    Signed-off-by: Jussi Maki <jussi@isovalent.com>
    joamaki committed Jan 24, 2023
    Configuration menu
    Copy the full SHA
    9d22723 View commit details
    Browse the repository at this point in the history