-
Notifications
You must be signed in to change notification settings - Fork 14
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
Delete pod stats on pod deleted #153
Conversation
func (s *Stats) RunGC(client kubernetes.Interface, namespace string, stopCh <-chan struct{}) error { | ||
|
||
factory := informers.NewSharedInformerFactoryWithOptions(client, time.Hour*24, informers.WithNamespace(namespace)) | ||
podInformer := factory.Core().V1().Pods() | ||
podInformer.Informer().AddEventHandler( | ||
cache.ResourceEventHandlerFuncs{ | ||
DeleteFunc: deleteStatsForDeletedPodsFn(s), | ||
}, | ||
) | ||
|
||
factory.Start(stopCh) | ||
// wait for the initial synchronization of the local cache. | ||
if !cache.WaitForCacheSync(stopCh, podInformer.Informer().HasSynced) { | ||
return errors.New("failed to sync") | ||
} | ||
|
||
return nil | ||
|
||
} | ||
|
||
func deleteStatsForDeletedPodsFn(s *Stats) func(obj interface{}) { | ||
|
||
return func(obj interface{}) { | ||
switch o := obj.(type) { | ||
case *corev1.Pod: | ||
s.DeleteKeysByFilter(o.GetName()) | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the relevant code that deletes the pod related stats when a pod is deleted.
/lgtm |
LGTM label has been added. Git tree hash: 66624cecbcedd5867bb20434503c03be7bc7651f
|
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: roivaz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/ok-to-test |
4c518f4
to
91c3e14
Compare
This PR adds a garbage collector to delete stats of pods that have been deleted. It is basically a k8s informer that reacts to pod deletion events by removing all the stats related to the pod from the stats cache.
The PR also removes all stats that had information about the grpc stream_id. This was previously used to cleanup stats but it was producing inconsistent results .
/kind bug
/priority important-soon
/assign