-
Notifications
You must be signed in to change notification settings - Fork 238
fix: enable annotations #1471
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
base: main
Are you sure you want to change the base?
fix: enable annotations #1471
Conversation
692e884
to
88bc343
Compare
9391a97
to
1118da4
Compare
Signed-off-by: Alex Castilio dos Santos <alexsantos@microsoft.com>
Signed-off-by: Alex Castilio dos Santos <alexsantos@microsoft.com>
Signed-off-by: Alex Castilio dos Santos <alexsantos@microsoft.com>
…y default Signed-off-by: Alex Castilio dos Santos <alexsantos@microsoft.com>
1118da4
to
feffe34
Compare
Can we have a testing done section ? |
@vakalapa PR description updated with test details. |
pkg/module/metrics/metrics_module.go
Outdated
@@ -108,6 +108,9 @@ type Module struct { | |||
|
|||
// pubsub subscription uuid | |||
pubsubPodSub string | |||
|
|||
// resetRegistry is the function to reset the registry | |||
resetRegistry func(*Module, []api.MetricsContextOptions) |
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.
curious as to why we're using resetRegistry
as an anonymous function and not a method? the usage seems to pass the pointer receiver as it is
resetRegistry func(*Module, []api.MetricsContextOptions) | |
func (m *Module)resetRegistry(contextOptions []api.MetricsContextOptions) |
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.
resetRegistry is a function that receives *Module and resets it's registry. Originally there's some logic in the function with its own dependencies that is not needed in the test. I don't want to consider m.daemonConfig, ctxType, naming logic and functions for creating specific metrics for resetting registry in my test.
There's a test to check generation of advanced metrics. For that, I want to validate the creation of metrics without following the original logic of resetting registry. So I only want to provide a simple way of registry reset:
retina/pkg/module/metrics/metrics_module_linux_test.go
Lines 774 to 778 in feffe34
resetRegistry: func(m *Module, _ []api.MetricsContextOptions) { | |
m.registry[mockMetricName] = myMockMetric | |
myMockMetric.Init(mockMetricName) | |
}, |
If it was a method, this would be way more complex.
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.
In my opinion, mixing and matching CRUD operation patterns here is a slight code smell, especially when reading (m *Module) updateMetricsContexts
where we have both
exporter.ResetAdvancedMetricsRegistry()
...
resetRegistry(m, spec.ContextOptions)
Performing reset operations. Can we not perform any noop dependency injection to match the rest of metricsmodule?
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.
@matmerr I think now I know what you mean. I have changed resetRegistry to RegistryResetter interface:
retina/pkg/module/metrics/metrics_module.go
Line 289 in c836caa
m.registryResetter.Reset(spec.ContextOptions) |
Signed-off-by: Alex Castilio dos Santos <alexsantos@microsoft.com>
This reverts commit a3911a8.
Signed-off-by: Alex Castilio dos Santos <alexsantos@microsoft.com>
c836caa
to
02b33d1
Compare
Description
Feature description: when using option
enableAnnotation: true
advanced metrics should only be generated for pods annotated withretina.sh: observe
or pods in a namespace with that annotation.Bug: When
enableAnnotation: true
advanced metrics are still being generated for all pods.Fix:
kube-system
namespace is not generating metrics by default)Related Issue
x
Checklist
git commit -S -s ...
). See this documentation on signing commits.Screenshots (if applicable) or Testing Completed
Namespace without annotation:

Retina agent logs before annotating:

Retina agent metrics before annotation:
Annotation added:

Retina agent logs after annotation:
Retina agent metrics after annotation:
Additional Notes
Add any additional notes or context about the pull request here.
Please refer to the CONTRIBUTING.md file for more information on how to contribute to this project.