ClusterLabs/pacemaker — pull request #71 by davidvossel (2012-04-20 16:39:41+00:00)
Title: Medium: pengine: cl#5054 - Ensure demote occurs before stop of multistate resource in Master role. Medium: pengine: cl#5054 - Ensure demote occurs before stop of multistate resource in Master role.

When a native resource's parent is a multistate resource, an order
constraint is set in place to ensure the demote action
of the resource will always occur before the stop action.
This will guarantee that the demote action will always be performed
in the correct order, but it does not guarantee that the demote
action will be performed. If the demote action is never set to required
it is possible that the stop action will occur without the demote action
entirely.

Right now the demote action will be set to required when we know
the next role of the multistate resource is transitioning from
(Master ---> Slave), or (Master ---> Stopped). Just because
the next role of the multistate resource does not change, that
does not mean however that the resource will not end up being stopped
by an order constraint later on. When the multistate resource is stopped
as a result of a order constraint, it is possible that even though the
demote is supposed to happen before the stop action, the demote action
will not be set to required and the resource will transition directly
from Master to Stopped without the demote.

To resolve this, a new order constraint flag has been introduced that
forces the 'first' action to be required when the 'then' action is,
but only when the 'then' action's resource is the Master role. This
flag is used with the order constraint (demote then stop) to guarantee
that the demote not only occurs in the correct order, but is required
when the Master resource is executing the stop action.