Skip to content

Commit

Permalink
pgsql: dont run promotable and file checks that could be on shared st…
Browse files Browse the repository at this point in the history
…orage during validate-all action
  • Loading branch information
oalbrigt committed Jan 25, 2023
1 parent 81f9e1a commit 8ee41af
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions heartbeat/pgsql
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,7 @@ check_config() {

if [ ! -f "$1" ]; then
if ocf_is_probe; then
ocf_log info "Configuration file is $1 not readable during probe."
ocf_log info "Unable to read $1 during probe."
rc=1
else
ocf_exit_reason "Configuration file $1 doesn't exist"
Expand All @@ -1846,8 +1846,7 @@ check_config() {
return $rc
}

# Validate most critical parameters
pgsql_validate_all() {
validate_ocf_check_level_10() {
local version
local check_config_rc
local rep_mode_string
Expand Down Expand Up @@ -1883,12 +1882,6 @@ pgsql_validate_all() {
fi
fi

getent passwd $OCF_RESKEY_pgdba >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
ocf_exit_reason "User $OCF_RESKEY_pgdba doesn't exist";
return $OCF_ERR_INSTALLED;
fi

if ocf_is_probe; then
ocf_log info "Don't check $OCF_RESKEY_pgdata during probe"
else
Expand All @@ -1898,18 +1891,6 @@ pgsql_validate_all() {
fi
fi

if [ -n "$OCF_RESKEY_monitor_user" -a ! -n "$OCF_RESKEY_monitor_password" ]
then
ocf_exit_reason "monitor password can't be empty"
return $OCF_ERR_CONFIGURED
fi

if [ ! -n "$OCF_RESKEY_monitor_user" -a -n "$OCF_RESKEY_monitor_password" ]
then
ocf_exit_reason "monitor_user has to be set if monitor_password is set"
return $OCF_ERR_CONFIGURED
fi

if is_replication || [ "$OCF_RESKEY_rep_mode" = "slave" ]; then
if [ `printf "$version\n9.1" | sort -n | head -1` != "9.1" ]; then
ocf_exit_reason "Replication mode needs PostgreSQL 9.1 or higher."
Expand Down Expand Up @@ -2027,6 +2008,35 @@ pgsql_validate_all() {
return $OCF_SUCCESS
}

# Validate most critical parameters
pgsql_validate_all() {
local rc

getent passwd $OCF_RESKEY_pgdba >/dev/null 2>&1
if [ ! $? -eq 0 ]; then
ocf_exit_reason "User $OCF_RESKEY_pgdba doesn't exist";
return $OCF_ERR_INSTALLED;
fi

if [ -n "$OCF_RESKEY_monitor_user" ] && [ -z "$OCF_RESKEY_monitor_password" ]; then
ocf_exit_reason "monitor password can't be empty"
return $OCF_ERR_CONFIGURED
fi

if [ -z "$OCF_RESKEY_monitor_user" ] && [ -n "$OCF_RESKEY_monitor_password" ]; then
ocf_exit_reason "monitor_user has to be set if monitor_password is set"
return $OCF_ERR_CONFIGURED
fi

if [ "$OCF_CHECK_LEVEL" -eq 10 ]; then
validate_ocf_check_level_10
rc=$?
[ $rc -ne "$OCF_SUCCESS" ] && exit $rc
fi

return $OCF_SUCCESS
}


#
# Check if we need to create a log file
Expand Down Expand Up @@ -2163,6 +2173,7 @@ case "$1" in
exit $OCF_SUCCESS;;
esac

[ "$__OCF_ACTION" != "validate-all" ] && OCF_CHECK_LEVEL=10
pgsql_validate_all
rc=$?

Expand Down

0 comments on commit 8ee41af

Please sign in to comment.