-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Expose serial number and bus type via GuestOsInfo #10970
Conversation
This commit updates the guestOsInfo command to show additional disk info, like serial number and bus type. Signed-off-by: Alvaro Romero <alromero@redhat.com>
Skipping CI for Draft Pull Request. |
Signed-off-by: Alvaro Romero <alromero@redhat.com>
/test pull-kubevirt-e2e-k8s-1.28-sig-compute-migrations |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mhenriks 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 |
/lgtm |
Required labels detected, running phase 2 presubmits: |
/hold @mhenriks @alromeros Sorry perhaps I am missing something, since you've added a non-primitive type to the api, don't you miss the piece of code that should prepare the slice as part of the parsing process? |
@@ -196,6 +197,7 @@ func parseFilesystem(agentReply string) ([]api.Filesystem, error) { | |||
Type: fs.Type, | |||
TotalBytes: fs.TotalBytes, | |||
UsedBytes: fs.UsedBytes, | |||
Disk: fs.Disk, |
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.
Is it safe to just assign it like that w/o iterating and running append
to the list you create with a make
?
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.
Yeah I think it's safe to just assign slices
Hey @enp0s3, isn't that automatically handled by the generate scripts? What is exactly missing in this one? |
@alromeros I took GetUsers() as a reference. The code iterates over the data it got from Should you have a function |
@alromeros I think I am confused because of the definition |
Right, I get what you mean. Following your example, We have something similar in GetFilesystems (the command I'm updating). We fetch the whole guest agent response here. Since the new field I added ( Maybe I'm missing something, but I don't see any good reasons for this intermediary step when we can just adjust the type ( |
Right, I'm just mirroring the guest agent's response (an array of |
/unhold @alromeros Thank you for the explanation! So the |
/retest-required |
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.
@enp0s3 this PR doesn't add a new test nor does it extend the existing functional test.
@@ -2215,13 +2215,20 @@ type VirtualMachineInstanceFileSystemList struct { | |||
Items []VirtualMachineInstanceFileSystem `json:"items"` | |||
} | |||
|
|||
// VirtualMachineInstanceFileSystemDisk represents the guest os FS disks | |||
type VirtualMachineInstanceFileSystemDisk struct { | |||
Serial string `json:"serial"` |
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.
Missing omitempty
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.
@alromeros is this ever expected to be empty? I would be pretty surprised
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 BusType will never be empty, but Serial is optional: https://qemu-project.gitlab.io/qemu/interop/qemu-ga-ref.html#qapidoc-146.
// VirtualMachineInstanceFileSystemDisk represents the guest os FS disks | ||
type VirtualMachineInstanceFileSystemDisk struct { | ||
Serial string `json:"serial"` | ||
BusType string `json:"bus-type"` |
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 does break convention, it should be json:"busType"
.
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.
@xpivarc Thanks for the heads up! this check must be automated somehow, it is something hard to remember for the long term.
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 can make the make generate
fail
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.
make generate
failed but I added an exception to allow this formatting so we don't need an intermediary type:
API rule violation: names_match,kubevirt.io/api/core/v1,VirtualMachineInstanceFileSystemDisk,BusType
I will fix it to avoid breaking the convention.
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 assumed we wanted to expose with exact naming naming scheme as libvirt
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.
Yeah me too. It prevents adding some unnecessary code, but I guess it's odd to only add the exception to BusType.
FileSystemType string `json:"fileSystemType"` | ||
UsedBytes int `json:"usedBytes"` | ||
TotalBytes int `json:"totalBytes"` | ||
Disk []VirtualMachineInstanceFileSystemDisk `json:"disk,omitempty"` |
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 is this a slice?
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 got the explanation 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.
That doesn't explain the question, @alromeros can you 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.
We are storing here the guest agent response to the guest-get-fsinfo
command. The command returns an array of disks, so I'm using one: https://qemu-project.gitlab.io/qemu/interop/qemu-ga-ref.html#qapidoc-161.
@enp0s3 |
@xpivarc +1 |
Didn't see individual checks for most of the fields in fsList but I can add them in a follow-up. Will open it later once we decide if the API is good. |
Follow-up #10970: Minor API fixes to get fsList disks
…ase-1.2 [release-1.2] Follow-up #10970: Minor API fixes to get fsList disks
What this PR does / why we need it:
This PR updates the guestOsInfo command to show additional disk info, like serial number and bus type.
Example:
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 # https://issues.redhat.com/browse/CNV-18671
Special notes for your reviewer:
Added the api exceptions so we can fetch the guest-agent information without unnecessary structs as intermediaries (json names need to match). The api additions are in that way (Disk being an array, for example) to match the guest-agent response.
Release note: