Refactor patches for rabbitmq-server package

Use rabbitmq-server-config package to package config files for
rabbitmq-server package. We can remove related patches of it.
Install custom ocf script and let SM call this one instead of
default one.

Deployment test and ping test between VMs pass
Config files check pass.

Story: 2003768
Task: 28042
Depends-on: https://review.openstack.org/#/c/621510

Change-Id: I64281b5601b7e457c724747f81e58cc1e42936dd
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
This commit is contained in:
zhipengl 2018-11-24 07:50:45 +08:00 committed by zhipeng liu
parent 28577e52b1
commit 75b332539d
17 changed files with 90 additions and 443 deletions

View File

@ -164,6 +164,7 @@ openstack-panko-config
# rabbitmq-server
rabbitmq-server
rabbitmq-server-config
# python-openstackclient
python2-openstackclient

View File

@ -43,6 +43,7 @@ openstack/python-oslo-concurrency
openstack/python-oslo-service
openstack/python-oslo-messaging
openstack/rabbitmq-server
openstack/rabbitmq-server-config
openstack/python-keystoneauth1
openstack/python-openstackclient
openstack/python-osc-lib

View File

@ -0,0 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=0

View File

@ -0,0 +1,42 @@
Summary: rabbitmq-server-config
Name: rabbitmq-server-config
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: StarlingX
URL: unknown
BuildArch: noarch
Source: %name-%version.tar.gz
Requires: %{_bindir}/systemctl
Requires: rabbitmq-server
Summary: package StarlingX configuration files of rabbitmq-server to system folder.
%description
package StarlingX configuration files of rabbitmq-server to system folder.
%prep
%setup
%build
%install
%{__install} -d %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq
%{__install} -d %{buildroot}%{_sysconfdir}/systemd/system
%{__install} -d %{buildroot}%{_datadir}/starlingx
%{__install} -m 0755 rabbitmq-server.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/stx.rabbitmq-server
%{__install} -m 0644 rabbitmq-server.service.example %{buildroot}%{_sysconfdir}/systemd/system/rabbitmq-server.service
%{__install} -m 0644 rabbitmq-server.logrotate %{buildroot}%{_datadir}/starlingx/stx.rabbitmq-server.logrotate
%post
if [ $1 -eq 1 ] ; then
# Initial installation
cp -f %{_datadir}/starlingx/stx.rabbitmq-server.logrotate %{_sysconfdir}/logrotate.d/rabbitmq-server
fi
%files
%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/stx.rabbitmq-server
%{_sysconfdir}/systemd/system/rabbitmq-server.service
%{_datadir}/starlingx/stx.rabbitmq-server.logrotate

View File

@ -0,0 +1,13 @@
/var/log/rabbitmq/*.log {
weekly
missingok
rotate 20
compress
delaycompress
notifempty
sharedscripts
postrotate
pgrep beam.smp >/dev/null && /usr/sbin/rabbitmqctl -q rotate_logs
true
endscript
}

View File

@ -0,0 +1,17 @@
[Unit]
Description=RabbitMQ broker
After=network.target epmd@0.0.0.0.socket
Wants=network.target epmd@0.0.0.0.socket
[Service]
Type=notify
User=root
Group=root
NotifyAccess=all
TimeoutStartSec=3600
WorkingDirectory=/var/lib/rabbitmq
ExecStart=/usr/lib/rabbitmq/bin/rabbitmq-server
ExecStop=/usr/lib/rabbitmq/bin/rabbitmqctl stop
[Install]
WantedBy=multi-user.target

View File

@ -1,3 +1,2 @@
COPY_LIST="rabbitmq-server/rabbitmq-server.ocf centos/patches/*"
TIS_PATCH_VER=6
TIS_PATCH_VER=7
BUILD_IS_SLOW=3

View File

@ -1,27 +1,22 @@
From 9eb2a001b8f80d1a66d4ec78d882d7d6cb4dff51 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Tue, 24 Jan 2017 12:16:38 -0500
Subject: [PATCH 4/5] WRS: 0001-Update-package-versioning-for-TIS-format.patch
Subject: [PATCH 1/2] WRS: 0001-Update-package-versioning-for-TIS-format.patch
Conflicts:
SPECS/rabbitmq-server.spec
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
---
SPECS/rabbitmq-server.spec | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
SPECS/rabbitmq-server.spec | 2 +-
1 file changed, 1 insertion(+), 1 deletions(-)
diff --git a/SPECS/rabbitmq-server.spec b/SPECS/rabbitmq-server.spec
index 3095f87..b5d53a2 100644
index 3a7d940..435f427 100644
--- a/SPECS/rabbitmq-server.spec
+++ b/SPECS/rabbitmq-server.spec
@@ -2,11 +2,9 @@
# We want to install into /usr/lib, even on 64-bit platforms
%global _rabbit_libdir %{_exec_prefix}/lib/rabbitmq
@@ -5,7 +5,7 @@
-%define tis_version r1
-
Name: rabbitmq-server
Version: 3.6.5
-Release: 1.%{tis_version}%{?dist}
-Release: 1%{?dist}
+Release: 1.el7%{?_tis_dist}.%{tis_patch_ver}
License: MPLv1.1
Group: Development/Libraries

View File

@ -1,25 +0,0 @@
From 0934088d588521e4f2ac2dbd28ae2de919368d71 Mon Sep 17 00:00:00 2001
From: Don Penney <don.penney@windriver.com>
Date: Wed, 7 Feb 2018 13:34:44 -0500
Subject: [PATCH] Update rabbitmq-server.logrotate
---
SOURCES/rabbitmq-server.logrotate | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/SOURCES/rabbitmq-server.logrotate b/SOURCES/rabbitmq-server.logrotate
index 832cdcf..8de4c84 100644
--- a/SOURCES/rabbitmq-server.logrotate
+++ b/SOURCES/rabbitmq-server.logrotate
@@ -7,6 +7,7 @@
notifempty
sharedscripts
postrotate
- /usr/sbin/rabbitmqctl -q rotate_logs
+ pgrep beam.smp >/dev/null && /usr/sbin/rabbitmqctl -q rotate_logs
+ true
endscript
}
--
1.8.3.1

View File

@ -1,7 +1,7 @@
From cc25d3100a677e0c69a11975fd30ce72937ad575 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Tue, 24 Jan 2017 12:16:38 -0500
Subject: [PATCH 3/5] WRS: Allow-rabbitmqctl-to-run-as-root.patch
Subject: [PATCH 2/2] WRS: Allow-rabbitmqctl-to-run-as-root-and-set-root-home.patch
---
SOURCES/rabbitmq-script-wrapper | 4 +++-
@ -17,11 +17,10 @@ index 3d2fc49..d039b23 100644
elif [ `id -u` = 0 ] ; then
- su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
+ # WRS. Allow to run as root
+ # su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
+ export HOME=${HOME:-/root}
+ /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
else
/usr/lib/rabbitmq/bin/${SCRIPT}
echo
--
1.8.3.1

View File

@ -1,6 +1,2 @@
spec-comments-for-ocf.patch
packstack-fixes.patch
Allow-rabbitmqctl-to-run-as-root.patch
0001-Update-package-versioning-for-TIS-format.patch
Set-root-home-for-rabbitmqctl.patch
0006-Update-rabbitmq-server.logrotate.patch
Allow-rabbitmqctl-to-run-as-root-and-set-root-home.patch

View File

@ -1,24 +0,0 @@
From d6ed4a9b31a25ae7b803b99f49bb88bb9648ce06 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Tue, 24 Jan 2017 12:16:38 -0500
Subject: [PATCH 5/5] WRS: Set-root-home-for-rabbitmqctl.patch
---
SOURCES/rabbitmq-script-wrapper | 1 +
1 file changed, 1 insertion(+)
diff --git a/SOURCES/rabbitmq-script-wrapper b/SOURCES/rabbitmq-script-wrapper
index d039b23..6f7450e 100644
--- a/SOURCES/rabbitmq-script-wrapper
+++ b/SOURCES/rabbitmq-script-wrapper
@@ -44,6 +44,7 @@ elif [ `id -u` = `id -u rabbitmq` -o "$SCRIPT" = "rabbitmq-plugins" ] ; then
elif [ `id -u` = 0 ] ; then
# WRS. Allow to run as root
# su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
+ export HOME=${HOME:-/root}
/bin/sh -c "/usr/lib/rabbitmq/bin/${SCRIPT} ${CMDLINE}"
else
/usr/lib/rabbitmq/bin/${SCRIPT}
--
1.8.3.1

View File

@ -1,37 +0,0 @@
From 251b011a5ccd75bfeb3ea56bb4d414491b560874 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Tue, 24 Jan 2017 12:16:38 -0500
Subject: [PATCH 2/5] WRS: packstack-fixes.patch
Conflicts:
SPECS/rabbitmq-server.spec
---
SPECS/rabbitmq-server.spec | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/SPECS/rabbitmq-server.spec b/SPECS/rabbitmq-server.spec
index f1c3cab..3095f87 100644
--- a/SPECS/rabbitmq-server.spec
+++ b/SPECS/rabbitmq-server.spec
@@ -28,6 +28,9 @@ Patch6: rabbitmq-server-0006-rabbit_prelaunch-must-use-RABBITMQ_SERVER_ERL_ARGS.
Patch101: rabbitmq-common-0001-Avoid-RPC-roundtrips-while-listing-items.patch
Patch102: rabbitmq-common-0002-Use-proto_dist-from-command-line.patch
+# WRS Patches
+Patch201: update-rabbitmq-server.service.patch
+
URL: http://www.rabbitmq.com/
BuildArch: noarch
BuildRequires: erlang >= %{erlang_minver}, python-simplejson, xmlto, libxslt, python, zip
@@ -72,6 +75,8 @@ cd deps/rabbit_common
%patch102 -p1
cd ../..
+%patch201 -p1
+
# We have to remove it until common_test subpackage lands RHOS
rm -f \
deps/amqp_client/src/rabbit_ct_client_helpers.erl \
--
1.8.3.1

View File

@ -1,49 +0,0 @@
From 45e477c179ff48c209c7b3210e285e6cddc22137 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Tue, 24 Jan 2017 12:16:38 -0500
Subject: [PATCH 1/5] WRS: spec-comments-for-ocf.patch
Conflicts:
SPECS/rabbitmq-server.spec
---
SPECS/rabbitmq-server.spec | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/SPECS/rabbitmq-server.spec b/SPECS/rabbitmq-server.spec
index 3a7d940..f1c3cab 100644
--- a/SPECS/rabbitmq-server.spec
+++ b/SPECS/rabbitmq-server.spec
@@ -2,10 +2,11 @@
# We want to install into /usr/lib, even on 64-bit platforms
%global _rabbit_libdir %{_exec_prefix}/lib/rabbitmq
+%define tis_version r1
Name: rabbitmq-server
Version: 3.6.5
-Release: 1%{?dist}
+Release: 1.%{tis_version}%{?dist}
License: MPLv1.1
Group: Development/Libraries
Source0: http://www.rabbitmq.com/releases/rabbitmq-server/v%{version}/%{name}-%{version}.tar.xz
@@ -15,6 +16,8 @@ Source0: http://www.rabbitmq.com/releases/rabbitmq-server/v%{version}/%{name}-%{
Source2: rabbitmq-script-wrapper
# curl -O https://raw.githubusercontent.com/lemenkov/rabbitmq-server/cdfc661/packaging/RPMS/Fedora/rabbitmq-server.logrotate
Source3: rabbitmq-server.logrotate
+# WRS modified ocf is located in wrs_patches
+Source4: rabbitmq-server.ocf
Source5: rabbitmq-server.tmpfiles
Patch1: rabbitmq-server-0001-Remove-excessive-sd_notify-code.patch
Patch2: rabbitmq-server-0002-Add-systemd-notification-support.patch
@@ -106,7 +109,7 @@ for app in rabbitmq-defaults rabbitmq-env rabbitmq-plugins rabbitmq-server rabbi
ln -s %{_rabbit_libdir}/lib/rabbitmq_server-%{version}/sbin/${app} %{buildroot}%{_rabbit_libdir}/bin/${app}
done
-install -p -D -m 0755 scripts/rabbitmq-server.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server
+install -p -D -m 0755 %{S:4} %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server
install -p -D -m 0755 scripts/rabbitmq-server-ha.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server-ha
install -p -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/logrotate.d/rabbitmq-server
--
1.8.3.1

View File

@ -1,32 +0,0 @@
From 8840ebc0baa702f612d8dddcdd3271758e2e4c4d Mon Sep 17 00:00:00 2001
From: Don Penney <don.penney@windriver.com>
Date: Mon, 27 Jun 2016 14:42:41 -0400
Subject: [PATCH 1/1] Update rabbitmq-server.service
---
docs/rabbitmq-server.service.example | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/docs/rabbitmq-server.service.example b/docs/rabbitmq-server.service.example
index 1aa6549..92aa231 100644
--- a/docs/rabbitmq-server.service.example
+++ b/docs/rabbitmq-server.service.example
@@ -1,4 +1,3 @@
-# systemd unit example
[Unit]
Description=RabbitMQ broker
After=network.target epmd@0.0.0.0.socket
@@ -6,8 +5,8 @@ Wants=network.target epmd@0.0.0.0.socket
[Service]
Type=notify
-User=rabbitmq
-Group=rabbitmq
+User=root
+Group=root
NotifyAccess=all
TimeoutStartSec=3600
WorkingDirectory=/var/lib/rabbitmq
--
1.8.3.1

View File

@ -1,251 +0,0 @@
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides: rabbitmq-server
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
DAEMON=/usr/bin/rabbitmq-server
CONTROL=/usr/bin/rabbitmqctl
USER=root
ROTATE_SUFFIX=
INIT_LOG_DIR=/var/log/rabbitmq
PID_FILE=/var/run/rabbitmq/pid
HOME=/root
export HOME
LOCK_FILE=
test -x $DAEMON || exit 0
test -x $CONTROL || exit 0
RETVAL=0
. /lib/lsb/init-functions
status_of_proc () {
local pidfile daemon name retval pid pidfromfile
pidfile=
daemon=_x_
name=_x_
while [ $# -gt 0 ]; do
case $1 in
-p) shift ; pidfile=$1 ;;
*)
if [ "$daemon" = "_x_" ]; then
daemon="$1"
elif [ "$name" = "_x_" ]; then
name="$1"
fi
;;
esac
shift
done
if [ ! -e $pidfile ]; then
for d in $daemon; do
rc=`pidof $d > /dev/null`
if [ $? = 0 ] ; then
return 0
fi
done
return 1
fi
pidfromfile=`cat $pidfile`
kill -0 $pidfromfile 2> /dev/null
retval=$_
if [ "$daemon" = "_x_" ]; then
# only the pid from the file is used
if [ $retval = 0 ]; then
log_success_msg "$name is running"
else
log_failure_msg "$name is not running"
fi
fi
for pid in `pidof $daemon` ; do
if test "$pidfromfile" -eq "$pid" 2> /dev/null; then
log_success_msg "$name is running"
return 0
fi
done
log_failure_msg "$name is not running"
return 1
}
ensure_pid_dir () {
PID_DIR=`dirname ${PID_FILE}`
if [ ! -d ${PID_DIR} ] ; then
mkdir -p ${PID_DIR}
chown -R ${USER}:${USER} ${PID_DIR}
chmod 755 ${PID_DIR}
fi
}
remove_pid () {
rm -f ${PID_FILE}
rmdir `dirname ${PID_FILE}` || :
}
start_rabbitmq () {
status_rabbitmq quiet || true
if [ $RETVAL = 0 ] ; then
echo RabbitMQ is currently running
else
RETVAL=0
ensure_pid_dir
# There seems to be a race condition around the creation of the Erlang cookie file,
# where both the rabbitmq-server launch and the subsequent "rabbitmqctl wait" will
# both try to create the file if it doesn't exist. This can result in a rare failure during
# initial configuration that reports the cookie file does not have the correct
# permissions. To avoid any possible race condition, we'll make a call to
# "rabbitmqctl status" first, which will create the cookie for us.
/sbin/rabbitmqctl status >/dev/null 2>&1
# RabbitMQ is using Erlang timers. It appears the Erlang module will abort if it detects discrepencies
# in timers, which it is believed to occur sometimes if the process is switched to a different processor
# (it compares a time value against an earlier value retrieved from a possibly different processor).
# To avoid this potential issue, we'll restrict rabbitmq-server to a single CPU for this instance.
# Note: Since SM does not use this script for launch rabbitmq-server, this will only affect the initial
# launching by packstack/puppet for configuration purposes.
RABBITMQ_PID_FILE=$PID_FILE start-stop-daemon \
--pidfile=$PID_FILE \
--background \
--start \
--startas /bin/bash -- \
-c "exec taskset -c 0 $DAEMON >> ${INIT_LOG_DIR}/startup_log 2>> ${INIT_LOG_DIR}/startup_err"
# Wait a second to give rabbit a chance to get started, then check it
sleep 1
taskset -c 0 $CONTROL wait $PID_FILE >> ${INIT_LOG_DIR}/wait_log 2>&1
RETVAL=$?
case "$RETVAL" in
0)
echo SUCCESS
if [ -n "$LOCK_FILE" ] ; then
touch $LOCK_FILE
fi
echo "`date` - rabbitmq successfully started" >> ${INIT_LOG_DIR}/startup_log
# only emit the event on boot
[ -n "$UPSTART_JOB" ] && initctl emit --no-wait rabbitmq-server-running || true
;;
*)
remove_pid
echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
echo "`date` - rabbitmq failed to start" >> ${INIT_LOG_DIR}/startup_err
RETVAL=1
;;
esac
fi
}
stop_rabbitmq () {
status_rabbitmq quiet || true
if [ $RETVAL = 0 ] ; then
if [ ! -e $PID_FILE ] ; then
for d in beam beam.smp; do
rc=`pidof $d 2> /dev/null`
if [ $? = 0 ] ; then
kill $rc
return
fi
done
fi
start-stop-daemon --pidfile=$PID_FILE --stop
RETVAL=$?
if [ $RETVAL = 0 ] ; then
remove_pid
if [ -n "$LOCK_FILE" ] ; then
rm -f $LOCK_FILE
fi
echo "`date` - rabbitmq successfully stopped" >> ${INIT_LOG_DIR}/shutdown_log
else
echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
echo "`date` - rabbitmq failed to stop" >> ${INIT_LOG_DIR}/shutdown_err
fi
else
echo RabbitMQ is not running
RETVAL=0
fi
}
status_rabbitmq() {
if [ "$1" = "quiet" ] ; then
status_of_proc -p $PID_FILE "beam beam.smp" rabbitmq-server > /dev/null
else
status_of_proc -p $PID_FILE "beam beam.smp" rabbitmq-server || exit 1
fi
RETVAL=$?
}
rotate_logs_rabbitmq() {
$CONTROL rotate_logs ${ROTATE_SUFFIX}
if [ $? != 0 ] ; then
RETVAL=1
fi
}
restart_running_rabbitmq () {
status_rabbitmq quiet
if [ $RETVAL = 0 ] ; then
restart_rabbitmq
else
echo RabbitMQ is not runnning
RETVAL=0
fi
}
restart_rabbitmq() {
stop_rabbitmq
start_rabbitmq
}
case "$1" in
start)
echo -n "Starting $DESC: "
start_rabbitmq
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
stop_rabbitmq
echo "$NAME."
;;
status)
status_rabbitmq
;;
rotate-logs)
echo -n "Rotating log files for $DESC: "
rotate_logs_rabbitmq
;;
force-reload|reload|restart)
echo -n "Restarting $DESC: "
restart_rabbitmq
echo "$NAME."
;;
try-restart)
echo -n "Restarting $DESC: "
restart_running_rabbitmq
echo "$NAME."
;;
*)
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
RETVAL=1
;;
esac
exit $RETVAL