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

Fix k8 namespace cache in database #1059

Merged
merged 3 commits into from
Jul 26, 2024
Merged

Conversation

grcevski
Copy link
Contributor

I think this fixes a bug that was very hard to track. Essentially, we saw a wrong service name used for events in a cluster, where there were a few subsequent launches and deaths of containers.

A container namespace was reused between two services on the new launch and the k8s decorator resolved the wrong name for the service, even though we had the correct destination name in the IP to name resolution. This means that the service IP caches were correct, but the name info was stale.

I made two changes to ensure we cleanup the namespace cache:

  1. When we overwrite the namespaces map, we clean up the cache for the namespace. I believe this is sufficient for the fix.
  2. I added a secondary cleanup of the cache when we run process deletion.

@grcevski grcevski requested review from mariomac and marctc as code owners July 25, 2024 21:11
@@ -108,19 +108,35 @@ func (id *Database) OnDeletion(containerID []string) {
}
}

func (id *Database) addProcess(ifp *container.Info) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this refactor so that I can use this logic in a test.

@codecov-commenter
Copy link

codecov-commenter commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.79%. Comparing base (bbb675b) to head (2d4944e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1059      +/-   ##
==========================================
+ Coverage   81.76%   81.79%   +0.03%     
==========================================
  Files         139      139              
  Lines       11289    11297       +8     
==========================================
+ Hits         9230     9240      +10     
+ Misses       1542     1541       -1     
+ Partials      517      516       -1     
Flag Coverage Δ
integration-test 56.96% <0.00%> (+0.16%) ⬆️
k8s-integration-test 58.98% <100.00%> (+0.08%) ⬆️
oats-test 37.02% <0.00%> (-0.03%) ⬇️
unittests 52.21% <82.35%> (+0.11%) ⬆️

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.

Copy link
Contributor

@mariomac mariomac left a comment

Choose a reason for hiding this comment

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

💪

@grcevski grcevski merged commit ada2a72 into grafana:main Jul 26, 2024
6 checks passed
@grcevski grcevski deleted the fix_service_cache branch July 26, 2024 13:28
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.

5 participants