This site is a work in progress — you can help! Please see the Site news for details.

LSB Resource Agents

From Linux-HA

Jump to: navigation, search

Background

LSB Resource Agents are those found in /etc/init.d. Generally they are provided by the OS/distribution and in order to be used with Heartbeat or Pacemaker resource management, must conform to the LSB Spec.

The LSB Spec (as it relates to init scripts) can be found at: http://refspecs.linux-foundation.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

Many distributions claim LSB compliance but ship with broken init scripts. The most common problems are:

  • Not implementing the status operation at all
  • Not observing the correct exit status codes for start/stop/status actions
  • Starting a started resource returns an error (this violates the LSB spec)
  • Stopping a stopped resource returns an error (this violates the LSB spec)
    This may also result in "ERROR: reboot narrowly avoided" messages by heartbeat, or, if the status operation is poorly implemented as well, in actual reboots, to "recover" from "stop failure".

NOTE: Parameters and options can not be passed to LSB Resource Agents.

Init Script (LSB) Compatibility Checks

Assuming some_service is configured correctly and currently not active, the following sequence will help you determine if it is LSB compatible:

  1. Start (stopped)
    /etc/init.d/some_service start ; echo "result: $?"
    • Did the service start?
    • Did the command print result: 0 (in addition to the regular output)?
  2. Status (running)
    /etc/init.d/some_service status ; echo "result: $?"
    • Did the script accept the command?
    • Did the script indicate the service was running?
    • Did the command print result: 0 (in addition to the regular output)?
  3. Start (running)
    /etc/init.d/some_service start ; echo "result: $?"
    • Is the service still running?
    • Did the command print result: 0 (in addition to the regular output)?
  4. Stop (running)
    /etc/init.d/some_service stop ; echo "result: $?"
    • Was the service stopped?
    • Did the command print result: 0 (in addition to the regular output)?
  5. Status (stopped)
    /etc/init.d/some_service status ; echo "result: $?"
    • Did the script accept the command?
    • Did the script indicate the service was not running?
    • Did the command print result: 3 (in addition to the regular output)?
  6. Stop (stopped)
    /etc/init.d/some_service stop ; echo "result: $?"
    • Is the service still stopped?
    • Did the command print result: 0 (in addition to the regular output)?
  7. Status (failed)
    This step is not readily testable and relies on manual inspection of the script.
    The script can optionally use one of the other codes (other than 3) listed in the LSB spec to indicate that it is active but failed.
    In such a case, this tells the cluster that, before moving the resource to another node, it should stop it on the existing one first.
    Making use of these extra exit codes is encouraged.

If the answer to any of the above questions is no, then the init script is not LSB compliant.

If you are using Pacemaker resource management, then your options at this point are to:

If you are still using the haresources mode of Heartbeat, then the script may still work as long as it follows the rules for Heartbeat Resource Agents.

See Also

Resource Agents

Personal tools