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

Progress metrics refactor and rename #3254

Merged

Conversation

arnongilboa
Copy link
Collaborator

@arnongilboa arnongilboa commented May 12, 2024

What this PR does / why we need it:
clone_progress, openstack_populator_progress and ovirt_progress metrics are not in the monitoring package. These metrics are not with correct metrics names, based on the kubevirt and Prometheus metrics naming conventions, they are not documented and are not located under /pkg/monitoring. After the code refactoring we should not have Prometheus metrics in other places in the code, other than the /monitoring/metrics package, and metrics should be registered using operator-observability package.

In addition, we aligned the progress metric names with the metric naming linter rules: kubevirt_cdi_clone_progress_total, kubevirt_cdi_openstack_populator_progress_total, kubevirt_cdi_ovirt_progress_total.

Which issue(s) this PR fixes:
Fixes # https://issues.redhat.com/browse/CNV-36845

Special notes for your reviewer:

Release note:

Align progress metrics names with kubevirt and Prometheus metrics naming conventions

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels May 12, 2024
@coveralls
Copy link

coveralls commented May 12, 2024

Coverage Status

coverage: 17.259% (+0.02%) from 17.24%
when pulling adb1b1d on arnongilboa:clone_progress_metric_refactor
into d2f3903 on kubevirt:main.

@arnongilboa arnongilboa changed the title Clone progress metric refactor clone_progress and openstack_volume_populator metrics refactor May 13, 2024
@arnongilboa arnongilboa force-pushed the clone_progress_metric_refactor branch 2 times, most recently from 3a816be to ded9c22 Compare May 13, 2024 09:44
@@ -66,12 +64,12 @@ func (r *ProgressReader) updateProgress() bool {
currentProgress = float64(r.Current) / float64(r.total) * 100.0
}
metric := &dto.Metric{}
Copy link
Member

Choose a reason for hiding this comment

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

we could also move this very specific Prometheus metric impl to the monitoring package, and make WriteCloneProgress return the value, which we would use later instead of *metric.Counter.Value

Comment on lines 17 to 19
func InitCloneProgressCounterVec() {
cloneProgress = newCloneProgressCounterVec()
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can avoid this, and inline the metric declaration, if in the test you call SetupMetrics

Comment on lines 14 to 15
//Subsystem: "volume_populators",
Name: "openstack_volume_populator",
Copy link
Member

Choose a reason for hiding this comment

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

with

Subsystem: "volume_populators",
Name:      "openstack_volume_populator",

the name was: "volume_populators_openstack_volume_populator", here we should have
https://github.com/prometheus/client_golang/blob/6e3f4b1091875216850a486b1c2eb0e5ea852f98/prometheus/metric.go#L69

Suggested change
//Subsystem: "volume_populators",
Name: "openstack_volume_populator",
Name: "volume_populators_openstack_volume_populator",

Copy link
Contributor

Choose a reason for hiding this comment

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

If we are generating the metric it should have kubevirt_cdi_ prefix

metric := &dto.Metric{}
Expect(progress.WithLabelValues(ownerUID).Write(metric)).To(Succeed())
Expect(metrics.WriteCloneProgress(ownerUID, metric)).To(Succeed())
Expect(*metric.Counter.Value).To(Equal(float64(0)))
Copy link
Member

Choose a reason for hiding this comment

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

instead of using &dto.Metric{}, create a method to get the value of a metric in pkg/monitoring, such as https://github.com/kubevirt/kubevirt/blob/e6207f255d85c24567f1d28b5a6f232279ae68ff/pkg/monitoring/metrics/virt-controller/vmi_metrics.go#L43

}

// WriteCloneProgress writes the cloneProgress metric into a metric protocol buffer
func WriteCloneProgress(labelValue string, metric *ioprometheusclient.Metric) error {
Copy link
Member

Choose a reason for hiding this comment

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

we should avoid this and only use add/set operations, this file should abstract Prometheus to the outside

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2024
@arnongilboa arnongilboa force-pushed the clone_progress_metric_refactor branch from ded9c22 to 0245f42 Compare May 15, 2024 19:59
@kubevirt-bot kubevirt-bot added size/XL and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L labels May 15, 2024
@arnongilboa arnongilboa changed the title clone_progress and openstack_volume_populator metrics refactor Progress metrics refactor May 15, 2024

populatorProgress = operatormetrics.NewCounterVec(
operatormetrics.MetricOpts{
Name: "ovirt_progress",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same. The metric requires kubevirt_cdi_ prefix

Copy link
Contributor

@assafad assafad May 16, 2024

Choose a reason for hiding this comment

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

Also missing _total suffix, since it's a counter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bennyz wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed

@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2024
@assafad
Copy link
Contributor

assafad commented May 16, 2024

@arnongilboa We have a metric name linter, can you please add the new metrics in
https://github.com/kubevirt/containerized-data-importer/blob/main/tools/prom-metrics-collector/metrics_json_generator.go? You can then use it locally with make lint-metrics and see what names you need to fix.
@machadovilaca @avlitman @sradco FYI, when new metrics groups are added, the developer needs to add the new group to the metrics names linter, or else CI won't catch it.

The clone_progress metric is not in the monitoring package. The metric
is with incorrect name, based on the kubevirt and Prometheus metrics
naming conventions. It's not documented and not located under
/pkg/monitoring. After the code refactoring we should not have
Prometheus metrics in other places in the code, other than the
/monitoring/metrics package, and metrics should be registered using
operator-observability package.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
@arnongilboa arnongilboa force-pushed the clone_progress_metric_refactor branch from 0245f42 to d189bfe Compare May 16, 2024 08:28
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 16, 2024
@arnongilboa arnongilboa changed the title Progress metrics refactor Progress metrics refactor and rename May 16, 2024
@arnongilboa arnongilboa force-pushed the clone_progress_metric_refactor branch 2 times, most recently from d72e060 to 2490c89 Compare May 16, 2024 11:45
Also add the metrics to the doc and json generation tools.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Copy link
Member

@awels awels left a comment

Choose a reason for hiding this comment

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

Will wait for the metrics folks to give their blessing, but code wise looks good to me.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label May 16, 2024
@awels
Copy link
Member

awels commented May 16, 2024

/test pull-cdi-goveralls

Copy link
Member

@machadovilaca machadovilaca left a comment

Choose a reason for hiding this comment

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

nit: I think we could avoid calling SetupMetrics in the init functions, but let's not block this because of that

@machadovilaca
Copy link
Member

/lgtm

@awels
Copy link
Member

awels commented May 16, 2024

/approve

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: awels

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 16, 2024
### kubevirt_cdi_operator_up
CDI operator status. Type: Gauge.

### kubevirt_cdi_ovirt_progress_total
Copy link
Contributor

Choose a reason for hiding this comment

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

@arnongilboa shouldn't the metric name include populator like it is for openstack?

Copy link
Contributor

@sradco sradco May 16, 2024

Choose a reason for hiding this comment

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

@arnongilboa can you please update the metrics description to be clearer? They are the same for both the openstack and ovirt metrics

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bennyz please consider doing it in a follow-up PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. I'm OK with that.

@arnongilboa
Copy link
Collaborator Author

/retest

@sradco
Copy link
Contributor

sradco commented May 17, 2024

/lgtm

kubevirt_cdi_ovirt_progress_total metric name and description would be updated in a follow-up PR.
This PR is urgent to unblock the metrics code refactoring linter PR.

@kubevirt-bot kubevirt-bot merged commit a5cedb1 into kubevirt:main May 17, 2024
19 checks passed
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request May 18, 2024
Manual backport of kubevirt#3254

clone_progress, openstack_populator_progress and ovirt_progress metrics
are not in the monitoring package. These metrics are not with correct
metrics names, based on the kubevirt and Prometheus metrics naming
conventions, they are not documented and are not located under
/pkg/monitoring. After the code refactoring we should not have
Prometheus metrics in other places in the code, other than the
/monitoring/metrics package, and metrics should be registered using
operator-observability package.

In addition, we aligned the progress metric names with the metric
naming linter rules:
kubevirt_cdi_clone_progress_total
kubevirt_cdi_openstack_populator_progress_total
kubevirt_cdi_ovirt_progress_total

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 18, 2024
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request May 18, 2024
Manual backport of kubevirt#3254

clone_progress, openstack_populator_progress and ovirt_progress metrics
are not in the monitoring package. These metrics are not with correct
metrics names, based on the kubevirt and Prometheus metrics naming
conventions, they are not documented and are not located under
/pkg/monitoring. After the code refactoring we should not have
Prometheus metrics in other places in the code, other than the
/monitoring/metrics package, and metrics should be registered using
operator-observability package.

In addition, we aligned the progress metric names with the metric
naming linter rules:
kubevirt_cdi_clone_progress_total
kubevirt_cdi_openstack_populator_progress_total
kubevirt_cdi_ovirt_progress_total

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request May 27, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request May 27, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
akalenyu pushed a commit to akalenyu/containerized-data-importer that referenced this pull request May 28, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
akalenyu pushed a commit to akalenyu/containerized-data-importer that referenced this pull request May 29, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request May 30, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request Jun 1, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
arnongilboa added a commit to arnongilboa/containerized-data-importer that referenced this pull request Jun 2, 2024
Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in kubevirt#3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
kubevirt-bot pushed a commit that referenced this pull request Jun 3, 2024
* Fix progress metric registration and parsing

Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Fix the metric parsing to match its new name. Otherwise the DV progress
will not be updated until its 100%.

Regression introduced in #3254

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add kubevirt_cdi_import_progress_total metric

Use it in the importer instead of kubevirt_cdi_clone_progress_total and
fix metric parsing accordingly.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Move ProgressFromClaim to host-clone

Nobody else is using it.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Add ProgressMetric interface

ProgressReader can now work with either import or clone progress metric.
FIXME: consider removing the direct Add/Get and use only via interface.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Refactor ProgressMetric interface

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Refactor progress parsing

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* Refer metric names from the metrics package

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

---------

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
kubevirt-bot pushed a commit that referenced this pull request Jul 10, 2024
* [release-v1.59] Progress metrics refactor and rename

Manual backport of #3254

clone_progress, openstack_populator_progress and ovirt_progress metrics
are not in the monitoring package. These metrics are not with correct
metrics names, based on the kubevirt and Prometheus metrics naming
conventions, they are not documented and are not located under
/pkg/monitoring. After the code refactoring we should not have
Prometheus metrics in other places in the code, other than the
/monitoring/metrics package, and metrics should be registered using
operator-observability package.

In addition, we aligned the progress metric names with the metric
naming linter rules:
kubevirt_cdi_clone_progress_total
kubevirt_cdi_openstack_populator_progress_total
kubevirt_cdi_ovirt_progress_total

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* [release-v1.59] Fix progress metric registration and parsing

Manual backport of #3292

Use default metric registration. We shouldn't use the controller-runtime
registration as we have no controller here and it will not register the
metric correctly.

Add kubevirt_cdi_import_progress_total metric and use it in the importer
instead of kubevirt_cdi_clone_progress_total.

Fix the metric parsing to match their new names. Otherwise the DV
progress will not be updated until its 100%.

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>

* [release-v1.59] Fix progress reporting for http imports

Backport of #3293

* tests: fix regex in import progress test

This test currently passes since the regex will always catch 100%,
hiding a bug we have in progress reporting.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Fix actual progress reporting for url->scratch

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* Hold on with reporting 100% until pod exits

Otherwise, we'll be reporting 100% prior to convert/resize/... being
done

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

* tests: fix a test that was adapted to no progress reporting

this tests cares about some progress being made so N/A
isn't the right choice

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

---------

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>

---------

Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
Co-authored-by: Alex Kalenyuk <akalenyu@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants