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

Asynchronous synchronization of Beyla cache #1358

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

mariomac
Copy link
Contributor

Alleviates the following issues: #1349 and #1354

The Beyla cache service was not accepting connections before it had a complete copy of the Kubernetes cache.

In big clusters (~1000 nodes) that meant that each cache instance would take some minutes to completely initialize, and beyla instances would keep reporting errors.

This PR enables the service as soon as the process start, and keeps accepting Beyla connections while the cache is still synchronizing, making sure that the Beyla clients won't receive the synchronization signal until the cache service is fully synchronized.

Comment on lines -183 to -190
select {
case <-time.After(mp.cfg.SyncTimeout):
klog().Warn("kubernetes cache has not been synced after timeout. The kubernetes attributes might be incomplete."+
" Consider increasing the BEYLA_KUBE_INFORMERS_SYNC_TIMEOUT value", "timeout", mp.cfg.SyncTimeout)
case err, ok := <-done:
if ok {
return nil, fmt.Errorf("failed to initialize Kubernetes informers: %w", err)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we didn't realize a bug here.

If the timeout happened, the later returned "informers" variable would be nil, as it requires that the InitInformers function successfully returns from another goroutine.

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 79.16667% with 15 lines in your changes missing coverage. Please review.

Project coverage is 72.06%. Comparing base (c4244b1) to head (c05b908).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/kubecache/meta/informers_init.go 80.00% 6 Missing and 4 partials ⚠️
pkg/kubecache/meta/informers.go 58.33% 4 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (c4244b1) and HEAD (c05b908). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (c4244b1) HEAD (c05b908)
unittests 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1358      +/-   ##
==========================================
- Coverage   79.06%   72.06%   -7.01%     
==========================================
  Files         145      144       -1     
  Lines       14648    14661      +13     
==========================================
- Hits        11581    10565    -1016     
- Misses       2489     3395     +906     
- Partials      578      701     +123     
Flag Coverage Δ
integration-test 58.86% <43.05%> (-0.04%) ⬇️
k8s-integration-test 59.57% <79.16%> (+0.18%) ⬆️
oats-test 34.29% <1.38%> (?)
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mariomac mariomac merged commit 3a57830 into grafana:main Nov 14, 2024
13 checks passed
@mariomac mariomac deleted the async-init-cache branch November 14, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants