2.0.0-0.1.rc2 - Update for new upstream tarball

... for release candidate: Pacemaker-2.0.0-rc2,
  for full details, see included ChangeLog file or
  https://github.com/ClusterLabs/pacemaker/releases/tag/Pacemaker-2.0.0-rc2

Adapt spec file more akin to upstream version including:
. out-of-tree change from 1.1.18-2 build got subsumed (508ad52e7)
. %%{_sysconfdir}/pacemaker path got properly owned
  (-cli package; f6e3ab98d)
. -libs package started to properly declare Requires(pre): shadow-utils
  (293fcc1e8 + b3d49d210)
. some build conditionals and dependencies dropped for no longer
  (snmp, esmtp; f24bdc6f2 and 1f7374884, respectively) or never
  being relevant (~bison, byacc, flex; 61aef8af4)
. some dependencies were constrained with new or higher lower bounds:
  corosync needs to be of version 2+ unconditionally (ccd58fe29),
  ditto some others components (~GLib, 1ac2e7cbb), plus both 2 and 3
  versions of Python are now (comprehensively for the auxiliary
  functionality where used) supported upstream with the latter being
  a better fit (453355f8f)
. package descriptions got to reflect the drop of legacy low-level
  cluster infrastructures (55ab749bf)

Adapt spec file akin to current packaging guidelines including:
. drop some redundant/futile expressions (defattr, "-n %%{name}-libs"
  instead of plain "libs", "timezone hack"), add some notes for future
. make -cts and -doc packages noarch (former enabled with 088a5e7d4)
. simplify "systemd_requires" macro invocation, and relax it to
  "systemd_ordering" for -remote package where possible so as not
  to drag systemd into a lightweight system setup (e.g. container)
  needlessly
. adjust, in a compatible way, common ldconfig invocation with
  post{,un} scriptlets
  (https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets)
. drop some more unuseful conditionals (upstart_job)

Apply some regression fixes on top as patches (PR #1457, #1459)

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
This commit is contained in:
Jan Pokorný 2018-04-13 16:43:20 +02:00
parent 0212b6ad2c
commit 436eae4e1e
No known key found for this signature in database
GPG Key ID: 61BBB23A9E8F8DE2
22 changed files with 4948 additions and 184 deletions

View File

@ -0,0 +1,43 @@
From b2bd800e70547990c00b8e8efc67b930e699887b Mon Sep 17 00:00:00 2001
From: Andrew Beekhof <andrew@beekhof.net>
Date: Wed, 11 Apr 2018 11:48:13 +1000
Subject: [PATCH 01/17] Fix: rhbz#1565187 - Ensure failures that cause fencing
are not removed until after fencing completes
---
lib/pengine/unpack.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index fcfd7ccbf..6b1e519c7 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -2807,6 +2807,7 @@ static bool check_operation_expiry(resource_t *rsc, node_t *node, int rc, xmlNod
}
if (clear_reason != NULL) {
+ node_t *remote_node = pe_find_node(data_set->nodes, rsc->id);
char *key = generate_op_key(rsc->id, CRM_OP_CLEAR_FAILCOUNT, 0);
action_t *clear_op = custom_action(rsc, key, CRM_OP_CLEAR_FAILCOUNT,
node, FALSE, TRUE, data_set);
@@ -2815,6 +2816,17 @@ static bool check_operation_expiry(resource_t *rsc, node_t *node, int rc, xmlNod
crm_notice("Clearing failure of %s on %s because %s " CRM_XS " %s",
rsc->id, node->details->uname, clear_reason, clear_op->uuid);
+
+ if (is_set(data_set->flags, pe_flag_stonith_enabled)
+ && rsc->remote_reconnect_ms
+ && remote_node
+ && remote_node->details->unclean) {
+
+ action_t *fence = pe_fence_op(remote_node, NULL, TRUE, NULL, data_set);
+ crm_notice("Waiting for %s to complete before clearing %s failure for remote node %s", fence?fence->uuid:"nil", task, rsc->id);
+
+ order_actions(fence, clear_op, pe_order_implies_then);
+ }
}
if (expired && (interval_ms == 0) && safe_str_eq(task, CRMD_ACTION_STATUS)) {
--
2.17.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
From faefccc1dc3108853bc7cfa35681a1ac261c5461 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 11 Apr 2018 11:28:43 -0500
Subject: [PATCH 03/17] Test: cts-pengine: create_mode is now controlled by
--update
---
cts/cts-pengine.in | 5 -----
1 file changed, 5 deletions(-)
diff --git a/cts/cts-pengine.in b/cts/cts-pengine.in
index ca29d76c3..905354db2 100644
--- a/cts/cts-pengine.in
+++ b/cts/cts-pengine.in
@@ -391,11 +391,6 @@ if [ -n "$single_test" ]; then
fi
DO_VERSIONED_TESTS=0
-create_mode=true
-# info Creating the following tests from $io_dir
-# do_test order-expired-failure "Order failcount cleanup after remote fencing"
-
-create_mode=false
info Performing the following tests from $io_dir
echo ""
--
2.17.0

View File

@ -0,0 +1,178 @@
From 5f370802061ea4e8d5a194fd5ed4f1020e195145 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 10:57:40 -0500
Subject: [PATCH 04/17] Build: cts: update scripts to use new @BASH_PATH@
subsitution variable
---
configure.ac | 5 ++++
cts/{CTS.py => CTS.py.in} | 28 +++++------------------
cts/{cluster_test => cluster_test.in} | 8 ++++++-
cts/{cts-cli => cts-cli.in} | 8 ++++++-
cts/{cts-regression => cts-regression.in} | 7 +++++-
cts/{cts => cts.in} | 8 ++++++-
7 files changed, 38 insertions(+), 26 deletions(-)
rename cts/{CTS.py => CTS.py.in} (97%)
rename cts/{cluster_test => cluster_test.in} (96%)
rename cts/{cts-cli => cts-cli.in} (99%)
rename cts/{cts-regression => cts-regression.in} (96%)
rename cts/{cts => cts.in} (97%)
diff --git a/configure.ac b/configure.ac
index c39954272..41676ed61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1700,9 +1700,13 @@ dnl Files we output that need to be executable
AC_CONFIG_FILES([cts/CTSlab.py], [chmod +x cts/CTSlab.py])
AC_CONFIG_FILES([cts/LSBDummy], [chmod +x cts/LSBDummy])
AC_CONFIG_FILES([cts/OCFIPraTest.py], [chmod +x cts/OCFIPraTest.py])
+AC_CONFIG_FILES([cts/cluster_test], [chmod +x cts/cluster_test])
+AC_CONFIG_FILES([cts/cts], [chmod +x cts/cts])
+AC_CONFIG_FILES([cts/cts-cli], [chmod +x cts/cts-cli])
AC_CONFIG_FILES([cts/cts-coverage], [chmod +x cts/cts-coverage])
AC_CONFIG_FILES([cts/cts-lrmd], [chmod +x cts/cts-lrmd])
AC_CONFIG_FILES([cts/cts-pengine], [chmod +x cts/cts-pengine])
+AC_CONFIG_FILES([cts/cts-regression], [chmod +x cts/cts-regression])
AC_CONFIG_FILES([cts/cts-stonithd], [chmod +x cts/cts-stonithd])
AC_CONFIG_FILES([cts/lxc_autogen.sh], [chmod +x cts/lxc_autogen.sh])
AC_CONFIG_FILES([cts/benchmark/clubench], [chmod +x cts/benchmark/clubench])
@@ -1718,6 +1722,7 @@ dnl Other files we output
AC_CONFIG_FILES(Makefile \
Doxyfile \
cts/Makefile \
+ cts/CTS.py \
cts/CTSvars.py \
cts/benchmark/Makefile \
cib/Makefile \
diff --git a/cts/CTS.py b/cts/CTS.py.in
similarity index 97%
rename from cts/CTS.py
rename to cts/CTS.py.in
index e78b54d56..30ecfba88 100644
--- a/cts/CTS.py
+++ b/cts/CTS.py.in
@@ -3,27 +3,11 @@
Classes related to testing high-availability clusters...
'''
-from __future__ import print_function
-
-__copyright__ = '''
-Copyright (C) 2000, 2001 Alan Robertson <alanr@unix.sh>
-Licensed under the GNU GPL.
-'''
-
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# Pacemaker targets compatibility with Python 2.7 and 3.2+
+from __future__ import print_function, unicode_literals, absolute_import, division
+
+__copyright__ = "Copyright 2000-2018 Alan Robertson <alanr@unix.sh>"
+__license__ = "GNU General Public License version 2 or later (GPLv2+) WITHOUT ANY WARRANTY"
import string, sys, time, re, os, traceback
@@ -42,7 +26,7 @@ from cts.patterns import PatternSelector
has_log_stats = {}
log_stats_bin = CTSvars.CRM_DAEMON_DIR + "/cts_log_stats.sh"
log_stats = """
-#!/bin/bash
+#!@BASH_PATH@
# Tool for generating system load reports while CTS runs
trap "" 1
diff --git a/cts/cluster_test b/cts/cluster_test.in
similarity index 96%
rename from cts/cluster_test
rename to cts/cluster_test.in
index 0cc8c26af..603bfe2f7 100755
--- a/cts/cluster_test
+++ b/cts/cluster_test.in
@@ -1,4 +1,10 @@
-#!/bin/bash
+#!@BASH_PATH@
+#
+# Copyright 2008-2018 Andrew Beekhof <andrew@beekhof.net>
+#
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
+#
if [ -e ~/.cts ]; then
. ~/.cts
fi
diff --git a/cts/cts-cli b/cts/cts-cli.in
similarity index 99%
rename from cts/cts-cli
rename to cts/cts-cli.in
index 75751c662..e62e5e2fe 100755
--- a/cts/cts-cli
+++ b/cts/cts-cli.in
@@ -1,4 +1,10 @@
-#!/bin/bash
+#!@BASH_PATH@
+#
+# Copyright 2008-2018 Andrew Beekhof <andrew@beekhof.net>
+#
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
+#
USAGE_TEXT="Usage: cts-cli [<options>]
Options:
diff --git a/cts/cts-regression b/cts/cts-regression.in
similarity index 96%
rename from cts/cts-regression
rename to cts/cts-regression.in
index fbc6319f8..6c9931f79 100755
--- a/cts/cts-regression
+++ b/cts/cts-regression.in
@@ -1,9 +1,14 @@
-#!/bin/bash
+#!@BASH_PATH@
#
# cts-regression
#
# Convenience wrapper for running any of the Pacemaker regression tests
#
+# Copyright 2012-2018 Andrew Beekhof <andrew@beekhof.net>
+#
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
+#
USAGE_TEXT="Usage: cts-regression [<options>] [<test> ...]
Options:
diff --git a/cts/cts b/cts/cts.in
similarity index 97%
rename from cts/cts
rename to cts/cts.in
index 5a2ee0c47..9ff107c66 100755
--- a/cts/cts
+++ b/cts/cts.in
@@ -1,4 +1,10 @@
-#!/bin/bash
+#!@BASH_PATH
+#
+# Copyright 2012-2018 Andrew Beekhof <andrew@beekhof.net>
+#
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
+#
if [ -e $PWD/cts/CTSlab.py ]; then
cts_root=$PWD/cts
--
2.17.0

View File

@ -0,0 +1,104 @@
From 25698bc62f4b1bf14112012809e1c70b57a44cd9 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 14:05:55 -0500
Subject: [PATCH 05/17] Test: cts: don't use readlink -e unless supported
BSD readlink doesn't
---
cts/cts-cli.in | 9 ++++++++-
cts/cts-pengine.in | 32 ++++++++++++++------------------
cts/cts-regression.in | 9 ++++++++-
3 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/cts/cts-cli.in b/cts/cts-cli.in
index e62e5e2fe..365f4b10b 100755
--- a/cts/cts-cli.in
+++ b/cts/cts-cli.in
@@ -15,8 +15,15 @@ Options:
-v, --valgrind Run all commands under valgrind
-s Save actual output as expected output"
+# If readlink supports -e (i.e. GNU), use it
+readlink -e / >/dev/null 2>/dev/null
+if [ $? -eq 0 ]; then
+ test_home="$(dirname $(readlink -e $0))"
+else
+ test_home="$(dirname $0)"
+fi
+
: ${shadow=cts-cli}
-test_home="$(dirname $(readlink -e $0))"
shadow_dir=$(mktemp -td cts-cli.shadow.XXXXXXXXXX)
num_errors=0
num_passed=0
diff --git a/cts/cts-pengine.in b/cts/cts-pengine.in
index 905354db2..fb0952580 100644
--- a/cts/cts-pengine.in
+++ b/cts/cts-pengine.in
@@ -1,21 +1,10 @@
#!@BASH_PATH@
-
- # Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public
- # License as published by the Free Software Foundation; either
- # version 2 of the License, or (at your option) any later version.
- #
- # This software is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public
- # License along with this library; if not, write to the Free Software
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- #
+#
+# Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
+#
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
+#
USAGE_TEXT="Usage: cts-pengine [<options>]
Options:
@@ -34,7 +23,14 @@ SBINDIR="@sbindir@"
BUILDDIR="@abs_top_builddir@"
CRM_SCHEMA_DIRECTORY="@CRM_SCHEMA_DIRECTORY@"
-test_home=$(dirname $(readlink -e $0))
+# If readlink supports -e (i.e. GNU), use it
+readlink -e / >/dev/null 2>/dev/null
+if [ $? -eq 0 ]; then
+ test_home="$(dirname $(readlink -e $0))"
+else
+ test_home="$(dirname $0)"
+fi
+
io_dir="$test_home/pengine"
failed="$test_home/.regression.failed.diff"
test_binary=
diff --git a/cts/cts-regression.in b/cts/cts-regression.in
index 6c9931f79..e89394b69 100755
--- a/cts/cts-regression.in
+++ b/cts/cts-regression.in
@@ -24,7 +24,14 @@ Tests (default tests are 'pengine cli lrmd'):
fencing Fencing daemon
all Synonym for 'pengine cli lrmd fencing'"
-test_home="$(dirname $(readlink -e $0))"
+# If readlink supports -e (i.e. GNU), use it
+readlink -e / >/dev/null 2>/dev/null
+if [ $? -eq 0 ]; then
+ test_home="$(dirname $(readlink -e $0))"
+else
+ test_home="$(dirname $0)"
+fi
+
valgrind=""
verbose=""
tests=""
--
2.17.0

View File

@ -0,0 +1,511 @@
From c7abf9bc0b3596b41981ee10af60c24a68287e78 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 14:15:23 -0500
Subject: [PATCH 06/17] Refactor: libcrmcommon: move PID functions to own file
Line counts before:
1515 lib/common/utils.c
and after:
1353 lib/common/utils.c
183 lib/common/pid.c
---
include/crm/common/internal.h | 26 ++---
include/crm_internal.h | 23 +----
lib/common/Makefile.am | 19 +---
lib/common/pid.c | 183 ++++++++++++++++++++++++++++++++++
lib/common/utils.c | 162 ------------------------------
5 files changed, 201 insertions(+), 212 deletions(-)
create mode 100644 lib/common/pid.c
diff --git a/include/crm/common/internal.h b/include/crm/common/internal.h
index 076b9f60b..064e983b6 100644
--- a/include/crm/common/internal.h
+++ b/include/crm/common/internal.h
@@ -1,20 +1,8 @@
/*
- * Copyright (C) 2015
- * Andrew Beekhof <andrew@beekhof.net>
+ * Copyright 2015-2018 Andrew Beekhof <andrew@beekhof.net>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * This source code is licensed under the GNU Lesser General Public License
+ * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef CRM_COMMON_INTERNAL__H
@@ -59,6 +47,14 @@ void crm_schema_init(void);
void crm_schema_cleanup(void);
+/* internal functions related to process IDs (from pid.c) */
+
+int crm_pid_active(long pid, const char *daemon);
+long crm_pidfile_inuse(const char *filename, long mypid, const char *daemon);
+long crm_read_pidfile(const char *filename);
+int crm_lock_pidfile(const char *filename, const char *name);
+
+
/* internal generic string functions (from strings.c) */
long long crm_int_helper(const char *text, char **end_text);
diff --git a/include/crm_internal.h b/include/crm_internal.h
index 4c6fb0d4a..78d947905 100644
--- a/include/crm_internal.h
+++ b/include/crm_internal.h
@@ -1,22 +1,8 @@
-/* crm_internal.h */
-
/*
- * Copyright (C) 2006 - 2008
- * Andrew Beekhof <andrew@beekhof.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
+ * Copyright 2006-2018 Andrew Beekhof <andrew@beekhof.net>
*
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * This source code is licensed under the GNU Lesser General Public License
+ * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#ifndef CRM_INTERNAL__H
@@ -141,7 +127,6 @@ extern int node_score_green;
extern int node_score_yellow;
/* Assorted convenience functions */
-int crm_pid_active(long pid, const char *daemon);
void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile);
/* from operations.c */
@@ -251,8 +236,6 @@ void strip_text_nodes(xmlNode * xml);
void pcmk_panic(const char *origin);
void sysrq_init(void);
pid_t pcmk_locate_sbd(void);
-long crm_pidfile_inuse(const char *filename, long mypid, const char *daemon);
-long crm_read_pidfile(const char *filename);
# define crm_config_err(fmt...) { crm_config_error = TRUE; crm_err(fmt); }
# define crm_config_warn(fmt...) { crm_config_warning = TRUE; crm_warn(fmt); }
diff --git a/lib/common/Makefile.am b/lib/common/Makefile.am
index 1fce0b927..7546fe9fc 100644
--- a/lib/common/Makefile.am
+++ b/lib/common/Makefile.am
@@ -1,19 +1,8 @@
#
-# Copyright (C) 2004 Andrew Beekhof
+# Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
include $(top_srcdir)/Makefile.common
@@ -40,7 +29,7 @@ libcrmcommon_la_LIBADD = @LIBADD_DL@ $(GNUTLSLIBS)
libcrmcommon_la_SOURCES = compat.c digest.c ipc.c io.c procfs.c utils.c xml.c \
iso8601.c remote.c mainloop.c logging.c watchdog.c \
schemas.c strings.c xpath.c attrd_client.c alerts.c \
- operations.c results.c
+ operations.c pid.c results.c
if BUILD_CIBSECRETS
libcrmcommon_la_SOURCES += cib_secrets.c
endif
diff --git a/lib/common/pid.c b/lib/common/pid.c
new file mode 100644
index 000000000..803799e64
--- /dev/null
+++ b/lib/common/pid.c
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
+ *
+ * This source code is licensed under the GNU Lesser General Public License
+ * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
+ */
+
+#include <crm_internal.h>
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include <crm/crm.h>
+
+int
+crm_pid_active(long pid, const char *daemon)
+{
+ static int have_proc_pid = 0;
+
+ if (have_proc_pid == 0) {
+ char proc_path[PATH_MAX], exe_path[PATH_MAX];
+
+ // Make sure pid hasn't been reused by another process
+ snprintf(proc_path, sizeof(proc_path), "/proc/%lu/exe",
+ (long unsigned int)getpid());
+
+ have_proc_pid = 1;
+ if (readlink(proc_path, exe_path, PATH_MAX - 1) < 0) {
+ have_proc_pid = -1;
+ }
+ }
+
+ if (pid <= 0) {
+ return -1;
+
+ } else if ((kill(pid, 0) < 0) && (errno == ESRCH)) {
+ return 0;
+
+ } else if ((daemon == NULL) || (have_proc_pid == -1)) {
+ return 1;
+
+ } else {
+ int rc = 0;
+ char proc_path[PATH_MAX], exe_path[PATH_MAX], myexe_path[PATH_MAX];
+
+ // Make sure pid hasn't been reused by another process
+ snprintf(proc_path, sizeof(proc_path), "/proc/%ld/exe", pid);
+
+ rc = readlink(proc_path, exe_path, PATH_MAX - 1);
+ if ((rc < 0) && (errno == EACCES)) {
+ crm_perror(LOG_INFO, "Could not read from %s", proc_path);
+ return 1;
+ } else if (rc < 0) {
+ crm_perror(LOG_ERR, "Could not read from %s", proc_path);
+ return 0;
+ }
+
+ exe_path[rc] = 0;
+
+ if (daemon[0] != '/') {
+ rc = snprintf(myexe_path, sizeof(proc_path), CRM_DAEMON_DIR"/%s",
+ daemon);
+ myexe_path[rc] = 0;
+ } else {
+ rc = snprintf(myexe_path, sizeof(proc_path), "%s", daemon);
+ myexe_path[rc] = 0;
+ }
+
+ if (strcmp(exe_path, myexe_path) == 0) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#define LOCKSTRLEN 11
+
+long
+crm_read_pidfile(const char *filename)
+{
+ int fd;
+ struct stat sbuf;
+ long pid = -ENOENT;
+ char buf[LOCKSTRLEN + 1];
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ goto bail;
+ }
+
+ if ((fstat(fd, &sbuf) >= 0) && (sbuf.st_size < LOCKSTRLEN)) {
+ sleep(2); /* if someone was about to create one,
+ * give'm a sec to do so
+ */
+ }
+
+ if (read(fd, buf, sizeof(buf)) < 1) {
+ goto bail;
+ }
+
+ if (sscanf(buf, "%ld", &pid) > 0) {
+ if (pid <= 0) {
+ pid = -ESRCH;
+ } else {
+ crm_trace("Got pid %lu from %s\n", pid, filename);
+ }
+ }
+
+ bail:
+ if (fd >= 0) {
+ close(fd);
+ }
+ return pid;
+}
+
+long
+crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
+{
+ long pid = crm_read_pidfile(filename);
+
+ if (pid < 2) {
+ // Invalid pid
+ pid = -ENOENT;
+ unlink(filename);
+
+ } else if (mypid && (pid == mypid)) {
+ // In use by us
+ pid = pcmk_ok;
+
+ } else if (crm_pid_active(pid, daemon) == FALSE) {
+ // Contains a stale value
+ unlink(filename);
+ pid = -ENOENT;
+
+ } else if (mypid && (pid != mypid)) {
+ // Locked by existing process
+ pid = -EEXIST;
+ }
+
+ return pid;
+}
+
+int
+crm_lock_pidfile(const char *filename, const char *name)
+{
+ long mypid = 0;
+ int fd = 0;
+ int rc = 0;
+ char buf[LOCKSTRLEN + 2];
+
+ mypid = (unsigned long) getpid();
+
+ rc = crm_pidfile_inuse(filename, 0, name);
+ if (rc == -ENOENT) {
+ // Exists, but the process is not active
+
+ } else if (rc != pcmk_ok) {
+ // Locked by existing process
+ return rc;
+ }
+
+ fd = open(filename, O_CREAT | O_WRONLY | O_EXCL, 0644);
+ if (fd < 0) {
+ return -errno;
+ }
+
+ snprintf(buf, sizeof(buf), "%*ld\n", LOCKSTRLEN - 1, mypid);
+ rc = write(fd, buf, LOCKSTRLEN);
+ close(fd);
+
+ if (rc != LOCKSTRLEN) {
+ crm_perror(LOG_ERR, "Incomplete write to %s", filename);
+ return -errno;
+ }
+
+ return crm_pidfile_inuse(filename, mypid, name);
+}
diff --git a/lib/common/utils.c b/lib/common/utils.c
index 582838e46..07ba1b7d1 100644
--- a/lib/common/utils.c
+++ b/lib/common/utils.c
@@ -681,168 +681,6 @@ crm_abort(const char *file, const char *function, int line,
crm_perror(LOG_ERR, "Cannot wait on forked child %d", pid);
}
-int
-crm_pid_active(long pid, const char *daemon)
-{
- static int have_proc_pid = 0;
-
- if(have_proc_pid == 0) {
- char proc_path[PATH_MAX], exe_path[PATH_MAX];
-
- /* check to make sure pid hasn't been reused by another process */
- snprintf(proc_path, sizeof(proc_path), "/proc/%lu/exe", (long unsigned int)getpid());
-
- have_proc_pid = 1;
- if(readlink(proc_path, exe_path, PATH_MAX - 1) < 0) {
- have_proc_pid = -1;
- }
- }
-
- if (pid <= 0) {
- return -1;
-
- } else if (kill(pid, 0) < 0 && errno == ESRCH) {
- return 0;
-
- } else if(daemon == NULL || have_proc_pid == -1) {
- return 1;
-
- } else {
- int rc = 0;
- char proc_path[PATH_MAX], exe_path[PATH_MAX], myexe_path[PATH_MAX];
-
- /* check to make sure pid hasn't been reused by another process */
- snprintf(proc_path, sizeof(proc_path), "/proc/%ld/exe", pid);
-
- rc = readlink(proc_path, exe_path, PATH_MAX - 1);
- if (rc < 0 && errno == EACCES) {
- crm_perror(LOG_INFO, "Could not read from %s", proc_path);
- return 1;
- } else if (rc < 0) {
- crm_perror(LOG_ERR, "Could not read from %s", proc_path);
- return 0;
- }
-
-
- exe_path[rc] = 0;
-
- if(daemon[0] != '/') {
- rc = snprintf(myexe_path, sizeof(proc_path), CRM_DAEMON_DIR"/%s", daemon);
- myexe_path[rc] = 0;
- } else {
- rc = snprintf(myexe_path, sizeof(proc_path), "%s", daemon);
- myexe_path[rc] = 0;
- }
-
- if (strcmp(exe_path, myexe_path) == 0) {
- return 1;
- }
- }
-
- return 0;
-}
-
-#define LOCKSTRLEN 11
-
-long
-crm_read_pidfile(const char *filename)
-{
- int fd;
- struct stat sbuf;
- long pid = -ENOENT;
- char buf[LOCKSTRLEN + 1];
-
- if ((fd = open(filename, O_RDONLY)) < 0) {
- goto bail;
- }
-
- if (fstat(fd, &sbuf) >= 0 && sbuf.st_size < LOCKSTRLEN) {
- sleep(2); /* if someone was about to create one,
- * give'm a sec to do so
- */
- }
-
- if (read(fd, buf, sizeof(buf)) < 1) {
- goto bail;
- }
-
- if (sscanf(buf, "%ld", &pid) > 0) {
- if (pid <= 0) {
- pid = -ESRCH;
- } else {
- crm_trace("Got pid %lu from %s\n", pid, filename);
- }
- }
-
- bail:
- if (fd >= 0) {
- close(fd);
- }
- return pid;
-}
-
-long
-crm_pidfile_inuse(const char *filename, long mypid, const char *daemon)
-{
- long pid = crm_read_pidfile(filename);
-
- if (pid < 2) {
- /* Invalid pid */
- pid = -ENOENT;
- unlink(filename);
-
- } else if (mypid && pid == mypid) {
- /* In use by us */
- pid = pcmk_ok;
-
- } else if (crm_pid_active(pid, daemon) == FALSE) {
- /* Contains a stale value */
- unlink(filename);
- pid = -ENOENT;
-
- } else if (mypid && pid != mypid) {
- /* locked by existing process - give up */
- pid = -EEXIST;
- }
-
- return pid;
-}
-
-static int
-crm_lock_pidfile(const char *filename, const char *name)
-{
- long mypid = 0;
- int fd = 0, rc = 0;
- char buf[LOCKSTRLEN + 2];
-
- mypid = (unsigned long)getpid();
-
- rc = crm_pidfile_inuse(filename, 0, name);
- if (rc == -ENOENT) {
- /* exists but the process is not active */
-
- } else if (rc != pcmk_ok) {
- /* locked by existing process - give up */
- return rc;
- }
-
- if ((fd = open(filename, O_CREAT | O_WRONLY | O_EXCL, 0644)) < 0) {
- /* Hmmh, why did we fail? Anyway, nothing we can do about it */
- return -errno;
- }
-
- snprintf(buf, sizeof(buf), "%*ld\n", LOCKSTRLEN - 1, mypid);
- rc = write(fd, buf, LOCKSTRLEN);
- close(fd);
-
- if (rc != LOCKSTRLEN) {
- crm_perror(LOG_ERR, "Incomplete write to %s", filename);
- return -errno;
- }
-
- return crm_pidfile_inuse(filename, mypid, name);
-}
-
void
crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile)
{
--
2.17.0

View File

@ -0,0 +1,66 @@
From 07f7ab1d805b7508889c9298d2ee1b2a44836ab9 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 14:23:27 -0500
Subject: [PATCH 07/17] Refactor: libcrmcommon: shuffle some internal
declarations around
trying to keep all internal header stuff for libcrmcommon in
include/crm/common/internal.h
---
include/crm/common/internal.h | 17 +++++++++++++++++
include/crm_internal.h | 11 -----------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/include/crm/common/internal.h b/include/crm/common/internal.h
index 064e983b6..4aa0c49c6 100644
--- a/include/crm/common/internal.h
+++ b/include/crm/common/internal.h
@@ -55,6 +55,23 @@ long crm_read_pidfile(const char *filename);
int crm_lock_pidfile(const char *filename, const char *name);
+/* interal functions related to resource operations (from operations.c) */
+
+char *generate_op_key(const char *rsc_id, const char *op_type,
+ guint interval_ms);
+char *generate_notify_key(const char *rsc_id, const char *notify_type,
+ const char *op_type);
+char *generate_transition_magic(const char *transition_key, int op_status,
+ int op_rc);
+char *generate_transition_key(int action, int transition_id, int target_rc,
+ const char *node);
+void filter_action_parameters(xmlNode *param_set, const char *version);
+xmlNode *create_operation_update(xmlNode *parent, lrmd_event_data_t *event,
+ const char *caller_version, int target_rc,
+ const char *node, const char *origin,
+ int level);
+
+
/* internal generic string functions (from strings.c) */
long long crm_int_helper(const char *text, char **end_text);
diff --git a/include/crm_internal.h b/include/crm_internal.h
index 78d947905..63dca974a 100644
--- a/include/crm_internal.h
+++ b/include/crm_internal.h
@@ -129,17 +129,6 @@ extern int node_score_yellow;
/* Assorted convenience functions */
void crm_make_daemon(const char *name, gboolean daemonize, const char *pidfile);
-/* from operations.c */
-char *generate_op_key(const char *rsc_id, const char *op_type, guint interval_ms);
-char *generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type);
-char *generate_transition_magic(const char *transition_key, int op_status, int op_rc);
-char *generate_transition_key(int action, int transition_id, int target_rc, const char *node);
-void filter_action_parameters(xmlNode *param_set, const char *version);
-xmlNode *create_operation_update(xmlNode *parent, lrmd_event_data_t *event,
- const char *caller_version, int target_rc,
- const char *node, const char *origin,
- int level);
-
// printf-style format to create operation ID from resource, action, interval
#define CRM_OP_FMT "%s_%s_%u"
--
2.17.0

View File

@ -0,0 +1,29 @@
From 720e8bc0524e436eefb8167bc3aff4b4d795f02c Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 15:20:01 -0500
Subject: [PATCH 08/17] High: crmd: delete resource from lrmd when appropriate
Regression introduced in e8802834 (2.0.0-rc2): a missing return value check
meant that crmd would always delete resource from its LRM state only, and
not from the lrmd itself. As a side effect, this also introduced a memory leak
when deleting a resource.
---
crmd/lrm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crmd/lrm.c b/crmd/lrm.c
index 7d4f05748..90300334d 100644
--- a/crmd/lrm.c
+++ b/crmd/lrm.c
@@ -1820,7 +1820,7 @@ do_lrm_invoke(long long action,
PCMK_OCF_CONNECTION_DIED);
return;
- } else if (!create_rsc) {
+ } else if ((rc < 0) && !create_rsc) {
/* Delete of malformed or nonexistent resource
* (deleting something that does not exist is a success)
*/
--
2.17.0

View File

@ -0,0 +1,49 @@
From 621bea158d57dd5c2f9ccc1ebe2f5978d5b638b6 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 17:49:49 -0500
Subject: [PATCH 09/17] Test: cts-cli: update expected results for recent
changes
should have been done with 0a21e9ca3
---
cts/cli/regression.acls.exp | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/cts/cli/regression.acls.exp b/cts/cli/regression.acls.exp
index cc3163621..0bef6f447 100644
--- a/cts/cli/regression.acls.exp
+++ b/cts/cli/regression.acls.exp
@@ -1182,8 +1182,8 @@ Call failed: Permission denied
* Passed: cibadmin - bob: Replace - delete attribute (allow)
- !#!#!#!#! Upgrading to pacemaker-2.0 and retesting !#!#!#!#!
-=#=#=#= Begin test: root: Upgrade to pacemaker-2.0 =#=#=#=
+ !#!#!#!#! Upgrading to latest CIB schema and re-testing !#!#!#!#!
+=#=#=#= Begin test: root: Upgrade to latest CIB schema =#=#=#=
__xml_acl_post_process: Creation of acl_permission=observer-read-1 is allowed
__xml_acl_post_process: Creation of acl_permission=observer-write-1 is allowed
__xml_acl_post_process: Creation of acl_permission=observer-write-2 is allowed
@@ -1206,7 +1206,7 @@ __xml_acl_post_process: Creation of role=auto-betteridea is allowed
__xml_acl_post_process: Creation of acl_role=auto-betteridea is allowed
__xml_acl_post_process: Creation of acl_permission=betteridea-nothing is allowed
__xml_acl_post_process: Creation of acl_permission=betteridea-resources is allowed
-=#=#=#= Current cib after: root: Upgrade to pacemaker-2.0 =#=#=#=
+=#=#=#= Current cib after: root: Upgrade to latest CIB schema =#=#=#=
<cib epoch="2" num_updates="0" admin_epoch="1">
<configuration>
<crm_config>
@@ -1260,8 +1260,8 @@ __xml_acl_post_process: Creation of acl_permission=betteridea-resources is allow
</configuration>
<status/>
</cib>
-=#=#=#= End test: root: Upgrade to pacemaker-2.0 - OK (0) =#=#=#=
-* Passed: cibadmin - root: Upgrade to pacemaker-2.0
+=#=#=#= End test: root: Upgrade to latest CIB schema - OK (0) =#=#=#=
+* Passed: cibadmin - root: Upgrade to latest CIB schema
=#=#=#= Begin test: unknownguy: Query configuration =#=#=#=
Call failed: Permission denied
=#=#=#= End test: unknownguy: Query configuration - Insufficient privileges (4) =#=#=#=
--
2.17.0

View File

@ -0,0 +1,106 @@
From ea62ae820b0fa71e5f582f844db21a79db268c1e Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Mon, 9 Apr 2018 17:50:23 -0500
Subject: [PATCH 10/17] Test: cts-cli,cts-pengine: avoid sed -i
"sed -i" isn't POSIX, and its usage differs in GNU sed and BSD sed,
so avoid it in regression tests.
It should be handled similarly in other places where it remains, but this will
help get the BSD build working.
---
cts/cts-cli.in | 25 +++++++++----------------
cts/cts-pengine.in | 13 ++++++++++++-
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/cts/cts-cli.in b/cts/cts-cli.in
index 365f4b10b..38045b944 100755
--- a/cts/cts-cli.in
+++ b/cts/cts-cli.in
@@ -433,18 +433,6 @@ function test_dates() {
test_assert $CRM_EX_OK 0
}
-function get_epoch() {
- CIB_user=root CIB_file=$1 CIB_shadow="" cibadmin -Q | head -n 1 | sed -e 's/.* epoch=\"\([0-9]*\).*/\1/'
-}
-
-function restore_epoch() {
- infile=$1; shift
- old=$1; shift
- new=$(get_epoch $infile)
-
- sed -i 's/epoch=.$old/epoch=\"$new/g' $infile
-}
-
function test_acl_loop() {
local TMPXML="$1"
@@ -693,8 +681,11 @@ EOF
test_assert $CRM_EX_OK
SHADOWPATH="$(crm_shadow --file)"
- sed -i 's/epoch=.2/epoch=\"6/g' "$SHADOWPATH"
- sed -i 's/admin_epoch=.1/admin_epoch=\"0/g' "$SHADOWPATH"
+ # sed -i isn't portable :-(
+ cp -p "$SHADOWPATH" "${SHADOWPATH}.$$" # to keep permissions
+ sed -e 's/epoch=.2/epoch=\"6/g' -e 's/admin_epoch=.1/admin_epoch=\"0/g' \
+ "$SHADOWPATH" > "${SHADOWPATH}.$$"
+ mv -- "${SHADOWPATH}.$$" "$SHADOWPATH"
test_acl_loop "$TMPXML"
@@ -845,7 +836,8 @@ for t in $tests; do
eval TMPFILE_$t="$TMPFILE"
test_$t > "$TMPFILE"
- sed -i -e 's/cib-last-written.*>/>/'\
+ # sed -i isn't portable :-(
+ sed -e 's/cib-last-written.*>/>/'\
-e 's/ last-run=\"[0-9]*\"//'\
-e 's/crm_feature_set="[^"]*" //'\
-e 's/validate-with="[^"]*" //'\
@@ -859,7 +851,8 @@ for t in $tests; do
-e 's/schemas\.c:\([0-9][0-9]*\)/schemas.c:NNN/' \
-e 's/constraints\.:\([0-9][0-9]*\)/constraints.:NNN/' \
-e 's/\(validation ([0-9][0-9]* of \)[0-9][0-9]*\().*\)/\1X\2/' \
- "$TMPFILE"
+ "$TMPFILE" > "${TMPFILE}.$$"
+ mv -- "${TMPFILE}.$$" "$TMPFILE"
if [ $do_save -eq 1 ]; then
cp "$TMPFILE" $test_home/cli/regression.$t.exp
diff --git a/cts/cts-pengine.in b/cts/cts-pengine.in
index fb0952580..060708439 100644
--- a/cts/cts-pengine.in
+++ b/cts/cts-pengine.in
@@ -84,6 +84,17 @@ function show_test() {
printf " Test %-25s $*\n" "$name:"
}
+# Normalize policy engine output for comparison
+normalize() {
+ for NORMALIZE_FILE in "$@"; do
+ # sed -i is not portable :-(
+ sed -e 's/crm_feature_set="[^"]*"//' \
+ -e 's/batch-limit="[0-9]*"//' \
+ "$NORMALIZE_FILE" > "${NORMALIZE_FILE}.$$"
+ mv -- "${NORMALIZE_FILE}.$$" "$NORMALIZE_FILE"
+ done
+}
+
info "Test home is:\t$test_home"
create_mode="false"
@@ -332,7 +343,7 @@ do_test() {
rm -f $dot_output
fi
- sed -i -e 's/crm_feature_set="[^"]*"//' -e 's/batch-limit="[0-9]*"//' $expected $output
+ normalize "$expected" "$output"
diff $diff_opts $expected $output >/dev/null
rc2=$?
if [ $rc2 -ne 0 ]; then
--
2.17.0

View File

@ -0,0 +1,171 @@
From 560281f7479d3526fd974a0c21c09ae930151df1 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 10 Apr 2018 10:43:35 -0500
Subject: [PATCH 11/17] Build: tools: only link against necessary libraries
COMMONLIBS was not
---
tools/Makefile.am | 103 ++++++++++++++++++++++------------------------
1 file changed, 50 insertions(+), 53 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index f1cc92ed2..24b1d8bdd 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,19 +1,8 @@
#
-# Copyright (C) 2004-2009 Andrew Beekhof
+# Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# This source code is licensed under the GNU General Public License version 2
+# or later (GPLv2+) WITHOUT ANY WARRANTY.
#
include $(top_srcdir)/Makefile.common
@@ -21,11 +10,6 @@ if BUILD_SYSTEMD
systemdunit_DATA = crm_mon.service
endif
-COMMONLIBS = \
- $(top_builddir)/lib/common/libcrmcommon.la \
- $(top_builddir)/lib/cib/libcib.la \
- $(CURSESLIBS) $(CLUSTERLIBS)
-
noinst_HEADERS = crm_resource.h fake_transition.h
pcmkdir = $(datadir)/$(PACKAGE)
@@ -52,71 +36,84 @@ endif
MAN8DEPS = crm_attribute crm_node
crmadmin_SOURCES = crmadmin.c
-crmadmin_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
- $(COMMONLIBS) $(CLUSTERLIBS)
+crmadmin_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la \
+ $(CLUSTERLIBS)
crm_error_SOURCES = crm_error.c
-crm_error_LDADD = $(COMMONLIBS)
+crm_error_LDADD = $(top_builddir)/lib/common/libcrmcommon.la
cibadmin_SOURCES = cibadmin.c
-cibadmin_LDADD = $(COMMONLIBS)
+cibadmin_LDADD = $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
crm_shadow_SOURCES = cib_shadow.c
-crm_shadow_LDADD = $(COMMONLIBS)
+crm_shadow_LDADD = $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
crm_node_SOURCES = crm_node.c
-crm_node_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la \
- $(COMMONLIBS) $(CLUSTERLIBS)
+crm_node_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la \
+ $(CLUSTERLIBS)
crm_simulate_SOURCES = crm_simulate.c fake_transition.c
crm_simulate_CFLAGS = -I$(top_srcdir)/pengine
-crm_simulate_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
- $(top_builddir)/pengine/libpengine.la \
- $(top_builddir)/lib/cib/libcib.la \
- $(top_builddir)/lib/lrmd/liblrmd.la \
- $(top_builddir)/lib/transition/libtransitioner.la \
- $(COMMONLIBS)
+crm_simulate_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
+ $(top_builddir)/pengine/libpengine.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/lrmd/liblrmd.la \
+ $(top_builddir)/lib/transition/libtransitioner.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
crm_diff_SOURCES = crm_diff.c
-crm_diff_LDADD = $(COMMONLIBS)
+crm_diff_LDADD = $(top_builddir)/lib/common/libcrmcommon.la
crm_mon_SOURCES = crm_mon.c
-crm_mon_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
- $(top_builddir)/lib/fencing/libstonithd.la \
- $(top_builddir)/pengine/libpengine.la \
- $(COMMONLIBS)
+crm_mon_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
+ $(top_builddir)/lib/fencing/libstonithd.la \
+ $(top_builddir)/pengine/libpengine.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la \
+ $(CURSESLIBS)
# Arguments could be made that this should live in crm/pengine
crm_verify_SOURCES = crm_verify.c
crm_verify_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
- $(top_builddir)/pengine/libpengine.la \
- $(COMMONLIBS)
+ $(top_builddir)/pengine/libpengine.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
crm_attribute_SOURCES = crm_attribute.c
-crm_attribute_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la $(COMMONLIBS)
+crm_attribute_LDADD = $(top_builddir)/lib/cluster/libcrmcluster.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
crm_resource_SOURCES = crm_resource.c crm_resource_ban.c crm_resource_runtime.c crm_resource_print.c fake_transition.c
crm_resource_CFLAGS = -I$(top_srcdir)/pengine
-crm_resource_LDADD = $(top_builddir)/lib/pengine/libpe_rules.la \
- $(top_builddir)/lib/lrmd/liblrmd.la \
- $(top_builddir)/lib/services/libcrmservice.la \
- $(top_builddir)/lib/pengine/libpe_status.la \
- $(top_builddir)/pengine/libpengine.la \
- $(top_builddir)/lib/transition/libtransitioner.la \
- $(COMMONLIBS)
+crm_resource_LDADD = $(top_builddir)/lib/pengine/libpe_rules.la \
+ $(top_builddir)/lib/lrmd/liblrmd.la \
+ $(top_builddir)/lib/services/libcrmservice.la \
+ $(top_builddir)/lib/pengine/libpe_status.la \
+ $(top_builddir)/pengine/libpengine.la \
+ $(top_builddir)/lib/transition/libtransitioner.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
iso8601_SOURCES = test.iso8601.c
-iso8601_LDADD = $(COMMONLIBS)
+iso8601_LDADD = $(top_builddir)/lib/common/libcrmcommon.la
attrd_updater_SOURCES = attrd_updater.c
-attrd_updater_LDADD = $(COMMONLIBS)
+attrd_updater_LDADD = $(top_builddir)/lib/common/libcrmcommon.la
crm_ticket_SOURCES = crm_ticket.c
-crm_ticket_LDADD = $(top_builddir)/lib/pengine/libpe_rules.la \
- $(top_builddir)/lib/pengine/libpe_status.la \
- $(top_builddir)/pengine/libpengine.la \
- $(COMMONLIBS)
+crm_ticket_LDADD = $(top_builddir)/lib/pengine/libpe_rules.la \
+ $(top_builddir)/lib/pengine/libpe_status.la \
+ $(top_builddir)/pengine/libpengine.la \
+ $(top_builddir)/lib/cib/libcib.la \
+ $(top_builddir)/lib/common/libcrmcommon.la
if BUILD_SERVICELOG
notifyServicelogEvent_SOURCES = notifyServicelogEvent.c
--
2.17.0

View File

@ -0,0 +1,268 @@
From b8745b20b966076f1218d9a3c476ec7537330122 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 10 Apr 2018 12:25:25 -0500
Subject: [PATCH 12/17] Low: fencing: free dynamic memory at stonithd shutdown
No serious effect since it's shutting down anyway, but clean up for the sake of
completeness, and making memory analysis happy
---
fencing/commands.c | 59 +++++++++++++++++++++++++++++++++++++++++-----
fencing/internal.h | 11 +++++----
fencing/main.c | 34 +++++++++-----------------
fencing/remote.c | 29 +++++++++++------------
4 files changed, 85 insertions(+), 48 deletions(-)
diff --git a/fencing/commands.c b/fencing/commands.c
index 809be518c..fe624da7d 100644
--- a/fencing/commands.c
+++ b/fencing/commands.c
@@ -485,7 +485,7 @@ schedule_stonith_command(async_command_t * cmd, stonith_device_t * device)
}
}
-void
+static void
free_device(gpointer data)
{
GListPtr gIter = NULL;
@@ -514,6 +514,23 @@ free_device(gpointer data)
free(device);
}
+void free_device_list()
+{
+ if (device_list != NULL) {
+ g_hash_table_destroy(device_list);
+ device_list = NULL;
+ }
+}
+
+void
+init_device_list()
+{
+ if (device_list == NULL) {
+ device_list = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL,
+ free_device);
+ }
+}
+
static GHashTable *
build_port_aliases(const char *hostmap, GListPtr * targets)
{
@@ -670,16 +687,28 @@ parse_host_list(const char *hosts)
GHashTable *metadata_cache = NULL;
+void
+free_metadata_cache() {
+ if (metadata_cache != NULL) {
+ g_hash_table_destroy(metadata_cache);
+ metadata_cache = NULL;
+ }
+}
+
+static void
+init_metadata_cache() {
+ if (metadata_cache == NULL) {
+ metadata_cache = crm_str_table_new();
+ }
+}
+
static xmlNode *
get_agent_metadata(const char *agent)
{
xmlNode *xml = NULL;
char *buffer = NULL;
- if(metadata_cache == NULL) {
- metadata_cache = crm_str_table_new();
- }
-
+ init_metadata_cache();
buffer = g_hash_table_lookup(metadata_cache, agent);
if(safe_str_eq(agent, STONITH_WATCHDOG_AGENT)) {
return NULL;
@@ -1228,7 +1257,7 @@ count_active_levels(stonith_topology_t * tp)
return count;
}
-void
+static void
free_topology_entry(gpointer data)
{
stonith_topology_t *tp = data;
@@ -1247,6 +1276,24 @@ free_topology_entry(gpointer data)
free(tp);
}
+void
+free_topology_list()
+{
+ if (topology != NULL) {
+ g_hash_table_destroy(topology);
+ topology = NULL;
+ }
+}
+
+void
+init_topology_list()
+{
+ if (topology == NULL) {
+ topology = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL,
+ free_topology_entry);
+ }
+}
+
char *stonith_level_key(xmlNode *level, int mode)
{
if(mode == -1) {
diff --git a/fencing/internal.h b/fencing/internal.h
index 9687b63c4..34d82c901 100644
--- a/fencing/internal.h
+++ b/fencing/internal.h
@@ -177,6 +177,13 @@ typedef struct stonith_topology_s {
} stonith_topology_t;
+void init_device_list(void);
+void free_device_list(void);
+void init_topology_list(void);
+void free_topology_list(void);
+void free_remote_op_list(void);
+void free_metadata_cache(void);
+
long long get_stonith_flag(const char *name);
void stonith_command(crm_client_t * client, uint32_t id, uint32_t flags,
@@ -218,10 +225,6 @@ void *create_remote_stonith_op(const char *client, xmlNode * request, gboolean p
int stonith_fence_history(xmlNode * msg, xmlNode ** output);
-void free_device(gpointer data);
-
-void free_topology_entry(gpointer data);
-
bool fencing_peer_active(crm_node_t *peer);
int stonith_manual_ack(xmlNode * msg, remote_fencing_op_t * op);
diff --git a/fencing/main.c b/fencing/main.c
index 7f0dad581..888f9605e 100644
--- a/fencing/main.c
+++ b/fencing/main.c
@@ -1,19 +1,8 @@
/*
- * Copyright (C) 2009 Andrew Beekhof <andrew@beekhof.net>
+ * Copyright 2009-2018 Andrew Beekhof <andrew@beekhof.net>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * This source code is licensed under the GNU General Public License version 2
+ * or later (GPLv2+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
@@ -532,11 +521,8 @@ fencing_topology_init()
const char *xpath = "//" XML_TAG_FENCING_LEVEL;
crm_trace("Full topology refresh");
-
- if(topology) {
- g_hash_table_destroy(topology);
- topology = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL, free_topology_entry);
- }
+ free_topology_list();
+ init_topology_list();
/* Grab everything */
xpathObj = xpath_search(local_cib, xpath);
@@ -1160,6 +1146,10 @@ stonith_cleanup(void)
crm_peer_destroy();
crm_client_cleanup();
+ free_remote_op_list();
+ free_topology_list();
+ free_device_list();
+ free_metadata_cache();
free(stonith_our_uname);
free_xml(local_cib);
}
@@ -1466,10 +1456,8 @@ main(int argc, char **argv)
stonith_our_uname = strdup("localhost");
}
-
- device_list = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL, free_device);
-
- topology = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL, free_topology_entry);
+ init_device_list();
+ init_topology_list();
if(stonith_watchdog_timeout_ms > 0) {
xmlNode *xml;
diff --git a/fencing/remote.c b/fencing/remote.c
index e1d1a5c66..a2b8bfb40 100644
--- a/fencing/remote.c
+++ b/fencing/remote.c
@@ -1,19 +1,8 @@
/*
- * Copyright (C) 2009 Andrew Beekhof <andrew@beekhof.net>
+ * Copyright 2009-2018 Andrew Beekhof <andrew@beekhof.net>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * This source code is licensed under the GNU General Public License version 2
+ * or later (GPLv2+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
@@ -82,7 +71,8 @@ typedef struct st_query_result_s {
GHashTable *devices;
} st_query_result_t;
-GHashTable *remote_op_list = NULL;
+static GHashTable *remote_op_list = NULL;
+
void call_remote_stonith(remote_fencing_op_t * op, st_query_result_t * peer);
static void remote_op_done(remote_fencing_op_t * op, xmlNode * data, int rc, int dup);
extern xmlNode *stonith_create_op(int call_id, const char *token, const char *op, xmlNode * data,
@@ -111,6 +101,15 @@ free_remote_query(gpointer data)
}
}
+void
+free_remote_op_list()
+{
+ if (remote_op_list != NULL) {
+ g_hash_table_destroy(remote_op_list);
+ remote_op_list = NULL;
+ }
+}
+
struct peer_count_data {
const remote_fencing_op_t *op;
gboolean verified_only;
--
2.17.0

View File

@ -0,0 +1,33 @@
From 13a7c5be972fbd5c00fa0ad3b832720c966e80cf Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 10 Apr 2018 15:19:11 -0500
Subject: [PATCH 13/17] Low: fencing: avoid memory leaks when freeing remote
operation
---
fencing/remote.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fencing/remote.c b/fencing/remote.c
index a2b8bfb40..42ca9a7e8 100644
--- a/fencing/remote.c
+++ b/fencing/remote.c
@@ -237,6 +237,7 @@ free_remote_op(gpointer data)
free(op->id);
free(op->action);
+ free(op->delegate);
free(op->target);
free(op->client_id);
free(op->client_name);
@@ -254,6 +255,7 @@ free_remote_op(gpointer data)
op->devices_list = NULL;
}
g_list_free_full(op->automatic_list, free);
+ g_list_free(op->duplicates);
free(op);
}
--
2.17.0

View File

@ -0,0 +1,25 @@
From c900353052e3db556443694c3b9fb86d55d202a3 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 10 Apr 2018 14:23:11 -0500
Subject: [PATCH 14/17] Low: libcrmcommon: fix memory leak in schema workaround
---
lib/common/schemas.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/common/schemas.c b/lib/common/schemas.c
index c3fff1e79..9222acba0 100644
--- a/lib/common/schemas.c
+++ b/lib/common/schemas.c
@@ -684,7 +684,7 @@ apply_transformation(xmlNode *xml, const char *transform, gboolean to_logs)
#if PCMK_SCHEMAS_EMERGENCY_XSLT != 0
emergency_res = xsltSaveResultToString(&emergency_result,
&emergency_txt_len, res, xslt);
- free(res);
+ xmlFreeDoc(res);
CRM_CHECK(emergency_res == 0, goto cleanup);
out = string2xml((const char *) emergency_result);
free(emergency_result);
--
2.17.0

View File

@ -0,0 +1,86 @@
From a70e665bea76d99ebb8809dd522dd2049c544fa7 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 10 Apr 2018 15:16:25 -0500
Subject: [PATCH 15/17] Low: libcrmcommon: free signal triggers when cleaning
up mainloop
Not really necessary, but cleans up memory at exit better
---
lib/common/mainloop.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/lib/common/mainloop.c b/lib/common/mainloop.c
index ba2f8d524..ce9f0ec3d 100644
--- a/lib/common/mainloop.c
+++ b/lib/common/mainloop.c
@@ -311,6 +311,17 @@ crm_signal(int sig, void (*dispatch) (int sig))
return TRUE;
}
+static void
+mainloop_destroy_signal_entry(int sig)
+{
+ crm_signal_t *tmp = crm_signals[sig];
+
+ crm_signals[sig] = NULL;
+
+ crm_trace("Destroying signal %d", sig);
+ mainloop_destroy_trigger((crm_trigger_t *) tmp);
+}
+
gboolean
mainloop_add_signal(int sig, void (*dispatch) (int sig))
{
@@ -348,11 +359,7 @@ mainloop_add_signal(int sig, void (*dispatch) (int sig))
crm_signals[sig]->signal = sig;
if (crm_signal(sig, mainloop_signal_handler) == FALSE) {
- crm_signal_t *tmp = crm_signals[sig];
-
- crm_signals[sig] = NULL;
-
- mainloop_destroy_trigger((crm_trigger_t *) tmp);
+ mainloop_destroy_signal_entry(sig);
return FALSE;
}
#if 0
@@ -372,8 +379,6 @@ mainloop_add_signal(int sig, void (*dispatch) (int sig))
gboolean
mainloop_destroy_signal(int sig)
{
- crm_signal_t *tmp = NULL;
-
if (sig >= NSIG || sig < 0) {
crm_err("Signal %d is out of range", sig);
return FALSE;
@@ -385,11 +390,7 @@ mainloop_destroy_signal(int sig)
} else if (crm_signals[sig] == NULL) {
return TRUE;
}
-
- crm_trace("Destroying signal %d", sig);
- tmp = crm_signals[sig];
- crm_signals[sig] = NULL;
- mainloop_destroy_trigger((crm_trigger_t *) tmp);
+ mainloop_destroy_signal_entry(sig);
return TRUE;
}
@@ -398,9 +399,13 @@ static qb_array_t *gio_map = NULL;
void
mainloop_cleanup(void)
{
- if(gio_map) {
+ if (gio_map) {
qb_array_free(gio_map);
}
+
+ for (int sig = 0; sig < NSIG; ++sig) {
+ mainloop_destroy_signal_entry(sig);
+ }
}
/*
--
2.17.0

View File

@ -0,0 +1,68 @@
From 1f916d3007d3e15d8306283e97714f6d7bd82125 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 11 Apr 2018 09:14:13 -0500
Subject: [PATCH 16/17] Build: Makefile: build and clean (but not install) CTS
by default
---
Makefile.am | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index f0f935dcf..4d5309a6e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,8 +23,14 @@ EXTRA_DIST = autogen.sh m4/gnulib-cache.m4
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure DRF/config-h.in \
DRF/stamp-h.in libtool.m4 ltdl.m4
-CORE = replace include lib mcp attrd pengine cib crmd fencing lrmd tools xml
-SUBDIRS = $(CORE) extra doc
+# Only these will get installed with a plain "make install"
+CORE_INSTALL = replace include lib mcp \
+ attrd pengine cib crmd fencing lrmd tools xml
+
+# Only these will get built with a plain "make" or "make clean"
+CORE = $(CORE_INSTALL) cts
+
+SUBDIRS = $(CORE) doc extra
AM_CPPFLAGS = -I$(top_srcdir)/include
@@ -33,9 +39,6 @@ doc_DATA = README.markdown COPYING
licensedir = $(docdir)/licenses/
license_DATA = $(wildcard licenses/*)
-# Test components
-SUBDIRS += cts
-
# Scratch file for ad-hoc testing
noinst_PROGRAMS = scratch
nodist_scratch_SOURCES = scratch.c
@@ -45,15 +48,19 @@ scratch.c:
echo 'int main(void){}' >$@
core:
- @echo "Building only core components: $(CORE)"
+ @echo "Building only core components and tests: $(CORE)"
list='$(CORE)'; for subdir in $$list; do echo "Building $$subdir"; $(MAKE) -C $$subdir all || exit 1; done
core-install:
- @echo "Installing only core components: $(CORE)"
- list='$(CORE)'; for subdir in $$list; do echo "Installing $$subdir"; $(MAKE) -C $$subdir install || exit 1; done
+ @echo "Installing only core components: $(CORE_INSTALL)"
+ list='$(CORE_INSTALL)'; \
+ for subdir in $$list; do \
+ echo "Installing $$subdir"; \
+ $(MAKE) -C $$subdir install || exit 1; \
+ done
core-clean:
- @echo "Cleaning only core components: $(CORE)"
+ @echo "Cleaning only core components and tests: $(CORE)"
list='$(CORE)'; for subdir in $$list; do echo "Cleaning $$subdir"; $(MAKE) -C $$subdir clean || exit 1; done
install-exec-local:
--
2.17.0

View File

@ -0,0 +1,196 @@
From 550a68817af8eaad45bfd001bba3782cba7e0d02 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 11 Apr 2018 10:35:31 -0500
Subject: [PATCH 17/17] Refactor: libcrmcommon: avoid "new" as variable name
confuses cppcheck
---
lib/common/xml.c | 69 +++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 33 deletions(-)
diff --git a/lib/common/xml.c b/lib/common/xml.c
index 7781d48a0..0bb64e5fb 100644
--- a/lib/common/xml.c
+++ b/lib/common/xml.c
@@ -4040,19 +4040,19 @@ apply_xml_diff(xmlNode *old_xml, xmlNode * diff, xmlNode **new_xml)
}
static void
-__xml_diff_object(xmlNode * old, xmlNode * new)
+__xml_diff_object(xmlNode *old_xml, xmlNode *new_xml)
{
xmlNode *cIter = NULL;
xmlAttr *pIter = NULL;
- CRM_CHECK(new != NULL, return);
- if(old == NULL) {
- crm_node_created(new);
- __xml_acl_post_process(new); /* Check creation is allowed */
+ CRM_CHECK(new_xml != NULL, return);
+ if (old_xml == NULL) {
+ crm_node_created(new_xml);
+ __xml_acl_post_process(new_xml); // Check creation is allowed
return;
} else {
- xml_private_t *p = new->_private;
+ xml_private_t *p = new_xml->_private;
if(p->flags & xpf_processed) {
/* Avoid re-comparing nodes */
@@ -4061,39 +4061,40 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
p->flags |= xpf_processed;
}
- for (pIter = crm_first_attr(new); pIter != NULL; pIter = pIter->next) {
+ for (pIter = crm_first_attr(new_xml); pIter != NULL; pIter = pIter->next) {
xml_private_t *p = pIter->_private;
/* Assume everything was just created and take it from there */
p->flags |= xpf_created;
}
- for (pIter = crm_first_attr(old); pIter != NULL; ) {
+ for (pIter = crm_first_attr(old_xml); pIter != NULL; ) {
xmlAttr *prop = pIter;
xml_private_t *p = NULL;
const char *name = (const char *)pIter->name;
- const char *old_value = crm_element_value(old, name);
- xmlAttr *exists = xmlHasProp(new, pIter->name);
+ const char *old_value = crm_element_value(old_xml, name);
+ xmlAttr *exists = xmlHasProp(new_xml, pIter->name);
pIter = pIter->next;
if(exists == NULL) {
- p = new->doc->_private;
+ p = new_xml->doc->_private;
/* Prevent the dirty flag being set recursively upwards */
clear_bit(p->flags, xpf_tracking);
- exists = xmlSetProp(new, (const xmlChar *)name, (const xmlChar *)old_value);
+ exists = xmlSetProp(new_xml, (const xmlChar *) name,
+ (const xmlChar *) old_value);
set_bit(p->flags, xpf_tracking);
p = exists->_private;
p->flags = 0;
- crm_trace("Lost %s@%s=%s", old->name, name, old_value);
- xml_remove_prop(new, name);
+ crm_trace("Lost %s@%s=%s", old_xml->name, name, old_value);
+ xml_remove_prop(new_xml, name);
} else {
int p_new = __xml_offset((xmlNode*)exists);
int p_old = __xml_offset((xmlNode*)prop);
- const char *value = crm_element_value(new, name);
+ const char *value = crm_element_value(new_xml, name);
p = exists->_private;
p->flags = (p->flags & ~xpf_created);
@@ -4102,16 +4103,18 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
/* Restore the original value, so we can call crm_xml_add(),
* which checks ACLs
*/
- char *vcopy = crm_element_value_copy(new, name);
+ char *vcopy = crm_element_value_copy(new_xml, name);
- crm_trace("Modified %s@%s %s->%s", old->name, name, old_value, vcopy);
- xmlSetProp(new, prop->name, (const xmlChar *)old_value);
- crm_xml_add(new, name, vcopy);
+ crm_trace("Modified %s@%s %s->%s",
+ old_xml->name, name, old_value, vcopy);
+ xmlSetProp(new_xml, prop->name, (const xmlChar *) old_value);
+ crm_xml_add(new_xml, name, vcopy);
free(vcopy);
} else if(p_old != p_new) {
- crm_info("Moved %s@%s (%d -> %d)", old->name, name, p_old, p_new);
- __xml_node_dirty(new);
+ crm_info("Moved %s@%s (%d -> %d)",
+ old_xml->name, name, p_old, p_new);
+ __xml_node_dirty(new_xml);
p->flags |= xpf_dirty|xpf_moved;
if(p_old > p_new) {
@@ -4126,21 +4129,21 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
}
}
- for (pIter = crm_first_attr(new); pIter != NULL; ) {
+ for (pIter = crm_first_attr(new_xml); pIter != NULL; ) {
xmlAttr *prop = pIter;
xml_private_t *p = pIter->_private;
pIter = pIter->next;
if(is_set(p->flags, xpf_created)) {
char *name = strdup((const char *)prop->name);
- char *value = crm_element_value_copy(new, name);
+ char *value = crm_element_value_copy(new_xml, name);
- crm_trace("Created %s@%s=%s", new->name, name, value);
+ crm_trace("Created %s@%s=%s", new_xml->name, name, value);
/* Remove plus create won't work as it will modify the relative attribute ordering */
- if(__xml_acl_check(new, name, xpf_acl_write)) {
+ if (__xml_acl_check(new_xml, name, xpf_acl_write)) {
crm_attr_dirty(prop);
} else {
- xmlUnsetProp(new, prop->name); /* Remove - change not allowed */
+ xmlUnsetProp(new_xml, prop->name); /* Remove - change not allowed */
}
free(value);
@@ -4148,9 +4151,9 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
}
}
- for (cIter = __xml_first_child(old); cIter != NULL; ) {
+ for (cIter = __xml_first_child(old_xml); cIter != NULL; ) {
xmlNode *old_child = cIter;
- xmlNode *new_child = find_element(new, cIter, TRUE);
+ xmlNode *new_child = find_element(new_xml, cIter, TRUE);
cIter = __xml_next(cIter);
if(new_child) {
@@ -4158,7 +4161,7 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
} else {
/* Create then free (which will check the acls if necessary) */
- xmlNode *candidate = add_node_copy(new, old_child);
+ xmlNode *candidate = add_node_copy(new_xml, old_child);
xmlNode *top = xmlDocGetRootElement(candidate->doc);
__xml_node_clean(candidate);
@@ -4166,7 +4169,7 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
/* Record the old position */
free_xml_with_position(candidate, __xml_offset(old_child));
- if (find_element(new, old_child, TRUE) == NULL) {
+ if (find_element(new_xml, old_child, TRUE) == NULL) {
xml_private_t *p = old_child->_private;
p->flags |= xpf_skip;
@@ -4174,9 +4177,9 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
}
}
- for (cIter = __xml_first_child(new); cIter != NULL; ) {
+ for (cIter = __xml_first_child(new_xml); cIter != NULL; ) {
xmlNode *new_child = cIter;
- xmlNode *old_child = find_element(old, cIter, TRUE);
+ xmlNode *old_child = find_element(old_xml, cIter, TRUE);
cIter = __xml_next(cIter);
if(old_child == NULL) {
@@ -4194,7 +4197,7 @@ __xml_diff_object(xmlNode * old, xmlNode * new)
crm_info("%s.%s moved from %d to %d",
new_child->name, ID(new_child), p_old, p_new);
- __xml_node_dirty(new);
+ __xml_node_dirty(new_xml);
p->flags |= xpf_moved;
if(p_old > p_new) {
--
2.17.0

View File

@ -0,0 +1,92 @@
From 889c0cdc0c592a7dee860bb6310a54bc8d33264e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 11 Apr 2018 16:49:40 +0200
Subject: [PATCH] Tests: cts-cli: fix thinko leading to system-wide shadow
files
In particular, building RPM package and triggering %check lead
to cts-cli trying to work with shadow copies located under
/var/lib/pacemaker/cib -- and failing because that path doesn't
exist at that time (unless the buildroot is already spoiled).
This change was unintentionally brought with 1d0d0eff2 commit.
Note that "mktemp" is not reliably portable (not POSIX'd),
but there were other occurrences already.
---
cts/cts-cli.in | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/cts/cts-cli.in b/cts/cts-cli.in
index 33580ebac..75751c662 100755
--- a/cts/cts-cli.in
+++ b/cts/cts-cli.in
@@ -11,6 +11,7 @@ Options:
: ${shadow=cts-cli}
test_home="$(dirname $(readlink -e $0))"
+shadow_dir=$(mktemp -td cts-cli.shadow.XXXXXXXXXX)
num_errors=0
num_passed=0
GREP_OPTIONS=
@@ -73,6 +74,7 @@ function test_assert() {
function test_tools() {
local TMPXML=$(mktemp --tmpdir cts-cli.tools.xml.XXXXXXXXXX)
local TMPORIG=$(mktemp --tmpdir cts-cli.tools.existing.xml.XXXXXXXXXX)
+ export CIB_shadow_dir="${shadow_dir}"
$VALGRIND_CMD crm_shadow --batch --force --create-empty $shadow 2>&1
export CIB_shadow=$shadow
@@ -370,6 +372,7 @@ function test_tools() {
cmd="crm_resource -r test-primitive --meta -d is-managed"
test_assert $CRM_EX_OK
+ unset CIB_shadow_dir
rm -f "$TMPXML" "$TMPORIG"
}
@@ -614,7 +617,7 @@ function test_acl_loop() {
function test_acls() {
local SHADOWPATH
local TMPXML=$(mktemp --tmpdir cts-cli.acls.xml.XXXXXXXXXX)
-
+ export CIB_shadow_dir="${shadow_dir}"
$VALGRIND_CMD crm_shadow --batch --force --create-empty $shadow --validate-with pacemaker-1.3 2>&1
export CIB_shadow=$shadow
@@ -681,12 +684,15 @@ EOF
sed -i 's/admin_epoch=.1/admin_epoch=\"0/g' "$SHADOWPATH"
test_acl_loop "$TMPXML"
+
+ unset CIB_shadow_dir
rm -f "$TMPXML"
}
function test_validity() {
local TMPGOOD=$(mktemp --tmpdir cts-cli.validity.good.xml.XXXXXXXXXX)
local TMPBAD=$(mktemp --tmpdir cts-cli.validity.bad.xml.XXXXXXXXXX)
+ export CIB_shadow_dir="${shadow_dir}"
$VALGRIND_CMD crm_shadow --batch --force --create-empty $shadow --validate-with pacemaker-1.2 2>&1
export CIB_shadow=$shadow
@@ -752,6 +758,7 @@ function test_validity() {
cmd="crm_simulate -x $TMPBAD -S"
test_assert $CRM_EX_OK 0
+ unset CIB_shadow_dir
rm -f "$TMPGOOD" "$TMPBAD"
}
@@ -845,6 +852,9 @@ for t in $tests; do
cp "$TMPFILE" $test_home/cli/regression.$t.exp
fi
done
+
+rm -f "${shadow_dir}/*"
+rmdir "${shadow_dir}"
failed=0
--
2.17.0

View File

@ -0,0 +1,23 @@
From 86a0b616d6363ff1a6f42454a5d4988266fc585d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Thu, 12 Apr 2018 15:02:03 +0200
Subject: [PATCH] Build: cts: fix autoconf variable substitution in the shebang
Rectifies 5f3708020.
---
cts/cts.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cts/cts.in b/cts/cts.in
index 9ff107c66..93ac1d3a3 100755
--- a/cts/cts.in
+++ b/cts/cts.in
@@ -1,4 +1,4 @@
-#!@BASH_PATH
+#!@BASH_PATH@
#
# Copyright 2012-2018 Andrew Beekhof <andrew@beekhof.net>
#
--
2.17.0

View File

@ -13,12 +13,12 @@
## Upstream pacemaker version, and its package version (specversion
## can be incremented to build packages reliably considered "newer"
## than previously built packages with the same pcmkversion)
%global pcmkversion 1.1.18
%global specversion 2
%global pcmkversion 2.0.0
%global specversion 1
## Upstream commit (or git tag, such as "Pacemaker-" plus the
## {pcmkversion} macro for an official release) to use for this package
%global commit Pacemaker-1.1.18
%global commit Pacemaker-2.0.0-rc2
## Since git v2.11, the extent of abbreviation is autoscaled by default
## (used to be constant of 7), so we need to convey it for non-tags, too.
%global commit_abbrev 9
@ -47,25 +47,23 @@
case "%{shortcommit}" in *-rc[[:digit:]]*%{rparen} false;;
esac; }; echo $?)
## Turn off auto-compilation of python files outside site-packages directory,
## so that the -libs-devel package is multilib-compliant (no *.py[co] files)
## (py_auto_byte_compile macro: https://bugzilla.redhat.com/574437)
%undefine py_auto_byte_compile
## Heuristic used to infer bleeding-edge deployments that are
## less likely to have working versions of the documentation tools
%define bleeding %(test ! -e /etc/yum.repos.d/fedora-rawhide.repo; echo $?)
## Corosync version
%define cs_version %(pkg-config corosync --modversion 2>/dev/null | awk -F . '{print $1}')
## Turn off auto-compilation of Python files outside site-packages directory,
## so that the -libs-devel package is multilib-compliant (no *.py[co] files)
## (py_auto_byte_compile macro: https://bugzilla.redhat.com/574437)
## XXX keep an eye on https://pagure.io/packaging-committee/issue/755
%undefine py_auto_byte_compile
## Where to install python site libraries (currently, this uses the unversioned
## python_sitearch macro to get the default system python, but at some point,
## we should explicitly choose python2_sitearch or python3_sitearch -- or both)
%define py_site %{?python_sitearch}%{!?python_sitearch:%(
python -c 'from distutils.sysconfig import get_python_lib as gpl; print(gpl(1))' 2>/dev/null)}
## Values that differ by Python major version
%global python_path /usr/bin/python%{?python3_pkgversion}%{!?python3_pkgversion:3}
%global python_pkg python3
%global python_min 3.2
%define py_site %{?python3_sitelib}%{!?python3_sitelib:%(
python3 -c 'from distutils.sysconfig import get_python_lib as gpl; print(gpl(1))' 2>/dev/null)}
## NOTE: skip cman_native (false) and systemd_native (true) decisions
# Define conditionals so that "rpmbuild --with <feature>" and
# "rpmbuild --without <feature>" can enable and disable specific features
@ -86,14 +84,7 @@
## (so later "official" packages will be considered updates)
%bcond_with pre_release
## Add option to ship Upstart job files
%bcond_with upstart_job
## Add option to turn on SNMP / ESMTP support
%bcond_with snmp
%bcond_with esmtp
## NOTE: skip --without cman
## NOTE: skip --with upstart_job
## Add option to turn off hardening of libraries and daemon executables
%bcond_without hardening
@ -128,7 +119,7 @@
Name: pacemaker
Summary: Scalable High-Availability cluster resource manager
Version: %{pcmkversion}
Release: %{pcmk_release}%{?dist}.2
Release: %{pcmk_release}%{?dist}
License: GPLv2+ and LGPLv2+
Url: http://www.clusterlabs.org
Group: System Environment/Daemons
@ -137,23 +128,39 @@ Group: System Environment/Daemons
Source0: https://github.com/%{github_owner}/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Source1: https://github.com/%{github_owner}/%{nagios_name}/archive/%{nagios_hash}/%{nagios_name}-%{nagios_hash}.tar.gz
# ---
Patch0: systemd-make-sure-neither-of-pacemaker-_remoted-is-p.patch
Patch0: 0001-Fix-rhbz-1565187-Ensure-failures-that-cause-fencing-.patch
Patch1: 0002-Test-rhbz-1565187-Ensure-failures-that-cause-fencing.patch
Patch2: 0003-Test-cts-pengine-create_mode-is-now-controlled-by-up.patch
Patch3: 0004-Build-cts-update-scripts-to-use-new-BASH_PATH-subsit.patch
# reordered due to how rebases where done
Patch4: 0018-Tests-cts-cli-fix-thinko-leading-to-system-wide-shad.patch
Patch5: 0005-Test-cts-don-t-use-readlink-e-unless-supported.patch
Patch6: 0006-Refactor-libcrmcommon-move-PID-functions-to-own-file.patch
Patch7: 0007-Refactor-libcrmcommon-shuffle-some-internal-declarat.patch
Patch8: 0008-High-crmd-delete-resource-from-lrmd-when-appropriate.patch
Patch9: 0009-Test-cts-cli-update-expected-results-for-recent-chan.patch
Patch10: 0010-Test-cts-cli-cts-pengine-avoid-sed-i.patch
Patch11: 0011-Build-tools-only-link-against-necessary-libraries.patch
Patch12: 0012-Low-fencing-free-dynamic-memory-at-stonithd-shutdown.patch
Patch13: 0013-Low-fencing-avoid-memory-leaks-when-freeing-remote-o.patch
Patch14: 0014-Low-libcrmcommon-fix-memory-leak-in-schema-workaroun.patch
Patch15: 0015-Low-libcrmcommon-free-signal-triggers-when-cleaning-.patch
Patch16: 0016-Build-Makefile-build-and-clean-but-not-install-CTS-b.patch
Patch17: 0017-Refactor-libcrmcommon-avoid-new-as-variable-name.patch
Patch18: 0019-Build-cts-fix-autoconf-variable-substitution-in-the-.patch
# keep following commented out for now
#Patch100: bz1179335-system-wide-crypto-policies.patch
Provides: pcmk-cluster-manager
Requires: resource-agents
Requires: %{name}-libs = %{version}-%{release}
Requires: %{name}-cluster-libs = %{version}-%{release}
Requires: %{name}-cli = %{version}-%{release}
Provides: pcmk-cluster-manager
%{?systemd_requires}
%if %{defined systemd_requires}
%systemd_requires
%endif
# Pacemaker targets compatibility with python 2.6+ and 3.2+
Requires: python2 >= 2.6
BuildRequires: python2-devel >= 2.6
# Pacemaker requires a minimum Python functionality
Requires: %{python_pkg} >= %{python_min}
BuildRequires: %{python_pkg}-devel >= %{python_min}
# Pacemaker requires a minimum libqb functionality
Requires: libqb >= 0.13.0
@ -163,29 +170,28 @@ BuildRequires: libqb-devel >= 0.13.0
BuildRequires: coreutils findutils grep sed
# Required for core functionality
BuildRequires: automake autoconf libtool pkgconfig libtool-ltdl-devel
## version lower bound for: G_GNUC_INTERNAL
BuildRequires: pkgconfig(glib-2.0) >= 2.6
BuildRequires: automake autoconf gcc libtool pkgconfig libtool-ltdl-devel
## version lower bound for: g_strcmp0, g_hash_table_iter_init, ...
BuildRequires: pkgconfig(glib-2.0) >= 2.16
BuildRequires: libxml2-devel libxslt-devel libuuid-devel
BuildRequires: bzip2-devel pam-devel
# Required for agent_config.h which specifies the correct scratch directory
BuildRequires: resource-agents
# Enables optional functionality
BuildRequires: ncurses-devel docbook-style-xsl
BuildRequires: bison byacc flex help2man gnutls-devel pkgconfig(dbus-1)
BuildRequires: help2man gnutls-devel pkgconfig(dbus-1)
BuildRequires: pkgconfig(systemd)
Requires: corosync
BuildRequires: pkgconfig(libcpg)
BuildRequires: pkgconfig(libcfg)
Requires: corosync >= 2.0.0
BuildRequires: corosynclib-devel >= 2.0.0
#XXX
#BuildRequires: pkgconfig(libcpg)
#BuildRequires: pkgconfig(libcfg)
## (note no avoiding effect when building through non-customized mock)
%if !%{bleeding}
%if %{with doc}
BuildRequires: publican inkscape asciidoc
BuildRequires: asciidoc inkscape publican
%endif
%endif
@ -194,7 +200,7 @@ BuildRequires: git
%description
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
It supports more than 16 node clusters with significant capabilities
for managing resources and dependencies.
@ -215,33 +221,34 @@ Requires: perl-TimeDate
%description cli
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
The %{name}-cli package contains command line tools that can be used
to query and control the cluster from machines that may, or may not,
be part of the cluster.
%package -n %{name}-libs
%package libs
License: GPLv2+ and LGPLv2+
Summary: Core Pacemaker libraries
Group: System Environment/Daemons
Requires(pre): shadow-utils
%description -n %{name}-libs
%description libs
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
The %{name}-libs package contains shared libraries needed for cluster
nodes and those just running the CLI tools.
%package -n %{name}-cluster-libs
%package cluster-libs
License: GPLv2+ and LGPLv2+
Summary: Cluster Libraries used by Pacemaker
Group: System Environment/Daemons
Requires: %{name}-libs = %{version}-%{release}
%description -n %{name}-cluster-libs
%description cluster-libs
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
The %{name}-cluster-libs package contains cluster-aware shared
libraries needed for nodes that will form part of the cluster nodes.
@ -250,23 +257,22 @@ libraries needed for nodes that will form part of the cluster nodes.
License: GPLv2+ and LGPLv2+
Summary: Pacemaker remote daemon for non-cluster nodes
Group: System Environment/Daemons
Provides: pcmk-cluster-manager
Requires: %{name}-libs = %{version}-%{release}
Requires: %{name}-cli = %{version}-%{release}
Requires: resource-agents
Provides: pcmk-cluster-manager
%if %{defined systemd_requires}
%systemd_requires
%endif
# -remote can be fully independent of systemd
%{?systemd_ordering}%{!?systemd_ordering:%{?systemd_requires}}
%description remote
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
The %{name}-remote package contains the Pacemaker Remote daemon
which is capable of extending pacemaker functionality to remote
nodes not running the full corosync/cluster stack.
%package -n %{name}-libs-devel
%package libs-devel
License: GPLv2+ and LGPLv2+
Summary: Pacemaker development package
Group: Development/Libraries
@ -276,35 +282,25 @@ Requires: %{name}-cluster-libs%{?_isa} = %{version}-%{release}
Requires: libtool-ltdl-devel%{?_isa} libuuid-devel%{?_isa}
Requires: libxml2-devel%{?_isa} libxslt-devel%{?_isa}
Requires: bzip2-devel%{?_isa} glib2-devel%{?_isa}
Requires: libqb-devel%{?_isa} corosynclib-devel%{?_isa}
Requires: libqb-devel%{?_isa}
Requires: corosynclib-devel%{?_isa} >= 2.0.0
%description -n %{name}-libs-devel
%description libs-devel
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
The %{name}-libs-devel package contains headers and shared libraries
for developing tools for Pacemaker.
# NOTE: can be noarch if lrmd_test is moved to another subpackage
%package cts
License: GPLv2+ and LGPLv2+
Summary: Test framework for cluster-related technologies like Pacemaker
Group: System Environment/Daemons
Requires: python2 >= 2.6
Requires: %{python_pkg} >= %{python_min}
Requires: %{name}-libs = %{version}-%{release}
BuildArch: noarch
# systemd python bindings are separate package in some distros
%if %{defined systemd_requires}
%if 0%{?fedora} > 22
Requires: python2-systemd
%else
%if 0%{?fedora} > 20 || 0%{?rhel} > 6
Requires: python2-systemd
%endif
%endif
%endif
Requires: %{python_pkg}-systemd
%description cts
Test framework for cluster-related technologies like Pacemaker
@ -313,12 +309,13 @@ Test framework for cluster-related technologies like Pacemaker
License: CC-BY-SA
Summary: Documentation for Pacemaker
Group: Documentation
BuildArch: noarch
%description doc
Documentation for Pacemaker.
Pacemaker is an advanced, scalable High-Availability cluster resource
manager for Corosync, CMAN and/or Linux-HA.
manager.
%package nagios-plugins-metadata
License: GPLv3
@ -338,24 +335,16 @@ monitor resources.
%prep
%setup -q -a 1 -n %{name}-%{commit}
%global __scm git
%global __scm git_am
%__scm_setup_git
%autopatch -p1
# Force the local time
#
# 'git' sets the file date to the date of the last commit.
# This can result in files having been created in the future
# when building on machines in timezones 'behind' the one the
# commit occurred in - which seriously confuses 'make'
find . -exec touch \{\} \;
%build
# Early versions of autotools (e.g. RHEL <= 5) do not support --docdir
export docdir=%{pcmk_docdir}
export systemdunitdir=%{?_unitdir}%{?!_unitdir:no}
export systemdunitdir=%{?_unitdir}%{!?_unitdir:no}
%if %{with hardening}
# prefer distro-provided hardening flags in case they are defined
@ -374,10 +363,9 @@ export LDFLAGS_HARDENED_LIB="%{?_hardening_ldflags}"
%{configure} \
%{?with_profiling: --with-profiling} \
%{?with_coverage: --with-coverage} \
%{!?with_snmp: --without-snmp} \
%{!?with_esmtp: --without-esmtp} \
%{!?with_doc: --with-brand=} \
%{!?with_hardening: --disable-hardening} \
%{?python_path: PYTHON=%{python_path}} \
--with-initdir=%{_initrddir} \
--localstatedir=%{_var} \
--with-version=%{version}-%{release} \
@ -388,9 +376,11 @@ export LDFLAGS_HARDENED_LIB="%{?_hardening_ldflags}"
make %{_smp_mflags} V=1 all
%check
{ ./BasicSanity.sh -V pengine cli 2>&1 && touch .CHECKED
} | sed 's/[fF]ail/faiil/g' # prevent false positives in rpmlint
[ -f .CHECKED ] && rm -f -- .CHECKED || false
{ cts/cts-pengine --run one-or-more-unrunnable-instances \
&& cts/cts-cli \
&& touch .CHECKED
} 2>&1 | sed 's/[fF]ail/faiil/g' # prevent false positives in rpmlint
[ -f .CHECKED ] && rm -f -- .CHECKED
%install
make DESTDIR=%{buildroot} docdir=%{pcmk_docdir} V=1 install
@ -404,18 +394,9 @@ for file in $(find %{nagios_name}-%{nagios_hash}/metadata -type f); do
install -m 644 $file %{buildroot}%{_datadir}/pacemaker/nagios/plugins-metadata
done
%if %{with upstart_job}
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/init
install -m 644 mcp/pacemaker.upstart ${RPM_BUILD_ROOT}%{_sysconfdir}/init/pacemaker.conf
install -m 644 mcp/pacemaker.combined.upstart ${RPM_BUILD_ROOT}%{_sysconfdir}/init/pacemaker.combined.conf
install -m 644 tools/crm_mon.upstart ${RPM_BUILD_ROOT}%{_sysconfdir}/init/crm_mon.conf
%endif
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/lib/rpm-state/%{name}
# Scripts that should be executable
chmod a+x %{buildroot}/%{_datadir}/pacemaker/tests/cts/CTSlab.py
# These are not actually scripts
find %{buildroot} -name '*.xml' -type f -print0 | xargs -0 chmod a-x
@ -433,9 +414,6 @@ find %{buildroot} -name 'o2cb*' -type f -print0 | xargs -0 rm -f
rm -f %{buildroot}/%{_initrddir}/pacemaker
rm -f %{buildroot}/%{_initrddir}/pacemaker_remote
# Don't ship fence_pcmk where it has no use
rm -f %{buildroot}/%{_sbindir}/fence_pcmk
%if %{with coverage}
GCOV_BASE=%{buildroot}/%{_var}/lib/pacemaker/gcov
mkdir -p $GCOV_BASE
@ -499,24 +477,19 @@ fi
%postun cli
%systemd_postun_with_restart crm_mon.service
%pre -n %{name}-libs
%pre libs
# XXX keep an eye on https://fedoraproject.org/wiki/Changes/SystemdSysusers
# reopened recently:
# https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/AETGESYR4IEQJMA6SKL7OERSDZFWFNEU/
getent group %{gname} >/dev/null || groupadd -r %{gname} -g 189
getent passwd %{uname} >/dev/null || useradd -r -g %{gname} -u 189 -s /sbin/nologin -c "cluster user" %{uname}
exit 0
%post -n %{name}-libs -p /sbin/ldconfig
%postun -n %{name}-libs -p /sbin/ldconfig
%post -n %{name}-cluster-libs -p /sbin/ldconfig
%postun -n %{name}-cluster-libs -p /sbin/ldconfig
%ldconfig_scriptlets libs
%ldconfig_scriptlets cluster-libs
%files
###########################################################
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/sysconfig/pacemaker
%{_sbindir}/pacemakerd
@ -554,20 +527,14 @@ exit 0
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/pengine
/usr/lib/ocf/resource.d/pacemaker/controld
/usr/lib/ocf/resource.d/pacemaker/remote
/usr/lib/ocf/resource.d/.isolation
%files cli
%defattr(-,root,root)
%dir %attr (750, root, %{gname}) %{_sysconfdir}/pacemaker
%config(noreplace) %{_sysconfdir}/logrotate.d/pacemaker
%config(noreplace) %{_sysconfdir}/sysconfig/crm_mon
%{_unitdir}/crm_mon.service
%if %{with upstart_job}
%config(noreplace) %{_sysconfdir}/init/crm_mon.conf
%endif
%{_sbindir}/attrd_updater
%{_sbindir}/cibadmin
%{_sbindir}/crm_diff
@ -587,6 +554,7 @@ exit 0
%exclude %{_datadir}/pacemaker/tests
%{_datadir}/pacemaker
%{_datadir}/snmp/mibs/PCMK-MIB.txt
%{_libexecdir}/pacemaker/lrmd_test
%exclude /usr/lib/ocf/resource.d/pacemaker/controld
%exclude /usr/lib/ocf/resource.d/pacemaker/o2cb
@ -607,7 +575,6 @@ exit 0
%exclude %{_mandir}/man8/crm_attribute.*
%exclude %{_mandir}/man8/crm_node.*
%exclude %{_mandir}/man8/crm_master.*
%exclude %{_mandir}/man8/fence_pcmk.*
%exclude %{_mandir}/man8/fence_legacy.*
%exclude %{_mandir}/man8/pacemakerd.*
%exclude %{_mandir}/man8/pacemaker_remoted.*
@ -620,10 +587,10 @@ exit 0
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/blackbox
%dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pacemaker/cores
%dir %attr (770, %{uname}, %{gname}) %{_var}/log/pacemaker
%dir %attr (770, %{uname}, %{gname}) %{_var}/log/pacemaker/bundles
%files -n %{name}-libs
%defattr(-,root,root)
%files libs
%{_libdir}/libcib.so.*
%{_libdir}/liblrmd.so.*
%{_libdir}/libcrmservice.so.*
@ -637,16 +604,13 @@ exit 0
%doc COPYING
%doc ChangeLog
%files -n %{name}-cluster-libs
%defattr(-,root,root)
%files cluster-libs
%{_libdir}/libcrmcluster.so.*
%license licenses/LGPLv2.1
%doc COPYING
%doc ChangeLog
%files remote
%defattr(-,root,root)
%config(noreplace) %{_sysconfdir}/sysconfig/pacemaker
# state directory is shared between the subpackets
# let rpm take care of removing it once it isn't
@ -661,23 +625,17 @@ exit 0
%doc ChangeLog
%files doc
%defattr(-,root,root)
%doc %{pcmk_docdir}
%license licenses/CC-BY-SA-4.0
%files cts
%defattr(-,root,root)
%{py_site}/cts
%{_datadir}/pacemaker/tests/cts
%{_libexecdir}/pacemaker/lrmd_test
%{_datadir}/pacemaker/tests
%license licenses/GPLv2
%doc COPYING
%doc ChangeLog
%files -n %{name}-libs-devel
%defattr(-,root,root)
%exclude %{_datadir}/pacemaker/tests/cts
%{_datadir}/pacemaker/tests
%files libs-devel
%{_includedir}/pacemaker
%{_libdir}/*.so
%if %{with coverage}
@ -689,12 +647,46 @@ exit 0
%doc ChangeLog
%files nagios-plugins-metadata
%defattr(-,root,root)
%dir %{_datadir}/pacemaker/nagios/plugins-metadata
%attr(0644,root,root) %{_datadir}/pacemaker/nagios/plugins-metadata/*
%license %{nagios_name}-%{nagios_hash}/COPYING
%changelog
* Mon Apr 09 2018 Jan Pokorný <jpokorny+rpm-pacemaker@redhat.com> - 2.0.0-0.1.rc2
- Update for new upstream tarball for release candidate: Pacemaker-2.0.0-rc2,
for full details, see included ChangeLog file or
https://github.com/ClusterLabs/pacemaker/releases/tag/Pacemaker-2.0.0-rc2
- Adapt spec file more akin to upstream version including:
. out-of-tree change from 1.1.18-2 build got subsumed (508ad52e7)
. %%{_sysconfdir}/pacemaker path got properly owned
(-cli package; f6e3ab98d)
. -libs package started to properly declare Requires(pre): shadow-utils
(293fcc1e8 + b3d49d210)
. some build conditionals and dependencies dropped for no longer
(snmp, esmtp; f24bdc6f2 and 1f7374884, respectively) or never
being relevant (~bison, byacc, flex; 61aef8af4)
. some dependencies were constrained with new or higher lower bounds:
corosync needs to be of version 2+ unconditionally (ccd58fe29),
ditto some others components (~GLib, 1ac2e7cbb), plus both 2 and 3
versions of Python are now (comprehensively for the auxiliary
functionality where used) supported upstream with the latter being
a better fit (453355f8f)
. package descriptions got to reflect the drop of legacy low-level
cluster infrastructures (55ab749bf)
- Adapt spec file akin to current packaging guidelines including:
. drop some redundant/futile expressions (defattr, "-n %%{name}-libs"
instead of plain "libs", "timezone hack"), add some notes for future
. make -cts and -doc packages noarch (former enabled with 088a5e7d4)
. simplify "systemd_requires" macro invocation, and relax it to
"systemd_ordering" for -remote package where possible so as not
to drag systemd into a lightweight system setup (e.g. container)
needlessly
. adjust, in a compatible way, common ldconfig invocation with
post{,un} scriptlets
(https://fedoraproject.org/wiki/Changes/Removing_ldconfig_scriptlets)
. drop some more unuseful conditionals (upstart_job)
- Apply some regression fixes on top as patches (PR #1457, #1459)
* Wed Feb 21 2018 Iryna Shcherbina <ishcherb@redhat.com> - 1.1.18-2.2
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

View File

@ -1,2 +1,2 @@
SHA512 (pacemaker-1.1.18.tar.gz) = 63c287888e5f0bd5f1a2f56450cb3d4da580df2d750ffa90b2212a4efcfa146e05e258a9d87fdcaacde5f8985b9730dae11c5d5ad22e811fd114e1640365c9aa
SHA512 (pacemaker-2.0.0-rc2.tar.gz) = f090f5bbe547c016f088d771d1969aaa771de417262786c493b5d6b39369e04655e29325084f7c1d481e0eaec64ffbab2b9ae6a74970bd61f5ec7fca0814d93c
SHA512 (nagios-agents-metadata-105ab8a7b2c16b9a29cf1c1596b80136eeef332b.tar.gz) = 11ddeb48a4929e7642b6dfa9c7962aa1d7a1af1c569830f55ed6cd6773abac13377317327bc1db8411c8077884f83f81cc54d746c834b63a99fa6dc219b5caad

View File

@ -1,44 +0,0 @@
From f33c8cffc0789d7544ec29c22fc846b59172af8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Thu, 16 Nov 2017 10:43:46 +0100
Subject: [PATCH] systemd: make sure neither of pacemaker{,_remoted} is
process-limited
---
lrmd/pacemaker_remote.service.in | 4 +---
mcp/pacemaker.service.in | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/lrmd/pacemaker_remote.service.in b/lrmd/pacemaker_remote.service.in
index d5717f6d0..13e7df8f4 100644
--- a/lrmd/pacemaker_remote.service.in
+++ b/lrmd/pacemaker_remote.service.in
@@ -21,9 +21,7 @@ EnvironmentFile=-@CONFIGDIR@/sbd
ExecStart=@sbindir@/pacemaker_remoted
-# Uncomment TasksMax if your systemd version supports it.
-# Only systemd v227 and above support this option.
-#TasksMax=infinity
+TasksMax=infinity
# Pacemaker Remote can exit only after all managed services have shut down;
# an HA database could conceivably take even longer than this
diff --git a/mcp/pacemaker.service.in b/mcp/pacemaker.service.in
index 516de0f82..a2ab96162 100644
--- a/mcp/pacemaker.service.in
+++ b/mcp/pacemaker.service.in
@@ -41,9 +41,7 @@ SuccessExitStatus=100
ExecStart=@sbindir@/pacemakerd -f
-# Uncomment TasksMax if your systemd version supports it.
-# Only systemd v227 and above support this option.
-#TasksMax=infinity
+TasksMax=infinity
# If pacemakerd doesn't stop, it's probably waiting on a cluster
# resource. Sending -KILL will just get the node fenced
--
2.15.0