Refactor meta patch for openstack-panko

Use openstack-panko-config package to package config file for
openstack-panko package.
The StarlingX common logrotate config file includes panko log files.
To avoid conflict with the logrotate config file from openstack-panko,
we're overwriting this file with just a comment to clear its config.

Deployment test pass and config file check pass!

Story: 2003768
Task: 28362

Change-Id: I09b0f6ae93b915e10ff3d8cdf6fc9cbd5fe9426e
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
This commit is contained in:
zhipengl 2018-12-13 23:27:58 +08:00 committed by zhipeng liu
parent 9893164a9a
commit 9d46723d4f
10 changed files with 124 additions and 168 deletions

View File

@ -160,6 +160,7 @@ openstack-aodh-config
python-panko
openstack-panko-api
openstack-panko-common
openstack-panko-config
# rabbitmq-server
rabbitmq-server

View File

@ -10,6 +10,7 @@ openstack/openstack-magnum
openstack/openstack-magnum-ui
openstack/openstack-ras
openstack/openstack-panko
openstack/openstack-panko-config
openstack/openstack-os-vif
openstack/python-aodhclient
openstack/python-ceilometer

View File

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

View File

@ -0,0 +1,35 @@
Summary: openstack-panko-config
Name: openstack-panko-config
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: openstack
Packager: StarlingX
URL: unknown
BuildArch: noarch
Source: %name-%version.tar.gz
Requires: openstack-panko-common
Requires: openstack-panko-api
Summary: package StarlingX configuration files of openstack-panko to system folder.
%description
package StarlingX configuration files of openstack-panko to system folder.
%prep
%setup
%build
%install
%{__install} -d %{buildroot}%{_bindir}
%{__install} -m 0755 panko-expirer-active %{buildroot}%{_bindir}/panko-expirer-active
%post
if test -s %{_sysconfdir}/logrotate.d/openstack-panko ; then
echo '#See /etc/logrotate.d/syslog for panko rules' > %{_sysconfdir}/logrotate.d/openstack-panko
fi
%files
%{_bindir}/panko-expirer-active

View File

@ -0,0 +1,60 @@
#!/bin/bash
#
# Wrapper script to run panko-expirer when on active controller only
#
PANKO_EXPIRER_INFO="/var/run/panko-expirer.info"
PANKO_EXPIRER_CMD="/usr/bin/nice -n 2 /usr/bin/panko-expirer"
function is_active_pgserver()
{
# Determine whether we're running on the same controller as the service.
local service=postgres
local enabledactive=$(/usr/bin/sm-query service $service| grep enabled-active)
if [ "x$enabledactive" == "x" ]
then
# enabled-active not found for that service on this controller
return 1
else
# enabled-active found for that resource
return 0
fi
}
if is_active_pgserver
then
if [ ! -f ${PANKO_EXPIRER_INFO} ]
then
echo skip_count=0 > ${PANKO_EXPIRER_INFO}
fi
source ${PANKO_EXPIRER_INFO}
sudo -u postgres psql -d sysinv -c "SELECT alarm_id, entity_instance_id from i_alarm;" | grep -P "^(?=.*100.101)(?=.*${HOSTNAME})" &>/dev/null
if [ $? -eq 0 ]
then
source /etc/platform/platform.conf
if [ "${system_type}" = "All-in-one" ]
then
source /etc/init.d/task_affinity_functions.sh
idle_core=$(get_most_idle_core)
if [ "$idle_core" -ne "0" ]
then
sh -c "exec taskset -c $idle_core ${PANKO_EXPIRER_CMD}"
sed -i "/skip_count/s/=.*/=0/" ${PANKO_EXPIRER_INFO}
exit 0
fi
fi
if [ "$skip_count" -lt "3" ]
then
newval=$(($skip_count+1))
sed -i "/skip_count/s/=.*/=$newval/" ${PANKO_EXPIRER_INFO}
exit 0
fi
fi
eval ${PANKO_EXPIRER_CMD}
sed -i "/skip_count/s/=.*/=0/" ${PANKO_EXPIRER_INFO}
fi
exit 0

View File

@ -1 +1 @@
TIS_PATCH_VER=5
TIS_PATCH_VER=6

View File

@ -5,9 +5,8 @@ Subject: [PATCH 1/1] panko config
---
SOURCES/panko-dist.conf | 2 +-
SOURCES/panko-expirer-active | 27 +++++++++++++++++++++++++++
SPECS/openstack-panko.spec | 22 +++++++++++++++++-----
3 files changed, 45 insertions(+), 6 deletions(-)
SPECS/openstack-panko.spec | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 SOURCES/panko-expirer-active
diff --git a/SOURCES/panko-dist.conf b/SOURCES/panko-dist.conf
@ -19,142 +18,66 @@ index c33a2ee..ac6f79f 100644
-log_dir = /var/log/panko
+#log_dir = /var/log/panko
use_stderr = False
diff --git a/SOURCES/panko-expirer-active b/SOURCES/panko-expirer-active
new file mode 100644
index 0000000..7d526e0
--- /dev/null
+++ b/SOURCES/panko-expirer-active
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+#
+# Wrapper script to run panko-expirer when on active controller only
+#
+PANKO_EXPIRER_INFO="/var/run/panko-expirer.info"
+PANKO_EXPIRER_CMD="/usr/bin/nice -n 2 /usr/bin/panko-expirer"
+
+function is_active_pgserver()
+{
+ # Determine whether we're running on the same controller as the service.
+ local service=postgres
+ local enabledactive=$(/usr/bin/sm-query service $service| grep enabled-active)
+ if [ "x$enabledactive" == "x" ]
+ then
+ # enabled-active not found for that service on this controller
+ return 1
+ else
+ # enabled-active found for that resource
+ return 0
+ fi
+}
+
+if is_active_pgserver
+then
+ if [ ! -f ${PANKO_EXPIRER_INFO} ]
+ then
+ echo skip_count=0 > ${PANKO_EXPIRER_INFO}
+ fi
+
+ source ${PANKO_EXPIRER_INFO}
+ sudo -u postgres psql -d sysinv -c "SELECT alarm_id, entity_instance_id from i_alarm;" | grep -P "^(?=.*100.101)(?=.*${HOSTNAME})" &>/dev/null
+ if [ $? -eq 0 ]
+ then
+ source /etc/platform/platform.conf
+ if [ "${system_type}" = "All-in-one" ]
+ then
+ source /etc/init.d/task_affinity_functions.sh
+ idle_core=$(get_most_idle_core)
+ if [ "$idle_core" -ne "0" ]
+ then
+ sh -c "exec taskset -c $idle_core ${PANKO_EXPIRER_CMD}"
+ sed -i "/skip_count/s/=.*/=0/" ${PANKO_EXPIRER_INFO}
+ exit 0
+ fi
+ fi
+
+ if [ "$skip_count" -lt "3" ]
+ then
+ newval=$(($skip_count+1))
+ sed -i "/skip_count/s/=.*/=$newval/" ${PANKO_EXPIRER_INFO}
+ exit 0
+ fi
+ fi
+
+ eval ${PANKO_EXPIRER_CMD}
+ sed -i "/skip_count/s/=.*/=0/" ${PANKO_EXPIRER_INFO}
+fi
+
+exit 0
diff --git a/SPECS/openstack-panko.spec b/SPECS/openstack-panko.spec
index d12da57..90471d9 100644
--- a/SPECS/openstack-panko.spec
+++ b/SPECS/openstack-panko.spec
@@ -4,20 +4,26 @@
@@ -4,20 +4,27 @@
Name: openstack-panko
Version: 3.0.0
-Release: 1%{?dist}
+Release: 1%{?_tis_dist}.%{tis_patch_ver}
Summary: Panko provides Event storage and REST API
License: ASL 2.0
URL: http://github.com/openstack/panko
Source0: https://tarballs.openstack.org/%{pypi_name}/%{pypi_name}-%{upstream_version}.tar.gz
Source1: %{pypi_name}-dist.conf
-Source2: %{pypi_name}.logrotate
+# WRS
+Source2: panko-expirer-active
Source2: %{pypi_name}.logrotate
+
+# WRS: Include patches here
+Patch1: 0001-modify-panko-api.patch
+Patch2: 0002-Change-event-list-descending.patch
+Patch3: 0003-Fix-event-query-to-sqlalchemy-with-non-admin-user.patch
+
BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-pbr
BuildRequires: python2-devel
BuildRequires: openstack-macros
+BuildRequires: python-tenacity >= 3.1.0
%description
HTTP API to store events.
@@ -116,6 +122,9 @@ This package contains documentation files for panko.
@@ -116,6 +123,11 @@ This package contains documentation files for panko.
%prep
%setup -q -n %{pypi_name}-%{upstream_version}
+# WRS: Apply patches here
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+
find . \( -name .gitignore -o -name .placeholder \) -delete
find panko -name \*.py -exec sed -i '/\/usr\/bin\/env python/{d;q}' {} +
@@ -158,6 +167,8 @@ mkdir -p %{buildroot}/%{_var}/log/%{name}
@@ -158,6 +170,8 @@ mkdir -p %{buildroot}/%{_var}/log/%{name}
install -p -D -m 640 %{SOURCE1} %{buildroot}%{_datadir}/panko/panko-dist.conf
install -p -D -m 640 etc/panko/panko.conf %{buildroot}%{_sysconfdir}/panko/panko.conf
install -p -D -m 640 etc/panko/api_paste.ini %{buildroot}%{_sysconfdir}/panko/api_paste.ini
+# WRS
+install -p -D -m 640 panko/api/panko-api.py %{buildroot}%{_datadir}/panko/panko-api.py
#TODO(prad): build the docs at run time, once the we get rid of postgres setup dependency
@@ -169,8 +180,8 @@ install -d -m 755 %{buildroot}%{_sharedstatedir}/panko
install -d -m 755 %{buildroot}%{_sharedstatedir}/panko/tmp
install -d -m 755 %{buildroot}%{_localstatedir}/log/panko
-# Install logrotate
-install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
+# WRS
+install -p -D -m 755 %{SOURCE2} %{buildroot}%{_bindir}/panko-expirer-active
# Remove all of the conf files that are included in the buildroot/usr/etc dir since we installed them above
rm -f %{buildroot}/usr/etc/panko/*
@@ -201,14 +212,15 @@ exit 0
@@ -201,14 +215,15 @@ exit 0
%{_bindir}/panko-api
%{_bindir}/panko-dbsync
%{_bindir}/panko-expirer
+%{_bindir}/panko-expirer-active
%files common
%dir %{_sysconfdir}/panko
+%{_datadir}/panko/panko-api.*
@ -162,10 +85,10 @@ index d12da57..90471d9 100644
%config(noreplace) %attr(-, root, panko) %{_sysconfdir}/panko/policy.json
%config(noreplace) %attr(-, root, panko) %{_sysconfdir}/panko/panko.conf
%config(noreplace) %attr(-, root, panko) %{_sysconfdir}/panko/api_paste.ini
-%config(noreplace) %attr(-, root, panko) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %attr(-, root, panko) %{_sysconfdir}/logrotate.d/%{name}
%dir %attr(0755, panko, root) %{_localstatedir}/log/panko
%defattr(-, panko, panko, -)
--
--
1.8.3.1

View File

@ -1,32 +0,0 @@
From 4e791be412662ae1f97cfd4ff5a90ea6337e49a4 Mon Sep 17 00:00:00 2001
From: Angie Wang <angie.Wang@windriver.com>
Date: Thu, 16 Nov 2017 15:25:08 -0500
Subject: [PATCH 1/1] spec change event list descending
---
SPECS/openstack-panko.spec | 2 ++
1 file changed, 2 insertions(+)
diff --git a/SPECS/openstack-panko.spec b/SPECS/openstack-panko.spec
index 90471d9..95497b4 100644
--- a/SPECS/openstack-panko.spec
+++ b/SPECS/openstack-panko.spec
@@ -16,6 +16,7 @@ Source2: panko-expirer-active
# WRS: Include patches here
Patch1: 0001-modify-panko-api.patch
+Patch2: 0002-Change-event-list-descending.patch
BuildArch: noarch
@@ -124,6 +125,7 @@ This package contains documentation files for panko.
# WRS: Apply patches here
%patch1 -p1
+%patch2 -p1
find . \( -name .gitignore -o -name .placeholder \) -delete
--
1.8.3.1

View File

@ -1,32 +0,0 @@
From aad89aa79de1e9f0b35afa1ba587c10591a889e0 Mon Sep 17 00:00:00 2001
From: Angie Wang <angie.Wang@windriver.com>
Date: Mon, 11 Dec 2017 16:29:23 -0500
Subject: [PATCH 1/1] spec fix event query to sqlalchemy with non admin user
---
SPECS/openstack-panko.spec | 2 ++
1 file changed, 2 insertions(+)
diff --git a/SPECS/openstack-panko.spec b/SPECS/openstack-panko.spec
index 95497b4..87a6a5a 100644
--- a/SPECS/openstack-panko.spec
+++ b/SPECS/openstack-panko.spec
@@ -17,6 +17,7 @@ Source2: panko-expirer-active
# WRS: Include patches here
Patch1: 0001-modify-panko-api.patch
Patch2: 0002-Change-event-list-descending.patch
+Patch3: 0003-Fix-event-query-to-sqlalchemy-with-non-admin-user.patch
BuildArch: noarch
@@ -126,6 +127,7 @@ This package contains documentation files for panko.
# WRS: Apply patches here
%patch1 -p1
%patch2 -p1
+%patch3 -p1
find . \( -name .gitignore -o -name .placeholder \) -delete
--
1.8.3.1

View File

@ -1,3 +1 @@
0001-panko-config.patch
0002-spec-change-event-list-descending.patch
0003-spec-fix-event-query-to-sqlalchemy-with-non-admin-us.patch