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

Use informer code from beyla-k8s-cache #1256

Merged
merged 29 commits into from
Oct 17, 2024

Conversation

mariomac
Copy link
Contributor

As a previous step to allow caching the informers' metadata into an intermediate service, this PR replaces the informers' code by the one used in the https://github.com/grafana/beyla-k8s-cache project.

This also allowed to simplify the informers code, as the previous code was a bit cumbersome and difficult to maintain, being a mixture of two informers (network and app), with some patch-over-patch modifications.

@mariomac mariomac added the do-not-merge WIP or something that musn't be merged label Oct 14, 2024
@mariomac mariomac marked this pull request as draft October 14, 2024 08:43
@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2024

Codecov Report

Attention: Patch coverage is 87.66667% with 37 lines in your changes missing coverage. Please review.

Project coverage is 81.71%. Comparing base (c06df82) to head (dd27d9e).

Files with missing lines Patch % Lines
pkg/internal/kube/informer_provider.go 71.42% 14 Missing and 4 partials ⚠️
pkg/internal/kube/store.go 93.75% 4 Missing and 2 partials ⚠️
pkg/transform/k8s.go 88.37% 3 Missing and 2 partials ⚠️
pkg/internal/discover/watcher_kube.go 91.66% 3 Missing and 1 partial ⚠️
pkg/internal/discover/container_updater.go 77.77% 1 Missing and 1 partial ⚠️
pkg/transform/name_resolver.go 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1256      +/-   ##
==========================================
+ Coverage   78.12%   81.71%   +3.58%     
==========================================
  Files         135      131       -4     
  Lines       11384    11041     -343     
==========================================
+ Hits         8894     9022     +128     
+ Misses       1951     1505     -446     
+ Partials      539      514      -25     
Flag Coverage Δ
integration-test 62.05% <16.66%> (+1.84%) ⬆️
k8s-integration-test 58.59% <81.33%> (?)
oats-test 37.18% <7.66%> (+0.71%) ⬆️
unittests 53.94% <50.00%> (+0.31%) ⬆️

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 removed the do-not-merge WIP or something that musn't be merged label Oct 16, 2024
@mariomac mariomac changed the title WIP: use informer code from beyla-k8s-cache Use informer code from beyla-k8s-cache Oct 16, 2024
@mariomac mariomac marked this pull request as ready for review October 16, 2024 14:44
Copy link
Contributor

@rafaelroquetto rafaelroquetto left a comment

Choose a reason for hiding this comment

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

All my comments are minor and pedantic - feel free to ignore. This looks really good. Way to go, thanks for this!

go.mod Outdated
@@ -1,6 +1,6 @@
module github.com/grafana/beyla

go 1.23
go 1.23.2
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if relevant here, but perhaps we should double check if this has any implications with Alloy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was automatically added by go mod tidy. Let me just revert this line.

Comment on lines 126 to 128
// caching the database initialization. Discarding it as subsequent
// invocations to Get will return the same initialized instance
_, err := ctxInfo.K8sInformer.Get(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Completely subjective and arguable suggestion: perhaps we can do:

func refreshK8sInformerCache(ctx ...) error {
   _, err: ctxInfo.K8sInformer.Get(ctx) // force the cache to be populated/refreshed
  return err
} 

err := refreshK8sInformerCache(ctx)

just so it is a tad more idiomatic - but like I said, feel free to ignore as this is a very subjective approach


return nil
// On is invoked every time an object metadata instance is stored or deleted in the
// kube.Store. It will just forward the event via channel for proper asynchronous
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// kube.Store. It will just forward the event via channel for proper asynchronous
// kube.Store. It will just forward the event via the channel for proper asynchronous

@mariomac mariomac merged commit 233fd32 into grafana:main Oct 17, 2024
10 checks passed
@mariomac mariomac deleted the simplify-informer branch October 17, 2024 08:05
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.

3 participants