Bug 1114622

Summary: RICCI XMLRPC: overload stop_service so that it can fulfill its nominal promise
Product: Red Hat Enterprise Linux 6 Reporter: Jan Pokorný [poki] <jpokorny>
Component: clustermonAssignee: Jan Pokorný [poki] <jpokorny>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.6CC: cfeist, cluster-maint, jpokorny, rsteiger, sbradley
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: clustermon-0.16.2-31.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1111249 Environment:
Last Closed: 2015-07-22 07:40:04 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:    
Bug Blocks: 1075802, 1111249, 1159926    

Description Jan Pokorný [poki] 2014-06-30 13:58:15 UTC
Currently, "stop_service" method of ricci/XMLRPC API is partly a misnomer,
in a sense, defeating the clarity towards the API users: in fact it
disables the service (as in clusvcadm -d, permanent stop) whereas stopping
(as in clusvcadm -s, temporary stop) might be expected.

Because of its longevity, the API call has to stay backwards compatible,
meaning that best way to allow for both permanent and temporary stop is
probably this:

1. keep stop_service, without any additional parameter/flag it refers to 
   permanent stop (backward compatibility)

2. introduce new parameter/toggle flag to stop_service method, say "soft",
   that defaults to "false" (leading to scenario of item 1.), but will
   change the behavior to use "clusvcadm -s" under the hood
   (instead of "-d") if set to "true"

This would, in turn, provide ability to temporarily stop service to
clients of ricci: luci/[bug 1111249], ccs/[bug to be filed]


Digest of the original bug:

+++ This bug was initially created as a clone of Bug #1111249 +++

Not having a "stop" button is a problem with clustered services that have
dependencies because dependencies will not start or stop child resources if
they are in disabled state.

--- Additional comment from Shane Bradley on 2014-06-30 15:31:54 CEST ---

Just expecting to be able to stop services like the following:
# clusvcadm -s service1

Comment 4 Jan Pokorný [poki] 2015-03-05 14:49:11 UTC
Oops, due to counter-intuitive source base split between two SRPMs,
this was misfiled under ricci component instead of clustermon.

Comment 8 Jan Pokorný [poki] 2015-03-09 15:49:44 UTC
Documentation note
------------------
This bug does not require a doc text -- it is a preparation work
at the back-end to enable the clients/front-end (luci, ccs) to expose
this new management tasks towards the users.


Development note
----------------

The API to be called was slightly extended as per [comment 0],
except for "new parameter/toggle flag" name, which is eventually
"temporary".  When one wants to check this API extension is actually
supported, per-module-API version 1.1 (or anything below 2.0) should
be exercised first, success of which will indicate proper support
of this feature at the back-end (and only then it is safe to work
with this expectation!).  Suggested pseudo-algorithm is hence:

1. try 1.1 <= API version < 2.0 (depending on other newly added features)
2a. SUCCESS -> all OK, handle the response
               (possibly remembering the feature support within
                a short-lived session)
2b. FAILURE -> inform user to update clustermon on the target node

Comment 12 Jan Pokorný [poki] 2015-04-21 15:01:19 UTC
OK, let's have a look at rgmanager's code to see what relevant bits we
can learn from so as not to be too restrictive on the modcluster side
about what service states and requests can combine well.

Unfinished "reverse engineering" of what is the outcome for particular
REQUEST + STATE combination ("what is OK and what is not"):

REQUEST\ STATE| S | S | S | S | F | U | C | E | R | D | M |
       |      | T | T | T | T | A | N | H | R | E | I | I |
       |      | O | A | A | O | I | I | E | R | C | S | G |
        \     | P | R | R | P | L | N | C | O | O | A | R |
         |    | P | T | T | P | E | I | K | R | V | B | A |
         |    | E | I | E | I | D | T |   |   | E | L | T |
          \   | D | N | D | N |   | I |   |   | R | E | E |
           |  |   | G |   | G |   | A |   |   |   | D |   |
           |  |   |   |   |   |   | L |   |   |   |   |   |
            \ |   |   |   |   |   | E |   |   |   |   |   |
             \|   |   |   |   |   | D |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
SUCCESS       |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
FAIL          |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
START         |C-1|C-1|C-1|C-1|F-0|F-0|C-1|C-1|O-2|F-0|O-4|<-advise_start
--------------+---+---+---+---+---+---+---+---+---+---+---+
STOP          |O-2|C-1|C-1|C-1|F-0|O-2|C-1|F-0|C-1|O-2|C-1|<-advise_stop
--------------+---+---+---+---+---+---+---+---+---+---+---+
STATUS        |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
DISABLE       |O-1|C-1|C-1|C-1|O-1|O-1|C-1|O-1|C-1|O-1|C-1|<-advise_stop
--------------+---+---+---+---+---+---+---+---+---+---+---+
STOP_RECOVER  |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
START_RECOVER |C-1|C-1|C-1|C-1|F-0|O-1|C-1|C-1|O-1|O-1|O-4|<-advise_start
--------------+---+---+---+---+---+---+---+---+---+---+---+
RESTART       |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
EXITING       |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
INIT          |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
ENABLE        |C-1|C-1|C-1|C-1|F-0|C-1|C-1|C-1|O-2|C-1|O-4|<-advise_start
--------------+---+---+---+---+---+---+---+---+---+---+---+
STATUS_NODE   |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
RELOCATE      |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
CONDSTOP      |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
CONDSTART     |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
START_REMOTE  |C-1|C-1|C-1|C-1|F-0|C-1|C-1|C-1|O-2|C-1|O-4|<-advise_start
--------------+---+---+---+---+---+---+---+---+---+---+---+
STOP_USER     |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
STOP_EXITING  |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
LOCK          |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
UNLOCK        |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
QUERY_LOCK    |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
MIGRATE       |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
FREEZE        |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
UNFREEZE      |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
STATUS_INQUIRY|   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
CONVALESCE    |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+
NONE          |   |   |   |   |   |   |   |   |   |   |   |
--------------+---+---+---+---+---+---+---+---+---+---+---+

encoding: X-Y

where X: O ~ OK
         C - conditionals (it depends)
         F - failure

and Y is a return value from svc_advise_{start,stop}:

advise_start 0 = DO NOT start service, return RG_EFAIL
             1 = START service - return whatever it returns.
             2 = DO NOT start service, return 0
             3 = DO NOT start service, return RG_EAGAIN
             4 = DO NOT start service, return RG_ERUN
             5 = DO NOT start service, return RG_EFROZEN

advise_stop  0 = DO NOT stop service, return RG_EFAIL
             1 = STOP service - return whatever it returns.
             2 = DO NOT stop service, return 0 (success)
             3 = DO NOT stop service, return RG_EFORWARD
             4 = DO NOT stop service, return RG_EAGAIN
             5 = DO NOT stop service, return RG_EFROZEN
             6 = DO NOT stop service, mark stopped and return
                 RG_SUCCESS (0)


relevant files (under rgmanager/src/daemons):
resgroup.h
rg_state.c
(rg_thread.c)

control flow wrt. advise_service_start:
== handle_fd_start_req ==>
   ==> handle_start_remote_req ==\
                                  => svc_start -> advise_service_start
====== handle_start_req        ==/

Comment 17 errata-xmlrpc 2015-07-22 07:40:04 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://rhn.redhat.com/errata/RHBA-2015-1413.html