Bug 1419520

Summary: Detaching all vms from a pool via REST API doesn't remove the pool
Product: [oVirt] ovirt-engine Reporter: sefi litmanovich <slitmano>
Component: RestAPIAssignee: Shahar Havivi <shavivi>
Status: CLOSED CURRENTRELEASE QA Contact: sefi litmanovich <slitmano>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: bugs, shavivi, tjelinek
Target Milestone: ovirt-4.1.1Flags: rule-engine: ovirt-4.1+
rule-engine: exception+
rule-engine: planning_ack+
tjelinek: devel_ack+
mavital: testing_ack+
Target Release: 4.1.1.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-21 09:43:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1378331    

Description sefi litmanovich 2017-02-06 12:02:23 UTC
Description of problem:
When detaching all the vms from a vm pool via UI the pool itself is automatically deleted as well.
This behaviour doesn't occur when detaching the last vm in the pool via REST API, in this case the pool will remain empty in the system.

Version-Release number of selected component (if applicable):
rhevm-4.1.0.4-0.1.el7

How reproducible:
always

Steps to Reproduce:
1. Create a vm pool with any amount of vms.
2. Detach all the vms (or only the last remaining one) from the pool via REST API:

https://{engine_url}/ovirt-engine/api/vms/{vm_id}/detach

body:

<action>
    <async>false</async>
    <grace_period>
        <expiry>10</expiry>
    </grace_period>
</action>

Actual results:
Vms are detached from the pool, but the pool itself keep remaining in the system.

Expected results:
Vms are detached from the pool and the pool itself is removed from the system.

Additional info:

Comment 1 Tomas Jelinek 2017-02-07 09:57:43 UTC
It does not sound like it but there is a pretty hard requirement of having only pools which have at least one VM. If this requirement is not fulfilled, the frontends start to fall apart throwing various exceptions such as
https://bugzilla.redhat.com/1378331 and https://bugzilla.redhat.com/show_bug.cgi?id=1378331

and Im pretty sure one could find more.

Fixing this issue should be as easy as changing:
new RemoveVmFromPoolParameters(guid, false, true),
to
new RemoveVmFromPoolParameters(guid, true, true),

in BackendVmResource.detach() method so I think it is safe to backport it.

Comment 2 sefi litmanovich 2017-02-23 12:10:37 UTC
Hi, is this patch included in latest build? I was able to re produce on rhevm-4.1.1.2-0.1.el7.noarch. If not please move to modified.

Comment 3 Shahar Havivi 2017-02-23 12:46:12 UTC
according to the log it suppose to be in 4.1.1
lets check it on your setup

Comment 4 Shahar Havivi 2017-02-23 12:53:04 UTC
it didn't make it for 4.1.1.2

Comment 5 sefi litmanovich 2017-03-06 12:22:24 UTC
Verified with rhevm-4.1.1.3-0.1.el7