Sync cache with timeout, fix apbroute start #3763
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WaitForCacheSync function takes stopChannel as an argument, and it will
retry syncing cache until it is closed. If we just use ovn-kube stop
channel, it will never return an error (it will never return until
either the cache is synced, or stopChannel is closed).
To fix it, GetChildStopChanWithTimeout and some wrappers functions
passing this channel with timeout were added. The default cache sync
timeout is 20 seconds (with reflector exponential backoff it means 4
list() retries).
If any informer failed to list its resource withing a given time period,
return error to make the problem visible.
To test this change, comment out list permission for any object in
dist/templates/ovn-setup.yaml.j2, run kind cluster and check the
corresponding container fails with message like
"failed to start ovnkube controller: error in syncing cache for
*v1.EndpointSlice informer"
Don't add event handlers for existing informers in constructor.
Do so only if Run() is called, otherwise workqueues will be filled,
but not handled.
I joined these 2 fixes together, because they both add an error to the
Run
method of the apbroute controllers