-
Notifications
You must be signed in to change notification settings - Fork 271
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
Progress metrics refactor and rename #3254
Conversation
3a816be
to
ded9c22
Compare
pkg/util/prometheus/prometheus.go
Outdated
@@ -66,12 +64,12 @@ func (r *ProgressReader) updateProgress() bool { | |||
currentProgress = float64(r.Current) / float64(r.total) * 100.0 | |||
} | |||
metric := &dto.Metric{} |
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 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
func InitCloneProgressCounterVec() { | ||
cloneProgress = newCloneProgressCounterVec() | ||
} |
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 avoid this, and inline the metric declaration, if in the test you call SetupMetrics
//Subsystem: "volume_populators", | ||
Name: "openstack_volume_populator", |
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.
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
//Subsystem: "volume_populators", | |
Name: "openstack_volume_populator", | |
Name: "volume_populators_openstack_volume_populator", |
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.
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))) |
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.
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 { |
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 avoid this and only use add/set operations, this file should abstract Prometheus to the outside
ded9c22
to
0245f42
Compare
|
||
populatorProgress = operatormetrics.NewCounterVec( | ||
operatormetrics.MetricOpts{ | ||
Name: "ovirt_progress", |
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.
Same. The metric requires kubevirt_cdi_ prefix
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.
Also missing _total
suffix, since it's a counter.
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.
@bennyz wdyt?
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.
renamed
@arnongilboa We have a metric name linter, can you please add the new metrics in |
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>
0245f42
to
d189bfe
Compare
d72e060
to
2490c89
Compare
Also add the metrics to the doc and json generation tools. Signed-off-by: Arnon Gilboa <agilboa@redhat.com>
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.
Will wait for the metrics folks to give their blessing, but code wise looks good to me.
/test pull-cdi-goveralls |
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.
nit: I think we could avoid calling SetupMetrics
in the init
functions, but let's not block this because of that
/lgtm |
/approve |
[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 |
### kubevirt_cdi_operator_up | ||
CDI operator status. Type: Gauge. | ||
|
||
### kubevirt_cdi_ovirt_progress_total |
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.
@arnongilboa shouldn't the metric name include populator like it is for openstack?
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.
@arnongilboa can you please update the metrics description to be clearer? They are the same for both the openstack and ovirt metrics
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.
@bennyz please consider doing it in a follow-up PR
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.
Sure. I'm OK with that.
/retest |
/lgtm kubevirt_cdi_ovirt_progress_total metric name and description would be updated in a follow-up PR. |
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
* [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>
What this PR does / why we need it:
clone_progress
,openstack_populator_progress
andovirt_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: