-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 VMI filesystem usage metrics #7814
Add VMI filesystem usage metrics #7814
Conversation
/retest |
1 similar comment
/retest |
/cc |
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.
Hi @machadovilaca Thank you for the PR
I have a small question below
metrics.pushCustomMetric( | ||
"kubevirt_vmi_filesystem_total_bytes", | ||
"Total VM filesystem capacity in bytes.", | ||
prometheus.GaugeValue, |
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.
Why have you decided to work with Gauge
metric instead of 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.
Per my understanding, for some types of filesystem, it is possible to change the total capacity, so this value might both go up and down, so I think we should use the Gauge
here
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.
+1
metrics.pushCustomMetric( | ||
"kubevirt_vmi_filesystem_used_bytes", | ||
"Used VM filesystem capacity in bytes.", | ||
prometheus.GaugeValue, |
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 here
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.
Here, this value might go up and down arbitrarily, so I think we should use the Gauge
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.
+1
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.
@machadovilaca Thank you! overall looks good, please see my comments below
fsLabels := []string{"disk"} | ||
|
||
for _, fsStat := range vmFSStats.Items { | ||
fsLabelValues := []string{fsStat.DiskName} |
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.
@machadovilaca Following is the struct:
type VirtualMachineInstanceFileSystem struct {
DiskName string `json:"diskName"`
MountPoint string `json:"mountPoint"`
FileSystemType string `json:"fileSystemType"`
UsedBytes int `json:"usedBytes"`
TotalBytes int `json:"totalBytes"`
}
I see that you don't scrap the MountPoint
and the FileSystemType
values, is that in purpose?
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.
not really, will add
return | ||
} | ||
|
||
// GetDomainStats() or may hang for a long time. |
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.
@machadovilaca Sorry I didn't understand the comment, can you please elaborate?
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.
misadded "or "
@@ -536,17 +562,23 @@ func (ps *prometheusScraper) Scrape(socketFile string, vmi *k6tv1.VirtualMachine | |||
} | |||
defer cli.Close() | |||
|
|||
vmStats, exists, err := cli.GetDomainStats() | |||
vmDomainStats, exists, err := cli.GetDomainStats() |
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.
@machadovilaca Can you please create a separate commit for the refactoring of the vmStats
name? please add in the commit message the reason why the new name is better
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.
Does this still make sense after https://github.com/kubevirt/kubevirt/pull/7814/files#r923806175 ?
} | ||
|
||
func (ps *prometheusScraper) Report(socketFile string, vmi *k6tv1.VirtualMachineInstance, vmStats *stats.DomainStats) { | ||
// statsMaxAge is an estimation - and there is not better way to do that. So it is possible that | ||
func (ps *prometheusScraper) Report(socketFile string, vmi *k6tv1.VirtualMachineInstance, vmDomainStats *stats.DomainStats, vmFSStats k6tv1.VirtualMachineInstanceFileSystemList) { |
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.
@machadovilaca I think it could be better if you will create a type vmStats struct
and you will be able to encapsulate the vmDomainStats
and vmFSStats
there
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.
👍 great idea.
This way even the vmStats
name can stay, only the type would change.
In the long term, it would keep our function signatures small, therefore more readable and easily changable.
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 like it, changed
@@ -69,7 +73,7 @@ var _ = Describe("Prometheus", func() { | |||
|
|||
ps := prometheusScraper{ch: ch} | |||
|
|||
vmStats := &stats.DomainStats{ | |||
vmDomainStats := &stats.DomainStats{ |
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.
@machadovilaca same here about a dedicated commit for refactoring
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.
Does this still make sense after https://github.com/kubevirt/kubevirt/pull/7814/files#r923806175 ?
@@ -99,7 +103,7 @@ var _ = Describe("Prometheus", func() { | |||
}, | |||
} | |||
vmi := k6tv1.VirtualMachineInstance{} | |||
ps.Report("test", &vmi, vmStats) | |||
ps.Report("test", &vmi, vmStats, emptyVmFSStats) |
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.
@machadovilaca Here you've left the vmStats
although you've refactored its name in previous places
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.
changed when using the suggested struct
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.
Thanks @machadovilaca! Good work!
fsLabels := []string{"disk"} | ||
|
||
for _, fsStat := range vmFSStats.Items { |
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: Maybe return if len(vmFSStats.Items) == 0
? This would prevent allocating fsLabels := []string{"disk"}
for these scenarios.
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.
added
for _, fsStat := range vmFSStats.Items { | ||
fsLabelValues := []string{fsStat.DiskName} | ||
|
||
metrics.pushCustomMetric( |
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'm wondering - why not publish all data we have? e.g. MountPoint
and FileSystemType
? Maybe as labels?
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 it is what @enp0s3 suggested in https://github.com/kubevirt/kubevirt/pull/7814/files#r923548381
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.
Sorry but this link just leads me to "Files" tab :)
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.
Oh you meant #7814 (comment). Got it. Thanks
var emptyVmFSStats = k6tv1.VirtualMachineInstanceFileSystemList{ | ||
Items: []k6tv1.VirtualMachineInstanceFileSystem{}, | ||
} | ||
|
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.
Having global mutabale variables for tests is a bad practice. I think you should choose one of the two options:
- Declare the variable globally but initialize it in a
BeforeEach
clause - Replace the variable with a function that returns an empty VMFSStats
Option 2 is safer and better imho, it isolates tests from one another and more readable
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, this relates to @enp0s3's suggestion about vmStats
struct. If this was the call, all you would need to change here is to initialize another field in the struct.
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.
updated
Expect(result.Desc().String()).To(ContainSubstring("kubevirt_vmi_filesystem_total_bytes")) | ||
result = <-ch | ||
Expect(result).ToNot(BeNil()) | ||
Expect(result.Desc().String()).To(ContainSubstring("kubevirt_vmi_filesystem_used_bytes")) |
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.
Maybe expect the channel to be empty here?
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.
added
30844a0
to
c23fb96
Compare
/test pull-kubevirt-e2e-k8s-1.22-sig-compute |
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.
Thanks @machadovilaca! Great work!
/lgtm
left small nit
@@ -543,6 +573,11 @@ type prometheusScraper struct { | |||
ch chan<- prometheus.Metric | |||
} | |||
|
|||
type VirtualMachineStats struct { |
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: Maybe VirtualMachineInstanceStats
is more accurate?
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.
updated
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.
thanks
Signed-off-by: João Vilaça <jvilaca@redhat.com>
Signed-off-by: João Vilaça <jvilaca@redhat.com>
Signed-off-by: João Vilaça <jvilaca@redhat.com>
c23fb96
to
5621389
Compare
/retest |
/test pull-kubevirt-e2e-kind-1.22-sriov |
1 similar comment
/test pull-kubevirt-e2e-kind-1.22-sriov |
/test pull-kubevirt-e2e-kind-1.22-sriov |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: stu-gott 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 |
/retest |
1 similar comment
/retest |
@machadovilaca: The following test failed, say
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 kubernetes/test-infra repository. I understand the commands that are listed here. |
/test pull-kubevirt-e2e-k8s-1.22-operator |
/test pull-kubevirt-unit-test |
/cherry-pick release-0.53 |
@machadovilaca: new pull request created: #8621 In response to this:
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 kubernetes/test-infra repository. |
Currently, in the dashboard, under Virtualization -> Overview, the filesystem
report uses a metric about the pod filesystem usage. This PR adds new metrics
with values corresponding to VM filesystem usage so they can be used in the
dashboard.
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Release note: