-
Notifications
You must be signed in to change notification settings - Fork 30
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
Restart a Virtual Machine #263
base: master
Are you sure you want to change the base?
Conversation
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 so much @Dhamo1107 !
ext_management_system.with_provider_connection(:namespace => location) do |connection| | ||
# Retrieve the details of the virtual machine: | ||
vm = connection.vm(name) | ||
vm.restart |
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 need to see if vm.restart
do a "soft" reboot via the guest or a restart via the virtualized hardware. That would dictate if we call this reboot_guest or reset
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.
Based on the API docs it looks like VirtualMachine#restart
is a hardware reset and VirtualMachineInstance#softreboot
is what we would call a reboot_guest
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 this method is good if you rename it def reset
and then if we add a reboot_guest which uses vmi = connection.vm_instance(name)
then you can vmi.softreboot
on that object
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.
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 you may need to implement raw_reboot_guest
and raw_reset
in something like module ManageIQ::Providers::Kubevirt::InfraManager::Vm::Operations::Guest
https://github.com/ManageIQ/manageiq/blob/master/app/models/vm/operations/guest.rb
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 forgot that with_provider_connection
is still using fog-kubevirt since @nasark's most recent work here was using kubeclient. I don't see restart or softreboot in fog-kubevirt so we might have an issue there.
Given that we want to move towards kubeclient in the near future as a replacement for fog-kubevirt I think we'd be better off going in that direction rather than adding restart/soft_reboot to fog-kubevirt.
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 @agrare, As suggested I’ve connected to the VM using the following code:
kubevirt = ext_management_system.parent_manager.connect(:service => "kubernetes", :path => "/apis/subresources.kubevirt.io", :version => "v1")
However, I’m not sure which method should be called on this kubevirt instance to perform the restart and reset operation (like kubevirt.create_virtual_machine_snapshot
). I assume a similar operation should be implemented here using kubeclient. Can you please advise on the correct method I should use for this 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.
Yeah so it looks like kubeclient doesn't pick up on the methods like reset and softreboot because the kubevirt.io API operations don't match the rest of the k8s apis.
I was able to restart and softreboot vms with:
kubevirt = ext_management_system.parent_manager.connect(:service => "kubernetes", :path => "/apis/subresources.kubevirt.io", :version => "v1")
kubevirt.rest_client['namespaces/manageiq/virtualmachines/fedora-jade-owl-56/restart'].put({}.to_json, { 'Content-Type' => 'application/json' }.merge(client.get_headers))
kubevirt.rest_client['namespaces/manageiq/virtualmachineinstances/fedora-jade-owl-56/softreboot'].put({}.to_json, { 'Content-Type' => 'application/json' }.merge(client.get_headers))
Co-authored-by: Adam Grare <[email protected]>
Create snapshot for a Virtual Machine
Hey @Dhamo1107 FYI it looks like you have a merge commit in here, in our recommended git config https://www.manageiq.org/docs/guides/developer_setup/git_workflow we recommend |
Hi @agrare, Got it, thanks for the input, I’ll update it as recommended |
I tested these changes and the reboot works perfectly, I saw a 500 error with soft_restart (I also hit this using kubeclient directly so it isn't anything in your PR that is causing it)
The VM does restart, it happens too quickly to see if the guest came down cleanly. Possibly an issue with communicating with the guest tools? Not sure... |
# Conflicts: # app/models/manageiq/providers/kubevirt/infra_manager/vm.rb # app/models/manageiq/providers/kubevirt/infra_manager/vm/operations.rb
This PR introduces the "Restart VM" feature for VMs managed by the KubeVirt infrastructure provider in ManageIQ.
Testing:
Verified the restart functionality for KubeVirt VMs via the UI.
Before: "Restart Guest" option is disabled for KubeVirt VMs.
After: "Restart Guest" button available and functional for KubeVirt VMs.
@Fryguy Kindly take a look at this and review the PR. Thank you!