From 5c17f2a6f0ff7730cbe09b30ec29528f22f14a0f Mon Sep 17 00:00:00 2001 From: Mark Goodwin Date: Fri, 15 Oct 2021 11:39:50 +1100 Subject: [PATCH] fix pmlogger manual start failure when service is disabled --- pcp.spec | 8 +- remove-run-level-check.patch | 183 +++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 remove-run-level-check.patch diff --git a/pcp.spec b/pcp.spec index 12a3750..7b6a8be 100644 --- a/pcp.spec +++ b/pcp.spec @@ -1,6 +1,6 @@ Name: pcp Version: 5.3.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: System-level performance monitoring and performance management License: GPLv2+ and LGPLv2+ and CC-BY URL: https://pcp.io @@ -8,6 +8,8 @@ URL: https://pcp.io %global artifactory https://performancecopilot.jfrog.io/artifactory Source0: %{artifactory}/pcp-source-release/pcp-%{version}.src.tar.gz +Patch0: remove-run-level-check.patch + %if 0%{?fedora} >= 26 || 0%{?rhel} > 7 %global __python2 python2 %else @@ -2263,6 +2265,7 @@ updated policy package. %prep %setup -q +%patch0 -p1 %build # the buildsubdir macro gets defined in %setup and is apparently only available in the next step (i.e. the %build step) @@ -3339,6 +3342,9 @@ PCP_LOG_DIR=%{_logsdir} %files zeroconf -f pcp-zeroconf-files.rpm %changelog +* Fri Oct 15 2021 Mark Goodwin - 5.3.4-2 +- fix pmlogger manual start failure when service is disabled + * Fri Oct 08 2021 Nathan Scott - 5.3.4-1 - Update to latest PCP sources. diff --git a/remove-run-level-check.patch b/remove-run-level-check.patch new file mode 100644 index 0000000..3e67769 --- /dev/null +++ b/remove-run-level-check.patch @@ -0,0 +1,183 @@ +commit b9ff7d65b5e11cae35995495b4177443283c9a31 +Author: Mark Goodwin +Date: Wed Oct 13 12:04:35 2021 +1100 + + services: remove run-level check in pmlogger systemd service config + + Remove the run-level check (pmlogger_check -C flag) since systemd + uses targets for run-level checks. The run-level checks were causing + the pmlogger service to fail to manually start (via systemctl start + pmlogger) when the service is disabled. + + New test qa/1889 checks pmlogger still starts even if disabled (on + systemd platforms only). qa/808 is also reworked since it was running + pmlogger_check directly and was failing every *second* run. + +diff --git a/qa/1889 b/qa/1889 +new file mode 100755 +index 000000000..00b748968 +--- /dev/null ++++ b/qa/1889 +@@ -0,0 +1,68 @@ ++#!/bin/sh ++# PCP QA Test No. 1889 ++# test primary pmlogger starts under systemd when service is disabled ++# ++# Copyright (c) 2021 Red Hat. All Rights Reserved. ++# ++seq=`basename $0` ++echo "QA output created by $seq" ++ ++# get standard environment, filters and checks ++. ./common.product ++. ./common.filter ++. ./common.check ++ ++# this tests systemd starting pmlogger ++which systemctl >/dev/null 2>&1 || _notrun "systemctl not installed" ++ ++_cleanup() ++{ ++ cd $here ++ if [ -n "$pid" ] ++ then ++ $sudo rm -f $PCP_TMP_DIR/pmlogger/$pid $PCP_RUN_DIR/pmlogger.$pid.socket ++ fi ++ $sudo rm -f $PCP_RUN_DIR/pmlogger.pid ++ echo "=== enable pmlogger.service" ++ $sudo systemctl enable pmlogger.service >/dev/null 2>&1 ++ _restore_auto_restart pmlogger ++ _service pmlogger restart | _filter_pcp_start ++ rm -rf $tmp.* ++} ++ ++status=1 # failure is the default! ++$sudo rm -rf $tmp.* $seq.full ++trap "_cleanup; exit \$status" 0 1 2 3 15 ++ ++# real QA test starts here ++_stop_auto_restart pmlogger ++ ++pid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep 'pmlogger.*-P' | \ ++grep -v grep | awk '{print $2}'` ++ ++if [ ! -S "$PCP_RUN_DIR/pmlogger.$pid.socket" ]; then ++ echo FAIL no primary pmlogger running? pid=$pid ++ status=1 ++ exit ++fi ++echo found primary pmlogger and found control socket in PCP_RUN_DIR ++ ++echo "=== disable pmlogger.service" | tee -a $seq.full ++$sudo systemctl disable pmlogger.service >>$seq.full 2>&1 ++ ++echo === start primary logger whilst disabled === ++_service pmlogger start | _filter_pcp_start ++_wait_for_pmlogger ++ ++newpid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep 'pmlogger.*-P' | \ ++ grep -v grep | awk '{print $2}'` ++ ++if [ -z "$newpid" ]; then ++ echo FAIL pmlogger failed to start whilst disabled ++ status=1 ++ exit ++fi ++echo found primary pmlogger and found control socket in PCP_RUN_DIR ++status=0 ++ ++exit +diff --git a/qa/1889.out b/qa/1889.out +new file mode 100644 +index 000000000..67d0e457f +--- /dev/null ++++ b/qa/1889.out +@@ -0,0 +1,6 @@ ++QA output created by 1889 ++found primary pmlogger and found control socket in PCP_RUN_DIR ++=== disable pmlogger.service ++=== start primary logger whilst disabled === ++found primary pmlogger and found control socket in PCP_RUN_DIR ++=== enable pmlogger.service +diff --git a/qa/808 b/qa/808 +index 6b0b64a7e..f1c796ee9 100755 +--- a/qa/808 ++++ b/qa/808 +@@ -53,9 +53,9 @@ else + done + $sudo kill -0 $pid >/dev/null 2>&1 && echo "Arrggh, pid $pid won't die!" + +- echo === running pmlogger_check to restart primary logger === +- $sudo $PCP_BINADM_DIR/pmlogger_check -C +- sleep 2 ++ echo === restart primary logger === ++ _service pmlogger start | _filter_pcp_start ++ _wait_for_pmlogger + + newpid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep 'pmlogger.*-P' | \ + grep -v grep | awk '{print $2}'` +@@ -98,9 +98,9 @@ else + $sudo rm -f $PCP_RUN_DIR/pmlogger.primary.socket + $sudo ln $PCP_RUN_DIR/pmlogger.$pid.socket $PCP_RUN_DIR/pmlogger.primary.socket + +- echo === running pmlogger_check to restart primary logger === +- $sudo $PCP_BINADM_DIR/pmlogger_check -C +- sleep 2 ++ echo === restart primary logger === ++ _service pmlogger start | _filter_pcp_start ++ _wait_for_pmlogger + + newpid=`$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep 'pmlogger.*-P' | \ + grep -v grep | awk '{print $2}'` +diff --git a/qa/808.out b/qa/808.out +index fdd386503..be2f16086 100644 +--- a/qa/808.out ++++ b/qa/808.out +@@ -1,7 +1,7 @@ + QA output created by 808 + found primary pmlogger and found control socket in PCP_RUN_DIR + === killing the primary pmlogger with SIGKILL === +-=== running pmlogger_check to restart primary logger === ++=== restart primary logger === + === checking with stale legacy hard links + === killing the primary pmlogger with SIGKILL === +-=== running pmlogger_check to restart primary logger === ++=== restart primary logger === +diff --git a/qa/group b/qa/group +index 7b50c353e..3f2033f53 100644 +--- a/qa/group ++++ b/qa/group +@@ -1946,6 +1946,7 @@ x11 + 1874 pmseries pmproxy local + 1876 pmcd secure local + 1886 pmseries libpcp_web local ++1889 pmlogger local + 1893 pmda.proc local + 1895 pmda.bpf local + 1896 pmlogger logutil pmlc local +diff --git a/src/pmlogger/pmlogger.service.in b/src/pmlogger/pmlogger.service.in +index 19b904cff..c24143734 100644 +--- a/src/pmlogger/pmlogger.service.in ++++ b/src/pmlogger/pmlogger.service.in +@@ -9,7 +9,7 @@ Wants=pmcd.service + [Service] + Type=notify + NotifyAccess=all +-Environment="PMLOGGER_CHECK_PARAMS=-C --only-primary" ++Environment="PMLOGGER_CHECK_PARAMS=--only-primary" + EnvironmentFile=-@PCP_SYSCONFIG_DIR@/pmlogger + TimeoutStartSec=120 + TimeoutStopSec=120 +diff --git a/src/pmlogger/pmlogger_check.service.in b/src/pmlogger/pmlogger_check.service.in +index af58997f3..ef24d30a5 100644 +--- a/src/pmlogger/pmlogger_check.service.in ++++ b/src/pmlogger/pmlogger_check.service.in +@@ -13,7 +13,7 @@ TimeoutStopSec=120 + # which is timer driven and exits. KillMode is temporary and will + # not be necessary once we have pmlogger-farm.service. + KillMode=process +-Environment="PMLOGGER_CHECK_PARAMS=-C --skip-primary" ++Environment="PMLOGGER_CHECK_PARAMS=--skip-primary" + EnvironmentFile=-@PCP_SYSCONFIG_DIR@/pmlogger_timers + ExecStart=@PCP_BINADM_DIR@/pmlogger_check $PMLOGGER_CHECK_PARAMS + WorkingDirectory=@PCP_VAR_DIR@