diff --git a/SOURCES/bz1640587-pgsql-ignore-masters-re-promote.patch b/SOURCES/bz1640587-pgsql-ignore-masters-re-promote.patch new file mode 100644 index 0000000..b371857 --- /dev/null +++ b/SOURCES/bz1640587-pgsql-ignore-masters-re-promote.patch @@ -0,0 +1,40 @@ +From 355cd29f2dee828bfe0a4ab64f425827aba7dd3b Mon Sep 17 00:00:00 2001 +From: Hideo Yamauchi +Date: Wed, 17 Oct 2018 09:54:37 +0900 +Subject: [PATCH] Mid: pgsql: Fix to ignore Master's re-promote. + +--- + heartbeat/pgsql | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/heartbeat/pgsql b/heartbeat/pgsql +index 380866da1..38f6ceeb7 100755 +--- a/heartbeat/pgsql ++++ b/heartbeat/pgsql +@@ -680,6 +680,7 @@ pgsql_start() { + + #pgsql_promote: Promote PostgreSQL + pgsql_promote() { ++ local output + local target + local rc + +@@ -687,6 +688,18 @@ pgsql_promote() { + ocf_exit_reason "Not in a replication mode." + return $OCF_ERR_CONFIGURED + fi ++ ++ output=`exec_sql "${CHECK_MS_SQL}"` ++ if [ $? -ne 0 ]; then ++ report_psql_error $rc $loglevel "Can't get PostgreSQL recovery status on promote." ++ return $OCF_ERR_GENERIC ++ fi ++ ++ if [ "$output" = "f" ]; then ++ ocf_log info "PostgreSQL is alredy Master. Don't execute promote." ++ return $OCF_SUCCESS ++ fi ++ + rm -f ${XLOG_NOTE_FILE}.* + + for target in $NODE_LIST; do diff --git a/SOURCES/bz1795535-pgsql-1-add-postgresql-12-support.patch b/SOURCES/bz1795535-pgsql-1-add-postgresql-12-support.patch new file mode 100644 index 0000000..3c05aba --- /dev/null +++ b/SOURCES/bz1795535-pgsql-1-add-postgresql-12-support.patch @@ -0,0 +1,105 @@ +From a43075be72683e1d4ddab700ec16d667164d359c Mon Sep 17 00:00:00 2001 +From: Kazutomo Nakahira +Date: Mon, 25 Nov 2019 17:40:33 +0900 +Subject: [PATCH 1/2] High: pgsql: Support for PostgreSQL 12 + +--- + heartbeat/pgsql | 32 +++++++++++++++++++++++++++++++- + 1 file changed, 31 insertions(+), 1 deletion(-) + +diff --git a/heartbeat/pgsql b/heartbeat/pgsql +index b1c070ead..5bc76cc4c 100755 +--- a/heartbeat/pgsql ++++ b/heartbeat/pgsql +@@ -1612,12 +1612,24 @@ make_recovery_conf() { + fi + + cat > $RECOVERY_CONF <> $RECOVERY_CONF <> $RECOVERY_CONF + ocf_log debug "Created recovery.conf. host=${OCF_RESKEY_master_ip}, user=${OCF_RESKEY_repuser}" + return 0 +@@ -1835,6 +1847,7 @@ pgsql_validate_all() { + local version + local check_config_rc + local rep_mode_string ++ local recovery_conf_string + local socket_directories + local rc + +@@ -1898,6 +1911,22 @@ pgsql_validate_all() { + ocf_exit_reason "Replication mode needs PostgreSQL 9.1 or higher." + return $OCF_ERR_INSTALLED + fi ++ ocf_version_cmp "$version" "12" ++ rc=$? ++ if [ $rc -eq 1 ]||[ $rc -eq 2 ]; then ++ # change the standby method for PosrgreSQL 12 or later. ++ USE_STANDBY_SIGNAL=true ++ # change the path to recovery.conf because it cause PostgreSQL start error. ++ RECOVERY_CONF=${OCF_RESKEY_tmpdir}/recovery.conf ++ if [ $check_config_rc -eq 0 ]; then ++ # adding recovery parameters to postgresql.conf. ++ recovery_conf_string="include '$RECOVERY_CONF' # added by pgsql RA" ++ if ! grep -q "^[[:space:]]*$recovery_conf_string" $OCF_RESKEY_config; then ++ ocf_log info "adding include directive $recovery_conf_string into $OCF_RESKEY_config" ++ echo "$recovery_conf_string" >> $OCF_RESKEY_config ++ fi ++ fi ++ fi + if [ ! -n "$OCF_RESKEY_master_ip" ]; then + ocf_exit_reason "master_ip can't be empty." + return $OCF_ERR_CONFIGURED +@@ -2107,6 +2136,7 @@ RESOURCE_NAME=`echo $OCF_RESOURCE_INSTANCE | cut -d ":" -f 1` + PGSQL_WAL_RECEIVER_STATUS_ATTR="${RESOURCE_NAME}-receiver-status" + RECOVERY_CONF=${OCF_RESKEY_pgdata}/recovery.conf + NODENAME=$(ocf_local_nodename | tr '[A-Z]' '[a-z]') ++USE_STANDBY_SIGNAL=false + + case "$1" in + methods) pgsql_methods + +From 5ab3339e8cb236583d375f5577f5a4dc129d5b27 Mon Sep 17 00:00:00 2001 +From: munenari +Date: Thu, 16 Jan 2020 09:27:59 +0900 +Subject: [PATCH 2/2] Remove standby.signal when promote with restart + +--- + heartbeat/pgsql | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/heartbeat/pgsql b/heartbeat/pgsql +index 5bc76cc4c..d5baa7b35 100755 +--- a/heartbeat/pgsql ++++ b/heartbeat/pgsql +@@ -720,7 +720,11 @@ pgsql_promote() { + ocf_log info "Restarting PostgreSQL instead of promote." + #stop : this function returns $OCF_SUCCESS only. + pgsql_real_stop slave +- rm -f $RECOVERY_CONF ++ if "${USE_STANDBY_SIGNAL}"; then ++ rm -f ${OCF_RESKEY_pgdata}/standby.signal ++ else ++ rm -f $RECOVERY_CONF ++ fi + pgsql_real_start + rc=$? + if [ $rc -ne $OCF_RUNNING_MASTER ]; then diff --git a/SOURCES/bz1795535-pgsql-2-fix-uppercase-hostname-support.patch b/SOURCES/bz1795535-pgsql-2-fix-uppercase-hostname-support.patch new file mode 100644 index 0000000..06c9aef --- /dev/null +++ b/SOURCES/bz1795535-pgsql-2-fix-uppercase-hostname-support.patch @@ -0,0 +1,48 @@ +From e56d0e1727bf84d0664db544a129a0237a1757c0 Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Fri, 11 Sep 2020 10:12:21 +0200 +Subject: [PATCH 1/2] pgsql: lower-case application_name to avoid issues with + upper-case hostnames + +--- + heartbeat/pgsql | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/heartbeat/pgsql b/heartbeat/pgsql +index 99e074287..de9f750c5 100755 +--- a/heartbeat/pgsql ++++ b/heartbeat/pgsql +@@ -1960,7 +1960,7 @@ pgsql_validate_all() { + else + CHECK_XLOG_LOC_SQL="select pg_last_xlog_replay_location(),pg_last_xlog_receive_location()" + fi +- CHECK_REPLICATION_STATE_SQL="select application_name,upper(state),upper(sync_state) from pg_stat_replication" ++ CHECK_REPLICATION_STATE_SQL="select lower(application_name),upper(state),upper(sync_state) from pg_stat_replication" + + PGSQL_STATUS_ATTR="${RESOURCE_NAME}-status" + PGSQL_DATA_STATUS_ATTR="${RESOURCE_NAME}-data-status" + +From 5aee799878180bb8daca82aebc2290c2735045eb Mon Sep 17 00:00:00 2001 +From: Oyvind Albrigtsen +Date: Fri, 11 Sep 2020 10:13:47 +0200 +Subject: [PATCH 2/2] pgsql: set exit-reason when failing due to remaining + PGSQL.lock + +--- + heartbeat/pgsql | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/heartbeat/pgsql b/heartbeat/pgsql +index de9f750c5..5a0628b7a 100755 +--- a/heartbeat/pgsql ++++ b/heartbeat/pgsql +@@ -966,6 +966,9 @@ pgsql_real_monitor() { + if ! pgsql_status + then + ocf_log info "PostgreSQL is down" ++ if [ "$__OCF_ACTION" = "monitor" ] && ! ocf_is_probe && [ -f $PGSQL_LOCK ]; then ++ ocf_exit_reason "My data may be inconsistent. You have to remove $PGSQL_LOCK file to force start." ++ fi + return $OCF_NOT_RUNNING + fi + diff --git a/SOURCES/bz1858752-Filesystem-support-whitespace-device-dir.patch b/SOURCES/bz1858752-Filesystem-support-whitespace-device-dir.patch new file mode 100644 index 0000000..15fb71f --- /dev/null +++ b/SOURCES/bz1858752-Filesystem-support-whitespace-device-dir.patch @@ -0,0 +1,566 @@ +From a8051cf9e21d231ce3c445f09631266157ffc2e0 Mon Sep 17 00:00:00 2001 +From: Reid wahl +Date: Fri, 10 Jul 2020 03:44:18 -0700 +Subject: [PATCH 1/3] Filesystem: Support whitespace in device or directory + name + +Whitespace in a device name (e.g., a CIFS share) or a directory name +breaks resource operations. + +One issue is that many of the variable occurrences aren't quoted, so a +string containing whitespace is split into multiple tokens. This is a +problem when the string meant to be passed as a single argument to a +function (e.g., `list_submounts()`). + +Another issue involves the parsing of `list_mounts()` output. +`list_mounts()` can pull data from `/proc/mounts`, `/etc/mtab`, or the +`mount` command. `/proc/mounts` and `/etc/mtab` represent spaces within +a field as octal `\040` strings, while `mount` represents them as +literal space characters. + +`list_mounts()` had to be modified to output the mount list as three +distinct fields ((`device`, `mountpoint`, `fstype`), separated by tab +characters) regardless of the data source. Parsers of `list_mounts()` +were modified to use tabs as field delimiters. + +The for loop in `Filesystem_stop()` also had to become a while loop to +read line-by-line irrespective of spaces. A for loop splits on spaces. + +Resolves: RHBZ#1624591 +--- + heartbeat/Filesystem | 106 +++++++++++++++++++++++++------------------ + 1 file changed, 61 insertions(+), 45 deletions(-) + +diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem +index 2f07a90ad..9a52aa712 100755 +--- a/heartbeat/Filesystem ++++ b/heartbeat/Filesystem +@@ -91,6 +91,7 @@ fi + + # Variables used by multiple methods + HOSTOS=`uname` ++TAB=' ' + + # The status file is going to an extra directory, by default + # +@@ -100,7 +101,7 @@ suffix="${OCF_RESOURCE_INSTANCE}" + [ "$OCF_RESKEY_CRM_meta_clone" ] && + suffix="${suffix}_$OCF_RESKEY_CRM_meta_clone" + suffix="${suffix}_`uname -n`" +-STATUSFILE=${OCF_RESKEY_directory}/$prefix$suffix ++STATUSFILE="${OCF_RESKEY_directory}/$prefix$suffix" + + ####################################################################### + +@@ -283,6 +284,7 @@ flushbufs() { + is_bind_mount() { + echo "$options" | grep -w bind >/dev/null 2>&1 + } ++ + list_mounts() { + local inpf="" + local mount_list="" +@@ -296,15 +298,23 @@ list_mounts() { + + # Make sure that the mount list has not been changed while reading. + while [ "$mount_list" != "$check_list" ]; do +- check_list=$mount_list ++ check_list="$mount_list" + if [ "$inpf" ]; then +- mount_list=$(cut -d' ' -f1,2,3 < $inpf) ++ # ... ++ # Spaces in device or mountpoint are octal \040 in $inpf ++ # Convert literal spaces (field separators) to tabs ++ mount_list=$(cut -d' ' -f1,2,3 < $inpf | tr ' ' "$TAB") + else +- mount_list=$($MOUNT | cut -d' ' -f1,3,5) ++ # on type ... ++ # Use tabs as field separators ++ match_string='\(.*\) on \(.*\) type \([^[:space:]]\)' ++ replace_string="\\1${TAB}\\3${TAB}\\5" ++ mount_list=$($MOUNT | sed "s/$match_string/$replace_string/g") + fi + done + +- echo "$mount_list" ++ # Convert octal \040 to space characters ++ printf "$mount_list" + } + + determine_blockdevice() { +@@ -318,7 +328,8 @@ determine_blockdevice() { + nfs4|nfs|smbfs|cifs|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs|none|lustre) + : ;; + *) +- DEVICE=`list_mounts | grep " $CANONICALIZED_MOUNTPOINT " | cut -d' ' -f1` ++ match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}" ++ DEVICE=`list_mounts | grep "$match_string" | cut -d"$TAB" -f1` + if [ -b "$DEVICE" ]; then + blockdevice=yes + fi +@@ -329,7 +340,7 @@ determine_blockdevice() { + # Lists all filesystems potentially mounted under a given path, + # excluding the path itself. + list_submounts() { +- list_mounts | grep " $1/" | cut -d' ' -f2 | sort -r ++ list_mounts | grep "${TAB}${1}/" | cut -d"$TAB" -f2 | sort -r + } + + # kernels < 2.6.26 can't handle bind remounts +@@ -358,15 +369,15 @@ bind_mount() { + if is_bind_mount && [ "$options" != "-o bind" ] + then + bind_kernel_check +- bind_opts=`echo $options | sed 's/bind/remount/'` +- $MOUNT $bind_opts $MOUNTPOINT ++ bind_opts=`echo "$options" | sed 's/bind/remount/'` ++ $MOUNT $bind_opts "$MOUNTPOINT" + else + true # make sure to return OK + fi + } + + is_option() { +- echo $OCF_RESKEY_options | grep -w "$1" >/dev/null 2>&1 ++ echo "$OCF_RESKEY_options" | grep -w "$1" >/dev/null 2>&1 + } + + is_fsck_needed() { +@@ -374,7 +385,7 @@ is_fsck_needed() { + force) true;; + no) false;; + ""|auto) +- case $FSTYPE in ++ case "$FSTYPE" in + ext4|ext4dev|ext3|reiserfs|reiser4|nss|xfs|jfs|vfat|fat|nfs4|nfs|cifs|smbfs|ocfs2|gfs2|none|lustre|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs) + false;; + *) +@@ -403,7 +414,7 @@ fstype_supported() + fi + + # support fuse-filesystems (e.g. GlusterFS) +- case $FSTYPE in ++ case "$FSTYPE" in + fuse.*|glusterfs|rozofs) support="fuse";; + esac + +@@ -486,7 +497,8 @@ trigger_udev_rules_if_needed() + Filesystem_start() + { + # Check if there are any mounts mounted under the mountpoint +- if list_mounts | grep -q -E " $CANONICALIZED_MOUNTPOINT/\w+" >/dev/null 2>&1; then ++ match_string="${TAB}${CANONICALIZED_MOUNTPOINT}" ++ if list_mounts | grep -q -E "$match_string/\w+" >/dev/null 2>&1; then + ocf_log err "There is one or more mounts mounted under $MOUNTPOINT." + return $OCF_ERR_CONFIGURED + fi +@@ -514,9 +526,9 @@ Filesystem_start() + if is_fsck_needed; then + ocf_log info "Starting filesystem check on $DEVICE" + if [ -z "$FSTYPE" ]; then +- $FSCK -p $DEVICE ++ $FSCK -p "$DEVICE" + else +- $FSCK -t $FSTYPE -p $DEVICE ++ $FSCK -t "$FSTYPE" -p "$DEVICE" + fi + + # NOTE: if any errors at all are detected, it returns non-zero +@@ -529,20 +541,20 @@ Filesystem_start() + fi + + [ -d "$MOUNTPOINT" ] || +- ocf_run mkdir -p $MOUNTPOINT ++ ocf_run mkdir -p "$MOUNTPOINT" + if [ ! -d "$MOUNTPOINT" ] ; then + ocf_exit_reason "Couldn't find directory [$MOUNTPOINT] to use as a mount point" + exit $OCF_ERR_INSTALLED + fi + +- flushbufs $DEVICE ++ flushbufs "$DEVICE" + # Mount the filesystem. + case "$FSTYPE" in +- none) $MOUNT $options $DEVICE $MOUNTPOINT && ++ none) $MOUNT $options "$DEVICE" "$MOUNTPOINT" && + bind_mount + ;; +- "") $MOUNT $options $DEVICE $MOUNTPOINT ;; +- *) $MOUNT -t $FSTYPE $options $DEVICE $MOUNTPOINT ;; ++ "") $MOUNT $options "$DEVICE" "$MOUNTPOINT" ;; ++ *) $MOUNT -t "$FSTYPE" $options "$DEVICE" "$MOUNTPOINT" ;; + esac + + if [ $? -ne 0 ]; then +@@ -595,23 +607,23 @@ signal_processes() { + done + } + try_umount() { +- local SUB=$1 +- $UMOUNT $umount_force $SUB +- list_mounts | grep -q " $SUB " >/dev/null 2>&1 || { ++ local SUB="$1" ++ $UMOUNT $umount_force "$SUB" ++ list_mounts | grep -q "${TAB}${SUB}${TAB}" >/dev/null 2>&1 || { + ocf_log info "unmounted $SUB successfully" + return $OCF_SUCCESS + } + return $OCF_ERR_GENERIC + } + fs_stop() { +- local SUB=$1 timeout=$2 sig cnt ++ local SUB="$1" timeout=$2 sig cnt + for sig in TERM KILL; do + cnt=$((timeout/2)) # try half time with TERM + while [ $cnt -gt 0 ]; do +- try_umount $SUB && ++ try_umount "$SUB" && + return $OCF_SUCCESS + ocf_exit_reason "Couldn't unmount $SUB; trying cleanup with $sig" +- signal_processes $SUB $sig ++ signal_processes "$SUB" $sig + cnt=$((cnt-1)) + sleep 1 + done +@@ -633,7 +645,7 @@ Filesystem_stop() + # Wipe the status file, but continue with a warning if + # removal fails -- the file system might be read only + if [ $OCF_CHECK_LEVEL -eq 20 ]; then +- rm -f ${STATUSFILE} ++ rm -f "${STATUSFILE}" + if [ $? -ne 0 ]; then + ocf_log warn "Failed to remove status file ${STATUSFILE}." + fi +@@ -650,7 +662,7 @@ Filesystem_stop() + + # Umount all sub-filesystems mounted under $MOUNTPOINT/ too. + local timeout +- for SUB in `list_submounts $MOUNTPOINT` $MOUNTPOINT; do ++ while read SUB; do + ocf_log info "Trying to unmount $SUB" + if ocf_is_true "$FAST_STOP"; then + timeout=6 +@@ -658,15 +670,18 @@ Filesystem_stop() + timeout=${OCF_RESKEY_CRM_meta_timeout:="20000"} + timeout=$((timeout/1000)) + fi +- fs_stop $SUB $timeout ++ fs_stop "$SUB" $timeout + rc=$? + if [ $rc -ne $OCF_SUCCESS ]; then + ocf_exit_reason "Couldn't unmount $SUB, giving up!" + fi +- done ++ done <<-EOF ++ $(list_submounts "$CANONICALIZED_MOUNTPOINT"; \ ++ echo $CANONICALIZED_MOUNTPOINT) ++ EOF + fi + +- flushbufs $DEVICE ++ flushbufs "$DEVICE" + + return $rc + } +@@ -677,7 +692,8 @@ Filesystem_stop() + # + Filesystem_status() + { +- if list_mounts | grep -q " $CANONICALIZED_MOUNTPOINT " >/dev/null 2>&1; then ++ match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}" ++ if list_mounts | grep -q "$match_string" >/dev/null 2>&1; then + rc=$OCF_SUCCESS + msg="$MOUNTPOINT is mounted (running)" + else +@@ -712,7 +728,7 @@ Filesystem_monitor_10() + return $OCF_SUCCESS + fi + dd_opts="iflag=direct bs=4k count=1" +- err_output=`dd if=$DEVICE $dd_opts 2>&1 >/dev/null` ++ err_output=`dd if="$DEVICE" $dd_opts 2>&1 >/dev/null` + if [ $? -ne 0 ]; then + ocf_exit_reason "Failed to read device $DEVICE" + ocf_log err "dd said: $err_output" +@@ -733,20 +749,20 @@ Filesystem_monitor_20() + # to bypass caches. + dd_opts="oflag=direct,sync bs=4k conv=fsync,sync" + fi +- status_dir=`dirname $STATUSFILE` ++ status_dir=$(dirname "$STATUSFILE") + [ -d "$status_dir" ] || mkdir -p "$status_dir" +- err_output=`echo "${OCF_RESOURCE_INSTANCE}" | dd of=${STATUSFILE} $dd_opts 2>&1` ++ err_output=`echo "${OCF_RESOURCE_INSTANCE}" | dd of="${STATUSFILE}" $dd_opts 2>&1` + if [ $? -ne 0 ]; then + ocf_exit_reason "Failed to write status file ${STATUSFILE}" + ocf_log err "dd said: $err_output" + return $OCF_ERR_GENERIC + fi +- test -f ${STATUSFILE} ++ test -f "${STATUSFILE}" + if [ $? -ne 0 ]; then + ocf_exit_reason "Cannot stat the status file ${STATUSFILE}" + return $OCF_ERR_GENERIC + fi +- cat ${STATUSFILE} > /dev/null ++ cat "${STATUSFILE}" > /dev/null + if [ $? -ne 0 ]; then + ocf_exit_reason "Cannot read the status file ${STATUSFILE}" + return $OCF_ERR_GENERIC +@@ -791,9 +807,9 @@ Filesystem_validate_all() + # NOTE: Without inserting the $FSTYPE module, this step may be imprecise + # TODO: This is Linux specific crap. + if [ ! -z "$FSTYPE" -a "$FSTYPE" != none ]; then +- cut -f2 /proc/filesystems |grep -q ^$FSTYPE$ ++ cut -f2 /proc/filesystems |grep -q "^${FSTYPE}$" + if [ $? -ne 0 ]; then +- modpath=/lib/modules/`uname -r` ++ modpath=/lib/modules/`uname -r` + moddep=$modpath/modules.dep + # Do we have $FSTYPE in modules.dep? + cut -d' ' -f1 $moddep |grep -q "^$modpath.*$FSTYPE\.k\?o:$" +@@ -826,7 +842,7 @@ set_blockdevice_var() { + blockdevice=no + + # these are definitely not block devices +- case $FSTYPE in ++ case "$FSTYPE" in + nfs4|nfs|smbfs|cifs|none|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs) return;; + esac + +@@ -834,7 +850,7 @@ set_blockdevice_var() { + return + fi + +- case $DEVICE in ++ case "$DEVICE" in + -*) # Oh... An option to mount instead... Typically -U or -L + ;; + /dev/null) # Special case for BSC +@@ -863,7 +879,7 @@ if [ -n "${OCF_RESKEY_force_unmount}" ]; then + FORCE_UNMOUNT=$OCF_RESKEY_force_unmount + fi + +-DEVICE=$OCF_RESKEY_device ++DEVICE="$OCF_RESKEY_device" + FSTYPE=$OCF_RESKEY_fstype + if [ ! -z "$OCF_RESKEY_options" ]; then + options="-o $OCF_RESKEY_options" +@@ -899,10 +915,10 @@ if [ -z "$OCF_RESKEY_directory" ]; then + exit $OCF_ERR_CONFIGURED + fi + else +- MOUNTPOINT=$(echo $OCF_RESKEY_directory | sed 's/\/*$//') ++ MOUNTPOINT="$(echo "$OCF_RESKEY_directory" | sed 's/\/*$//')" + : ${MOUNTPOINT:=/} + if [ -e "$MOUNTPOINT" ] ; then +- CANONICALIZED_MOUNTPOINT=$(readlink -f "$MOUNTPOINT") ++ CANONICALIZED_MOUNTPOINT="$(readlink -f "$MOUNTPOINT")" + if [ $? -ne 0 ]; then + ocf_exit_reason "Could not canonicalize $MOUNTPOINT because readlink failed" + exit $OCF_ERR_GENERIC +@@ -947,7 +963,7 @@ CLUSTERSAFE=0 + is_option "ro" && + CLUSTERSAFE=2 + +-case $FSTYPE in ++case "$FSTYPE" in + nfs4|nfs|smbfs|cifs|none|gfs2|glusterfs|ceph|ocfs2|overlay|overlayfs|tmpfs|cvfs) + CLUSTERSAFE=1 # this is kind of safe too + ;; + +From eca9a96ad3356df3636bfa3187afe1b1954693b2 Mon Sep 17 00:00:00 2001 +From: Reid wahl +Date: Fri, 10 Jul 2020 16:38:04 -0700 +Subject: [PATCH 2/3] Filesystem: POSIX-compliant syntax for portability + +Updated to use POSIX `$()` instead of Bourne-shell backticks, and to +use `grep ... >/dev/null 2>&1` instead of `grep -q`. (Note: `grep -q` +only suppresses `stdout` anyway. `grep -q -s` would be required to +suppress both `stdout` and `stderr`.) +--- + heartbeat/Filesystem | 33 +++++++++++++++++---------------- + 1 file changed, 17 insertions(+), 16 deletions(-) + +diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem +index 9a52aa712..34ade20d7 100755 +--- a/heartbeat/Filesystem ++++ b/heartbeat/Filesystem +@@ -90,7 +90,7 @@ fi + : ${OCF_RESKEY_force_unmount=${OCF_RESKEY_force_unmount_default}} + + # Variables used by multiple methods +-HOSTOS=`uname` ++HOSTOS=$(uname) + TAB=' ' + + # The status file is going to an extra directory, by default +@@ -100,7 +100,7 @@ prefix=${OCF_RESKEY_statusfile_prefix} + suffix="${OCF_RESOURCE_INSTANCE}" + [ "$OCF_RESKEY_CRM_meta_clone" ] && + suffix="${suffix}_$OCF_RESKEY_CRM_meta_clone" +-suffix="${suffix}_`uname -n`" ++suffix="${suffix}_$(uname -n)" + STATUSFILE="${OCF_RESKEY_directory}/$prefix$suffix" + + ####################################################################### +@@ -329,7 +329,7 @@ determine_blockdevice() { + : ;; + *) + match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}" +- DEVICE=`list_mounts | grep "$match_string" | cut -d"$TAB" -f1` ++ DEVICE=$(list_mounts | grep "$match_string" | cut -d"$TAB" -f1) + if [ -b "$DEVICE" ]; then + blockdevice=yes + fi +@@ -354,7 +354,7 @@ bind_kernel_check() { + exit(1); + }' + [ $? -ne 0 ] && +- ocf_log warn "kernel `uname -r` cannot handle read only bind mounts" ++ ocf_log warn "kernel $(uname -r) cannot handle read only bind mounts" + } + + bind_root_mount_check() { +@@ -369,7 +369,7 @@ bind_mount() { + if is_bind_mount && [ "$options" != "-o bind" ] + then + bind_kernel_check +- bind_opts=`echo "$options" | sed 's/bind/remount/'` ++ bind_opts=$(echo "$options" | sed 's/bind/remount/') + $MOUNT $bind_opts "$MOUNTPOINT" + else + true # make sure to return OK +@@ -469,7 +469,7 @@ trigger_udev_rules_if_needed() + refresh_flag="yes" + fi + else +- tmp="`echo $DEVICE|awk '{$1=""; print substr($0,2)}'`" ++ tmp="$(echo $DEVICE|awk '{$1=""; print substr($0,2)}')" + case "$DEVICE" in + -U*|--uuid*) + tmp="/dev/disk/by-uuid/$tmp" +@@ -498,7 +498,7 @@ Filesystem_start() + { + # Check if there are any mounts mounted under the mountpoint + match_string="${TAB}${CANONICALIZED_MOUNTPOINT}" +- if list_mounts | grep -q -E "$match_string/\w+" >/dev/null 2>&1; then ++ if list_mounts | grep -E "$match_string/\w+" >/dev/null 2>&1; then + ocf_log err "There is one or more mounts mounted under $MOUNTPOINT." + return $OCF_ERR_CONFIGURED + fi +@@ -602,14 +602,14 @@ signal_processes() { + return + fi + for pid in $pids; do +- ocf_log info "sending signal $sig to: `ps -f $pid | tail -1`" ++ ocf_log info "sending signal $sig to: $(ps -f $pid | tail -1)" + kill -s $sig $pid + done + } + try_umount() { + local SUB="$1" + $UMOUNT $umount_force "$SUB" +- list_mounts | grep -q "${TAB}${SUB}${TAB}" >/dev/null 2>&1 || { ++ list_mounts | grep "${TAB}${SUB}${TAB}" >/dev/null 2>&1 || { + ocf_log info "unmounted $SUB successfully" + return $OCF_SUCCESS + } +@@ -693,7 +693,7 @@ Filesystem_stop() + Filesystem_status() + { + match_string="${TAB}${CANONICALIZED_MOUNTPOINT}${TAB}" +- if list_mounts | grep -q "$match_string" >/dev/null 2>&1; then ++ if list_mounts | grep "$match_string" >/dev/null 2>&1; then + rc=$OCF_SUCCESS + msg="$MOUNTPOINT is mounted (running)" + else +@@ -728,7 +728,7 @@ Filesystem_monitor_10() + return $OCF_SUCCESS + fi + dd_opts="iflag=direct bs=4k count=1" +- err_output=`dd if="$DEVICE" $dd_opts 2>&1 >/dev/null` ++ err_output=$(dd if="$DEVICE" $dd_opts 2>&1 >/dev/null) + if [ $? -ne 0 ]; then + ocf_exit_reason "Failed to read device $DEVICE" + ocf_log err "dd said: $err_output" +@@ -751,7 +751,7 @@ Filesystem_monitor_20() + fi + status_dir=$(dirname "$STATUSFILE") + [ -d "$status_dir" ] || mkdir -p "$status_dir" +- err_output=`echo "${OCF_RESOURCE_INSTANCE}" | dd of="${STATUSFILE}" $dd_opts 2>&1` ++ err_output=$(echo "${OCF_RESOURCE_INSTANCE}" | dd of="${STATUSFILE}" $dd_opts 2>&1) + if [ $? -ne 0 ]; then + ocf_exit_reason "Failed to write status file ${STATUSFILE}" + ocf_log err "dd said: $err_output" +@@ -807,12 +807,13 @@ Filesystem_validate_all() + # NOTE: Without inserting the $FSTYPE module, this step may be imprecise + # TODO: This is Linux specific crap. + if [ ! -z "$FSTYPE" -a "$FSTYPE" != none ]; then +- cut -f2 /proc/filesystems |grep -q "^${FSTYPE}$" ++ cut -f2 /proc/filesystems | grep "^${FSTYPE}$" >/dev/null 2>&1 + if [ $? -ne 0 ]; then +- modpath=/lib/modules/`uname -r` ++ modpath=/lib/modules/$(uname -r) + moddep=$modpath/modules.dep + # Do we have $FSTYPE in modules.dep? +- cut -d' ' -f1 $moddep |grep -q "^$modpath.*$FSTYPE\.k\?o:$" ++ cut -d' ' -f1 $moddep \ ++ | grep "^${modpath}.*${FSTYPE}\.k\?o:$" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + ocf_log info "It seems we do not have $FSTYPE support" + fi +@@ -846,7 +847,7 @@ set_blockdevice_var() { + nfs4|nfs|smbfs|cifs|none|glusterfs|ceph|tmpfs|overlay|overlayfs|rozofs|zfs|cvfs|lustre) return;; + esac + +- if `is_option "loop"`; then ++ if $(is_option "loop"); then + return + fi + + +From 5517712f4bb6e90b23cde6310c03509c9061cb36 Mon Sep 17 00:00:00 2001 +From: Reid wahl +Date: Fri, 10 Jul 2020 16:44:17 -0700 +Subject: [PATCH 3/3] Filesystem: Convert leading space characters to tabs + +A few lines started with spaces instead of tabs. Tabs are the +convention in this file. +--- + heartbeat/Filesystem | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem +index 34ade20d7..501e5a0d0 100755 +--- a/heartbeat/Filesystem ++++ b/heartbeat/Filesystem +@@ -359,10 +359,10 @@ bind_kernel_check() { + + bind_root_mount_check() { + if [ "$(df -P "$1" | awk 'END{print $6}')" = "/" ]; then +- return 1 +- else +- return 0 +- fi ++ return 1 ++ else ++ return 0 ++ fi + } + + bind_mount() { +@@ -571,10 +571,10 @@ get_pids() + local procs + local mmap_procs + +- if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_root_mount_check "$DEVICE"; then +- ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'" +- FORCE_UNMOUNT=safe +- fi ++ if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_root_mount_check "$DEVICE"; then ++ ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'" ++ FORCE_UNMOUNT=safe ++ fi + + if ocf_is_true "$FORCE_UNMOUNT"; then + if [ "X${HOSTOS}" = "XOpenBSD" ];then diff --git a/SOURCES/bz1872999-aws-vpc-move-ip-add-region-parameter.patch b/SOURCES/bz1872999-aws-vpc-move-ip-add-region-parameter.patch new file mode 100644 index 0000000..4fef3d5 --- /dev/null +++ b/SOURCES/bz1872999-aws-vpc-move-ip-add-region-parameter.patch @@ -0,0 +1,81 @@ +--- ClusterLabs-resource-agents-e711383f/heartbeat/aws-vpc-move-ip 2020-09-23 11:57:38.855067216 +0200 ++++ aws-vpc-move-ip.tmp 2020-09-23 11:57:17.993045991 +0200 +@@ -37,13 +37,17 @@ + # Defaults + OCF_RESKEY_awscli_default="/usr/bin/aws" + OCF_RESKEY_profile_default="default" ++OCF_RESKEY_region_default="" + OCF_RESKEY_routing_table_role_default="" + OCF_RESKEY_monapi_default="false" + + : ${OCF_RESKEY_awscli=${OCF_RESKEY_awscli_default}} + : ${OCF_RESKEY_profile=${OCF_RESKEY_profile_default}} ++: ${OCF_RESKEY_region=${OCF_RESKEY_region_default}} + : ${OCF_RESKEY_routing_table_role=${OCF_RESKEY_routing_table_role_default}} + : ${OCF_RESKEY_monapi=${OCF_RESKEY_monapi_default}} ++ ++[ -n "$OCF_RESKEY_region" ] && region_opt="--region $OCF_RESKEY_region" + ####################################################################### + + +@@ -87,6 +91,14 @@ + + + ++ ++ ++Valid AWS region name (e.g., 'us-west-2') ++ ++region name ++ ++ ++ + + + VPC private IP address +@@ -151,7 +163,7 @@ + execute_cmd_as_role(){ + cmd=$1 + role=$2 +- output="$($OCF_RESKEY_awscli sts assume-role --role-arn $role --role-session-name AWSCLI-RouteTableUpdate --profile $OCF_RESKEY_profile --output=text)" ++ output="$($OCF_RESKEY_awscli sts assume-role --role-arn $role --role-session-name AWSCLI-RouteTableUpdate --profile $OCF_RESKEY_profile $region_opt --output=text)" + export AWS_ACCESS_KEY_ID="$(echo $output | awk -F" " '$4=="CREDENTIALS" {print $5}')" + export AWS_SECRET_ACCESS_KEY="$(echo $output | awk -F" " '$4=="CREDENTIALS" {print $7}')" + export AWS_SESSION_TOKEN="$(echo $output | awk -F" " '$4=="CREDENTIALS" {print $8}')" +@@ -198,11 +210,11 @@ + for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do + ocf_log info "monitor: check routing table (API call) - $rtb" + if [[ -z "${OCF_RESKEY_routing_table_role}" ]]; then +- cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId" ++ cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId" + ocf_log debug "executing command: $cmd" + ROUTE_TO_INSTANCE="$($cmd)" + else +- cmd="$OCF_RESKEY_awscli --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId" ++ cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 describe-route-tables --route-table-ids $rtb --query RouteTables[*].Routes[?DestinationCidrBlock=='$OCF_RESKEY_ip/32'].InstanceId" + ROUTE_TO_INSTANCE="$(execute_cmd_as_role "$cmd" $OCF_RESKEY_routing_table_role)" + fi + ocf_log debug "Overlay IP is currently routed to ${ROUTE_TO_INSTANCE}" +@@ -283,11 +295,11 @@ + + for rtb in $(echo $OCF_RESKEY_routing_table | sed -e 's/,/ /g'); do + if [[ -z "${OCF_RESKEY_routing_table_role}" ]]; then +- cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" ++ cmd="$OCF_RESKEY_awscli --profile $OCF_RESKEY_profile $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" + ocf_log debug "executing command: $cmd" + $cmd + else +- cmd="$OCF_RESKEY_awscli --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" ++ cmd="$OCF_RESKEY_awscli $region_opt --output text ec2 replace-route --route-table-id $rtb --destination-cidr-block ${OCF_RESKEY_ip}/32 --network-interface-id $EC2_NETWORK_INTERFACE_ID" + update_response="$(execute_cmd_as_role "$cmd" $OCF_RESKEY_routing_table_role)" + fi + rc=$? +@@ -397,7 +409,7 @@ + ec2ip_monitor;; + validate-all) + exit $?;; +- *) ++ *) + echo $USAGE + exit $OCF_ERR_UNIMPLEMENTED + ;; diff --git a/SPECS/resource-agents.spec b/SPECS/resource-agents.spec index 4b87092..2219f90 100644 --- a/SPECS/resource-agents.spec +++ b/SPECS/resource-agents.spec @@ -70,7 +70,7 @@ Name: resource-agents Summary: Open Source HA Reusable Cluster Resource Scripts Version: 4.1.1 -Release: 68%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist} +Release: 69%{?rcver:%{rcver}}%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist} License: GPLv2+ and LGPLv2+ URL: https://github.com/ClusterLabs/resource-agents %if 0%{?fedora} || 0%{?centos_version} || 0%{?rhel} @@ -236,6 +236,11 @@ Patch144: bz1845574-azure-events-2-import-urlerror-encode-postdata.patch Patch145: bz1846733-gcp-vpc-move-vip-1-support-multiple-alias-ips.patch Patch146: bz1846733-gcp-vpc-move-vip-2-fix-list-sort.patch Patch147: bz1850778-azure-lb-fix-redirect-issue.patch +Patch148: bz1640587-pgsql-ignore-masters-re-promote.patch +Patch149: bz1795535-pgsql-1-add-postgresql-12-support.patch +Patch150: bz1795535-pgsql-2-fix-uppercase-hostname-support.patch +Patch151: bz1858752-Filesystem-support-whitespace-device-dir.patch +Patch152: bz1872999-aws-vpc-move-ip-add-region-parameter.patch # bundle patches Patch1000: 7-gcp-bundled.patch @@ -275,7 +280,14 @@ Requires: /usr/sbin/fuser /bin/mount Requires: /sbin/fsck Requires: /usr/sbin/fsck.ext2 /usr/sbin/fsck.ext3 /usr/sbin/fsck.ext4 Requires: /usr/sbin/fsck.xfs -Requires: /sbin/mount.nfs /sbin/mount.nfs4 /usr/sbin/mount.cifs +Requires: /sbin/mount.nfs /sbin/mount.nfs4 +%if 0%{?fedora} < 33 || (0%{?rhel} && 0%{?rhel} < 9) || (0%{?centos} && 0%{?centos} < 9) || 0%{?suse_version} +%if (0%{?rhel} && 0%{?rhel} < 8) || (0%{?centos} && 0%{?centos} < 8) +Requires: /usr/sbin/mount.cifs +%else +Recommends: /usr/sbin/mount.cifs +%endif +%endif # IPaddr2 Requires: /sbin/ip @@ -532,6 +544,11 @@ exit 1 %patch145 -p1 %patch146 -p1 %patch147 -p1 +%patch148 -p1 +%patch149 -p1 +%patch150 -p1 +%patch151 -p1 -F1 +%patch152 -p1 chmod 755 heartbeat/nova-compute-wait chmod 755 heartbeat/NovaEvacuate @@ -1095,6 +1112,20 @@ ccs_update_schema > /dev/null 2>&1 ||: %endif %changelog +* Wed Sep 23 2020 Oyvind Albrigtsen - 4.1.1-69 +- pgsql: ignore masters re-promote +- pgsql: add PostgreSQL 12 support +- Make Samba/CIFS dependency weak +- Filesystem: Support whitespace in device or directory name +- aws-vpc-move-ip: add region parameter + + + Resolves: rhbz#1640587 + Resolves: rhbz#1795535 + Resolves: rhbz#1828600 + Resolves: rhbz#1858752 + Resolves: rhbz#1872999 + * Thu Aug 20 2020 Oyvind Albrigtsen - 4.1.1-68 - azure-lb: fix redirect issue