Bug 2123586

Summary: vGPU wasn't deleted automatically when deleting the instance that allocated vGPU
Product: Red Hat OpenStack Reporter: Chorong Park <chopark>
Component: openstack-novaAssignee: OSP DFG:Compute <osp-dfg-compute>
Status: CLOSED NOTABUG QA Contact: OSP DFG:Compute <osp-dfg-compute>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 16.2 (Train)CC: dasmith, eglynn, jhakimra, jinjlee, kchamart, rcernin, sbauza, sgordon, smooney, vromanso
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-10-19 10:20:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2109450    
Bug Blocks:    

Description Chorong Park 2022-09-02 02:55:45 UTC
Description of problem:

this issue is remained the mediated device (mdev) after deleting the instance that allocated vGPU 
According to them, mdev is remained when checking the CLI `mdevctl list` after shelving the instance but it is deallocated when checking the CLI `nvidia-smi vgpu`

I'm very wondering that why mdev is remained after deleting/shelving the instance that allocated vGPU 
Do we need to manually delete mdev if deleting/shelving the instance that allocated vGPU?

They do delete the instance using the CLI `nova force-delete`  to immediately delete the instance because they are using soft-delete due to their company policy

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
vGPU was't deleted automatically when deleting the instance that allocated vGPU

Expected results:
vGPU is deleted automatically when deleting the instance that allocated vGPU

Additional info:

Comment 3 Sylvain Bauza 2022-09-05 09:08:39 UTC
(In reply to Chorong Park from comment #0)

> Expected results:
> vGPU is deleted automatically when deleting the instance that allocated vGPU


No, FWIW, this isn't an expected result.
When creating an instance, Nova verifies whether there are mdevs that are not used by other instances, and if so, uses one of them for the new instance [1]
If there are no existing created mdevs that are not used by some guests, then Nova will directly ask sysfs to create one mdev [2]

When deleting an instance, then we just remove the guest so the mdev that was created is no longer used.


[1] https://github.com/openstack/nova/blob/58be0ca8b8204bce6cbb6747d46ca595c5843a30/nova/virt/libvirt/driver.py#L8449-L8455
[2] https://github.com/openstack/nova/blob/58be0ca8b8204bce6cbb6747d46ca595c5843a30/nova/virt/libvirt/driver.py#L8343-L8372 and https://github.com/openstack/nova/blob/58be0ca8b8204bce6cbb6747d46ca595c5843a30/nova/privsep/libvirt.py#L195-L203