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

NETOBSERV-1427: Added config watcher and supporting metrics reloading #607

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

OlivierCazade
Copy link
Contributor

Description

Added new type to watch a configmap and notify prometheus encoder

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist.
  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
    • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
    • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
    • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 22, 2024

@OlivierCazade: This pull request references NETOBSERV-1427 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

In response to this:

Description

Added new type to watch a configmap and notify prometheus encoder

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist.
  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

}
}

func (e *EncodeProm) cleanDeletedCounters(newCfg api.PromEncode) {
Copy link
Member

Choose a reason for hiding this comment

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

after rebasing this code can probably be simplified, with all cleanup functions merged in a single one, as Kalman did use a common struct for all the metric types

switch mCfg.Type {
case api.MetricEncodeOperationName("Counter"):
if oldMetric, ok := e.counters[fullMetricName]; ok {
if !reflect.DeepEqual(mInfo, oldMetric.info) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if that works as intended, as info contains a predicate (a function) so they'll likely never be equal: https://pkg.go.dev/reflect#DeepEqual
You could test just the api definition oldMetric.info.MetricsItem

func (pcw *pipelineConfigWatcher) updateFromConfigmap(cm *corev1.ConfigMap) {
if rawConfig, ok := cm.Data[pcw.configFile]; ok {
config := config.ConfigHotReloadStruct{}
err := json.Unmarshal([]byte(rawConfig), config)
Copy link
Member

Choose a reason for hiding this comment

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

govet messages below seem relevant, I guess Unmarshalling would fail here


}

func (e *EncodeProm) cleandDeletedMetrics(newCfg api.PromEncode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps cleanDeletedMetrics (without the extra d)?

Copy link

codecov bot commented Mar 14, 2024

Codecov Report

Attention: Patch coverage is 13.96104% with 265 lines in your changes are missing coverage. Please review.

Project coverage is 65.11%. Comparing base (d2b2352) to head (3d16544).
Report is 2 commits behind head on main.

❗ Current head 3d16544 differs from pull request most recent head 2e05954. Consider uploading reports for the commit 2e05954 to get more accurate results

Files Patch % Lines
pkg/pipeline/encode/encode_prom.go 6.32% 163 Missing ⚠️
pkg/pipeline/pipeline_watcher.go 8.95% 61 Missing ⚠️
pkg/utils/kubernetes.go 0.00% 22 Missing ⚠️
pkg/pipeline/encode/encode_s3.go 0.00% 4 Missing ⚠️
...ipeline/encode/opentelemetry/encode_otlpmetrics.go 40.00% 3 Missing ⚠️
pkg/pipeline/pipeline.go 66.66% 2 Missing and 1 partial ⚠️
pkg/pipeline/encode/encode.go 0.00% 2 Missing ⚠️
pkg/pipeline/encode/encode_kafka.go 0.00% 2 Missing ⚠️
...g/pipeline/encode/opentelemetry/encode_otlplogs.go 0.00% 2 Missing ⚠️
.../pipeline/encode/opentelemetry/encode_otlptrace.go 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #607      +/-   ##
==========================================
- Coverage   67.41%   65.11%   -2.31%     
==========================================
  Files         102      112      +10     
  Lines        7589     7940     +351     
==========================================
+ Hits         5116     5170      +54     
- Misses       2162     2456     +294     
- Partials      311      314       +3     
Flag Coverage Δ
unittests 65.11% <13.96%> (-2.31%) ⬇️

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.

@codecov-commenter
Copy link

codecov-commenter commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 15.86716% with 228 lines in your changes are missing coverage. Please review.

Project coverage is 66.49%. Comparing base (a5ad247) to head (c306f62).
Report is 5 commits behind head on main.

Files Patch % Lines
pkg/pipeline/encode/encode_prom.go 10.00% 90 Missing ⚠️
pkg/pipeline/pipeline_watcher.go 8.47% 54 Missing ⚠️
pkg/pipeline/pipeline_builder.go 22.85% 26 Missing and 1 partial ⚠️
pkg/utils/kubernetes.go 0.00% 17 Missing ⚠️
pkg/config/pipeline_builder.go 0.00% 16 Missing ⚠️
pkg/config/config.go 0.00% 5 Missing and 1 partial ⚠️
pkg/pipeline/encode/encode_s3.go 0.00% 4 Missing ⚠️
...ipeline/encode/opentelemetry/encode_otlpmetrics.go 40.00% 3 Missing ⚠️
pkg/pipeline/encode/encode.go 0.00% 2 Missing ⚠️
pkg/pipeline/encode/encode_kafka.go 0.00% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #607      +/-   ##
==========================================
- Coverage   67.43%   66.49%   -0.94%     
==========================================
  Files         102      104       +2     
  Lines        7593     6659     -934     
==========================================
- Hits         5120     4428     -692     
+ Misses       2162     1916     -246     
- Partials      311      315       +4     
Flag Coverage Δ
unittests 66.49% <15.86%> (-0.94%) ⬇️

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.

@OlivierCazade OlivierCazade force-pushed the 1427-hotreload branch 4 times, most recently from ca4a86c to 64d701b Compare April 4, 2024 14:32
@OlivierCazade
Copy link
Contributor Author

/retest

@OlivierCazade OlivierCazade changed the title WIP NETOBSERV-1427: Added config watcher and supporting metrics reloading NETOBSERV-1427: Added config watcher and supporting metrics reloading Apr 19, 2024
@jotak
Copy link
Member

jotak commented Apr 19, 2024

thanks @OlivierCazade !
/lgtm

@memodi
Copy link

memodi commented Apr 24, 2024

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved QE has approved this pull request label Apr 24, 2024
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Apr 24, 2024

@OlivierCazade: This pull request references NETOBSERV-1427 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

In response to this:

Description

Added new type to watch a configmap and notify prometheus encoder

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist.
  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@OlivierCazade
Copy link
Contributor Author

/approve

Copy link

openshift-ci bot commented Apr 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: OlivierCazade

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 2ab1f8d into netobserv:main Apr 26, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants