Add owner references to EnhancedEvent, consolidate calls to apiserver, make cache size configurable and add metrics for reads #144
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.
Details
There are a few changes in this PR.
OwnerReferences
is added to the exported events.Deleted
field in exported eventsThis is to capture whether the object is deleted. This helps receivers identify whether a resource is deleted and create rules for it when needed.
Consolidate the number of read calls to kube-apiserver
Currently, every time there's an event, the events exporter runs
GetObject
method for metadata like labels and annotations independently. This results in the multiple read calls to kube-apiserver for the same object. These number of read call grow as we want to look up additional information about the object likeownerReferences
.So, in this change, a struct called
ObjectMetadata
is created to capture all the pieces of information about the object that need to be added to the EnhancedEvent. Every time there's an event, the object is fetched from kube-apiserver if it's not in the cache already and all pieces of metadata require only 1 call. The metadata is cached so repeated events about the same object don't result in more calls.Additionally,
UID + ResourceVersion
is used the cache key so if the object changes, it's looked up again.Cache size is made configurable with a default size of
1024
as beforeMetrics are added to capture reads served from cache and apiserver
Addresses issues
ownerReferences
to the exported events #143Testing done
Tests
Events
New metrics