Bug 1416903

Summary: power operations using REST API on parent service has no effect
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Drew Bomhof <dbomhof>
Status: CLOSED ERRATA QA Contact: Martin Kourim <mkourim>
Severity: medium Docs Contact:
Priority: high    
Version: 5.7.0CC: dajohnso, gmccullo, jhardy, mkourim, obarenbo, simaishi
Target Milestone: GA   
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: api:rest:power
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-01 13:09:24 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:

Description Martin Kourim 2017-01-26 18:26:06 UTC
Description of problem:
Service with vm has parent service defined ("ancestry": "<parent_id>").
When running power operation on parent service using REST API, it has no effect.
When running power operation on child service using REST API, it works.

Power actions on a service should be processed from the service it is initiated and child services, i.e. calling the action on the top-level service should work.

The top-level (parent) service is minimal service with just name and description.


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


How reproducible:
100%


Steps to Reproduce:
1. create child service with vm
2. create minimal service, e.g.
POST /api/services
{
    "name" : "test_service_parent",
    "description" : "Test Service parent"
}
3. edit child vm to add ancestor:
POST /api/services/:child_id
{
    "action": "edit",
    "ancestry" : "<parent_id>"
}
4. run power operation on parent service:
POST /api/services/:parent_id
{
    "action": "stop"
}


Actual results:
No effect on the vm associated with child service.

Following is set in parent service:
"options": {"power_status": "stopping"}



Expected results:
The vm associated with child service is stopped.

Comment 2 Greg McCullough 2017-02-02 20:13:16 UTC
Martin - Please retest with the fix from https://github.com/ManageIQ/manageiq/pull/13232 which was created for Bug 1394202.  This change resolves a few issues and should correct this scenario.

Comment 3 Martin Kourim 2017-03-01 13:13:23 UTC
Tested on 5.8.0.2 and the described issue is still there.

Comment 4 Drew Bomhof 2017-03-21 13:21:26 UTC
Martin,

I was able to duplicate the problem yesterday (3/20/2017.) I'm working on a PR to resolve it.

Comment 5 Drew Bomhof 2017-03-28 20:49:07 UTC
PR: https://github.com/ManageIQ/manageiq/pull/14550

Comment 6 Drew Bomhof 2017-04-03 20:40:17 UTC
PR: https://github.com/ManageIQ/manageiq/pull/14550 - Refactored how atomic? and composite? services are clarified - now they are clarified (from the services level) simply as child_resources? and empty_child_resources?

Comment 7 CFME Bot 2017-04-18 20:16:47 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/ec58361e4c0940d4dac70094fe3c00452d681f54

commit ec58361e4c0940d4dac70094fe3c00452d681f54
Author:     Drew Bomhof <dbomhof>
AuthorDate: Mon Apr 3 16:11:52 2017 -0400
Commit:     Drew Bomhof <dbomhof>
CommitDate: Tue Apr 18 14:48:55 2017 -0400

    Adjust power states to handle children
    
    1. Iterate through the children if there are no service_resources on the parent
    2. Iterate through the children for power states to adjust the power state and status for
    the entire service
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1416903

 app/models/mixins/service_mixin.rb |  6 +++++-
 app/models/service.rb              | 28 +++++++++++++++++-----------
 2 files changed, 22 insertions(+), 12 deletions(-)

Comment 8 CFME Bot 2017-04-18 20:16:52 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/3daf3fe27f08a15605721eeb249c60a85793dc1e

commit 3daf3fe27f08a15605721eeb249c60a85793dc1e
Author:     Drew Bomhof <dbomhof>
AuthorDate: Mon Apr 3 16:12:25 2017 -0400
Commit:     Drew Bomhof <dbomhof>
CommitDate: Tue Apr 18 14:48:55 2017 -0400

    Add specs around the the all_states_match? method
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1416903

 spec/models/service_spec.rb | 76 ++++++++++++++++++++++++++++++++++-----------
 1 file changed, 58 insertions(+), 18 deletions(-)

Comment 9 CFME Bot 2017-04-18 20:16:57 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/a52d65d8895fe942750b15caaab80f4024889024

commit a52d65d8895fe942750b15caaab80f4024889024
Author:     Drew Bomhof <dbomhof>
AuthorDate: Wed Apr 5 11:42:03 2017 -0400
Commit:     Drew Bomhof <dbomhof>
CommitDate: Tue Apr 18 14:48:55 2017 -0400

    Re use the composite? and atomic? method names
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1416903

 app/models/service.rb       |  8 +++----
 spec/models/service_spec.rb | 55 +++++++++++++++++++++------------------------
 2 files changed, 30 insertions(+), 33 deletions(-)

Comment 10 CFME Bot 2017-04-18 20:17:03 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/f2a06a87a849786153fa0589b18b4c546e793a4a

commit f2a06a87a849786153fa0589b18b4c546e793a4a
Author:     Drew Bomhof <dbomhof>
AuthorDate: Tue Apr 18 15:47:50 2017 -0400
Commit:     Drew Bomhof <dbomhof>
CommitDate: Tue Apr 18 15:47:50 2017 -0400

    Extract service actions list into a method
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1416903

 app/models/service.rb       | 14 ++++++++------
 spec/models/service_spec.rb |  2 ++
 2 files changed, 10 insertions(+), 6 deletions(-)

Comment 11 Martin Kourim 2017-10-20 09:07:56 UTC
Verified using CFME QE test automation on 5.9.0.2

Comment 14 errata-xmlrpc 2018-03-01 13:09:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0380