-
Notifications
You must be signed in to change notification settings - Fork 450
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
Add missing label servicemonitor #2573
Add missing label servicemonitor #2573
Conversation
Could we use |
No, but I could include a PodMonitorSelector and ServiceMonitorSelector. WDYT? |
Signed-off-by: Yuri Sa <[email protected]> Add missing label for Service/Pod Monitors Signed-off-by: Yuri Sa <[email protected]> Add missing label for Service/Pod Monitors Signed-off-by: Yuri Sa <[email protected]>
d88ee20
to
ea1e00a
Compare
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.
@yuriolisa i left a comment on the original issue for how I think we should solve this. Let me know your thoughts.
Signed-off-by: Yuri Sa <[email protected]>
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.
A few questions. Do we have an e2e test for this that checks that we successfully pulled metrics based on the SM/PM?
tests/e2e-prometheuscr/create-pm-prometheus-exporters/01-assert.yaml
Outdated
Show resolved
Hide resolved
tests/e2e-prometheuscr/create-sm-prometheus-exporters/01-assert.yaml
Outdated
Show resolved
Hide resolved
Signed-off-by: Yuri Sa <[email protected]>
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.
i meant to click request changes for that podmonitor issue
Signed-off-by: Yuri Sa <[email protected]>
Added the comment and changed the PodMonitor matchLabels to the default one. |
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.
one comment, otherwise i think this is looking good!
tests/e2e-prometheuscr/create-pm-prometheus-exporters/01-assert.yaml
Outdated
Show resolved
Hide resolved
Signed-off-by: Yuri Sa <[email protected]>
Signed-off-by: Yuri Sa <[email protected]>
looks like some legit e2e and lint failures |
Signed-off-by: Yuri Sa <[email protected]>
Signed-off-by: Yuri Sa <[email protected]>
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.
one tiny comment, but i don't think it really matters.
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.
Can we add a e2e test similar to this one: https://github.com/open-telemetry/opentelemetry-operator/tree/main/tests/e2e-targetallocator/targetallocator-prometheuscr? I'd like to check that our generated PodMonitors and ServiceMonitors allow us to actually scrape collector metrics.
Signed-off-by: Yuri Sa <[email protected]>
"app.kubernetes.io/instance": fmt.Sprintf("%s.%s", params.OtelCol.Namespace, params.OtelCol.Name), | ||
"app.kubernetes.io/managed-by": "opentelemetry-operator", | ||
"app.kubernetes.io/part-of": "opentelemetry", | ||
"app.kubernetes.io/name": naming.MonitoringService(params.OtelCol.Name), |
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.
@yuriolisa i realized that we actually need to update the monitoring service for the collector to have its own special label in the same way we do for headless and instead match on that.
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 because the name label for the service actually is just the name of the overall collector
Signed-off-by: Yuri Sa <[email protected]>
Signed-off-by: Yuri Sa <[email protected]>
headlessLabel = "operator.opentelemetry.io/collector-headless-service" | ||
headlessExists = "Exists" | ||
headlessLabel = "operator.opentelemetry.io/collector-headless-service" | ||
headlessExists = "Exists" |
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.
i think we can consolidate here
@@ -44,7 +46,7 @@ func HeadlessService(params manifests.Params) (*corev1.Service, error) { | |||
h.Name = naming.HeadlessService(params.OtelCol.Name) | |||
h.Labels[headlessLabel] = headlessExists | |||
|
|||
// copy to avoid modifying params.OtelCol.Annotations | |||
// copy to avoid modifying params.OtelCol.annotations |
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.
uppercase?
@@ -44,7 +44,6 @@ func ServiceMonitor(params manifests.Params) (*monitoringv1.ServiceMonitor, erro | |||
} | |||
name := naming.ServiceMonitor(params.OtelCol.Name) | |||
labels := manifestutils.Labels(params.OtelCol.ObjectMeta, name, params.OtelCol.Spec.Image, ComponentOpenTelemetryCollector, []string{}) | |||
selectorMatchLabels := manifestutils.SelectorMatchLabels(params.OtelCol.ObjectMeta, ComponentOpenTelemetryCollector) |
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.
we should still be using this to match on the overall labels we expect the service to have, otherwise our match would be too wide
Signed-off-by: Yuri Sa <[email protected]>
Signed-off-by: Yuri Sa <[email protected]>
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.
Just one last thing to improve test confidence, but the overall logic here looks 👌
Signed-off-by: Yuri Sa <[email protected]>
* Add missing label for Service/Pod Monitors Signed-off-by: Yuri Sa <[email protected]> Add missing label for Service/Pod Monitors Signed-off-by: Yuri Sa <[email protected]> Add missing label for Service/Pod Monitors Signed-off-by: Yuri Sa <[email protected]> * Added manifests.utils to set labels Signed-off-by: Yuri Sa <[email protected]> * Fixed labels names Signed-off-by: Yuri Sa <[email protected]> * Fixed labels for PodMonitor Signed-off-by: Yuri Sa <[email protected]> * Fixed e2e test Signed-off-by: Yuri Sa <[email protected]> * Fixed e2e test Signed-off-by: Yuri Sa <[email protected]> * Fixed selectorMatchLabels Signed-off-by: Yuri Sa <[email protected]> * Removed the extra method Signed-off-by: Yuri Sa <[email protected]> * Adjusted nil Signed-off-by: Yuri Sa <[email protected]> * Changed labels Signed-off-by: Yuri Sa <[email protected]> * Changed labels Signed-off-by: Yuri Sa <[email protected]> * Readded common labels Signed-off-by: Yuri Sa <[email protected]> * Readded common labels Signed-off-by: Yuri Sa <[email protected]> * Added labels assert Signed-off-by: Yuri Sa <[email protected]> --------- Signed-off-by: Yuri Sa <[email protected]>
Description:
Add missing label for Service/Pod Monitors
Link to tracking Issue:
Resolves #2251
Testing:
Added unit and e2e tests.
Documentation: