5.4. validate-all action

The validate-all action tests for correct resource agent configuration and a working environment. validate-all should exit with one of the following return codes:

validate-all is usually wrapped in a function that is not only called when explicitly invoking the corresponding action, but also — as a sanity check — from just about any other function. Therefore, the resource agent author must keep in mind that the function may be invoked during the start, stop, and monitor operations, and also during probes.

Probes pose a separate challenge for validation. During a probe (when the cluster manager may expect the resource not to be running on the node where the probe is executed), some required components may be expected to not be available on the affected node. For example, this includes any shared data on storage devices not available for reading during the probe. The validate-all function may thus need to treat probes specially, using the ocf_is_probe convenience function:

foobar_validate_all() {
    # Test for configuration errors first
    if ! ocf_is_decimal $OCF_RESKEY_eggs; then
       ocf_log err "eggs is not numeric!"

    # Test for required binaries
    check_binary frobnicate

    # Check for data directory (this may be on shared storage, so
    # disable this test during probes)
    if ! ocf_is_probe; then
       if ! [ -d $OCF_RESKEY_datadir ]; then
          ocf_log err "$OCF_RESKEY_datadir does not exist or is not a directory!"
          exit $OCF_ERR_INSTALLED

    return $OCF_SUCCESS