resource-agents/RHEL-102779-pgsqlms-fix-validate-warnings.patch
Oyvind Albrigtsen 4800c63bd0 - pgsqlms: fix validate warnings
- nginx: fix validate warnings
- Filesystem: speed up get PIDs

  Resolves: RHEL-102779, RHEL-112443, RHEL-121985
2025-11-04 13:31:59 +01:00

182 lines
6.7 KiB
Diff

From 443841ea27d61a2eedff4a0c4f18bb5771fb8d5e Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Tue, 8 Jul 2025 15:19:09 +0200
Subject: [PATCH] pgsqlms: improvements and fixes
- add support for promotable variables
- dont fail during validate-all action if notify != true (to avoid
error and future fails during `pcs resource create`)
- report NOT_RUNNING during probe-action when no database has been
created or postgresql is not installed
---
script/pgsqlms | 74 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 49 insertions(+), 25 deletions(-)
diff --git a/heartbeat/pgsqlms b/heartbeat/pgsqlms
index 5ddd67a..1abffeb 100755
--- a/heartbeat/pgsqlms
+++ b/heartbeat/pgsqlms
@@ -485,7 +485,7 @@ sub _pg_isready {
# Add 60s to the timeout or use a 24h timeout fallback to make sure
# Pacemaker will give up before us and take decisions
my $timeout = ( _get_action_timeout() || 60*60*24 ) + 60;
- my $rc = _runas( $PGISREADY, '-h', $pghost, '-p', $pgport, '-d', 'postgres', '-t', $timeout );
+ my $rc = _runas( $PGISREADY, '-q', '-h', $pghost, '-p', $pgport, '-d', 'postgres', '-t', $timeout );
# Possible error codes:
# 1: ping rejected (usually when instance is in startup, in crash
@@ -624,14 +624,18 @@ sub _get_controldata {
and defined $controldata{'redo'}
and defined $controldata{'wal_level'};
- ocf_exit_reason( 'Could not read all datas from controldata file for "%s"',
- $datadir );
+ if ( ! ocf_is_probe() ) {
+ ocf_exit_reason( 'Could not read all datas from controldata file for "%s"',
+ $datadir );
- ocf_log( 'debug',
- "_get_controldata: controldata file: %s",
- Data::Dumper->new( [ \%controldata ] )->Terse(1)->Dump, $ans );
+ ocf_log( 'debug',
+ "_get_controldata: controldata file: %s",
+ Data::Dumper->new( [ \%controldata ] )->Terse(1)->Dump, $ans );
- exit $OCF_ERR_ARGS;
+ exit $OCF_ERR_ARGS;
+ }
+
+ return ();
}
# Pead major version from datadir/PG_VERSION and return it as numeric version
@@ -642,8 +646,12 @@ sub _get_pg_version {
# check PG_VERSION
if ( ! -s "$datadir/PG_VERSION" ) {
- ocf_exit_reason( 'PG_VERSION does not exist in "%s"', $datadir );
- exit $OCF_ERR_ARGS;
+ if ( ! ocf_is_probe() ) {
+ ocf_exit_reason( 'PG_VERSION does not exist in "%s"', $datadir );
+ exit $OCF_ERR_ARGS;
+ } else {
+ return -1;
+ }
}
unless ( open( $fh, '<', "$datadir/PG_VERSION" ) ) {
@@ -1324,22 +1332,34 @@ sub pgsql_validate_all {
}
# check notify=true
- unless ( defined $ENV{'OCF_RESKEY_CRM_meta_notify'}
- and lc($ENV{'OCF_RESKEY_CRM_meta_notify'}) =~ /^true$|^on$|^yes$|^y$|^1$/ ) {
+ unless ( $__OCF_ACTION eq 'validate-all'
+ or ( defined $ENV{'OCF_RESKEY_CRM_meta_notify'}
+ and lc($ENV{'OCF_RESKEY_CRM_meta_notify'}) =~ /^true$|^on$|^yes$|^y$|^1$/ ) ) {
ocf_exit_reason(
'You must set meta parameter notify=true for your "master" resource'
);
return $OCF_ERR_INSTALLED;
}
- # check master-max=1
+ # check promoted_max=1/master-max=1
unless (
- defined $ENV{'OCF_RESKEY_CRM_meta_master_max'}
- and $ENV{'OCF_RESKEY_CRM_meta_master_max'} eq '1'
+ $__OCF_ACTION eq 'validate-all'
+ or
+ ( defined $ENV{'OCF_RESKEY_CRM_meta_promoted_max'}
+ and $ENV{'OCF_RESKEY_CRM_meta_promoted_max'} eq '1' )
+ or
+ (defined $ENV{'OCF_RESKEY_CRM_meta_master_max'}
+ and $ENV{'OCF_RESKEY_CRM_meta_master_max'} eq '1')
) {
- ocf_exit_reason(
- 'You must set meta parameter master-max=1 for your "master" resource'
- );
+ if ( ocf_version_cmp( $ENV{"OCF_RESKEY_crm_feature_set"}, '3.1.0' ) =~ /^[21]$/ ) {
+ ocf_exit_reason(
+ 'You must set meta parameter promoted_max=1 for your "promotable" resource'
+ );
+ } else {
+ ocf_exit_reason(
+ 'You must set meta parameter master-max=1 for your "master" resource'
+ );
+ }
return $OCF_ERR_INSTALLED;
}
@@ -1366,14 +1386,14 @@ sub pgsql_validate_all {
}
$guc = qx{ $POSTGRES -C primary_conninfo -D "$pgdata" $start_opts};
- unless ($guc =~ /\bapplication_name='?$nodename'?\b/) {
+ unless ($guc =~ /\bapplication_name='?$nodename'?\b/ or $__OCF_ACTION eq 'validate-all') {
ocf_exit_reason(
q{Parameter "primary_conninfo" MUST contain 'application_name=%s'. }.
q{It is currently set to '%s'}, $nodename, $guc );
return $OCF_ERR_ARGS;
}
}
- else {
+ elsif ($PGVERNUM > -1 ) {
my @content;
# check recovery template
@@ -1428,14 +1448,14 @@ sub pgsql_validate_all {
}
# require 9.3 minimum
- if ( $PGVERNUM < $PGVER_93 ) {
+ if ( $PGVERNUM < $PGVER_93 && $PGVERNUM > -1 ) {
ocf_exit_reason( "Require 9.3 and more" );
return $OCF_ERR_INSTALLED;
}
# check binaries
- unless ( -x $PGCTL and -x $PGPSQL and -x $PGCTRLDATA and -x $PGISREADY
- and ( -x $PGWALDUMP or -x "$bindir/pg_xlogdump")
+ unless ( ( -x $PGCTL and -x $PGPSQL and -x $PGCTRLDATA and -x $PGISREADY
+ and ( -x $PGWALDUMP or -x "$bindir/pg_xlogdump") ) or ocf_is_probe()
) {
ocf_exit_reason(
"Missing one or more binary. Check following path: %s, %s, %s, %s, %s or %s",
@@ -1445,7 +1465,7 @@ sub pgsql_validate_all {
# require wal_level >= hot_standby
%cdata = _get_controldata();
- unless ( $cdata{'wal_level'} =~ m{hot_standby|logical|replica} ) {
+ unless ( (defined $cdata{'wal_level'} and $cdata{'wal_level'} =~ m{hot_standby|logical|replica}) or ocf_is_probe() ) {
ocf_exit_reason(
'wal_level must be one of "hot_standby", "logical" or "replica"' );
return $OCF_ERR_ARGS;
@@ -1599,6 +1619,10 @@ sub pgsql_monitor {
return _confirm_role();
}
+ if ( ocf_is_probe() ) {
+ return $OCF_NOT_RUNNING;
+ }
+
if ( $pgisready_rc == 1 ) {
# The attempt was rejected.
# This could happen in several cases:
@@ -2254,13 +2278,13 @@ chdir File::Spec->tmpdir();
# mandatory sanity checks
# check pgdata
-if ( ! -d $pgdata ) {
+if ( ! -d $pgdata and ! ocf_is_probe() ) {
ocf_exit_reason( 'PGDATA "%s" does not exist', $pgdata );
exit $OCF_ERR_ARGS;
}
# check datadir
-if ( ! -d $datadir ) {
+if ( ! -d $datadir and ! ocf_is_probe() ) {
ocf_exit_reason( 'data_directory "%s" does not exist', $datadir );
exit $OCF_ERR_ARGS;
}