Backport patch for rig list race condition
Related: RHBZ#2077096 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
This commit is contained in:
parent
fdc84bf7b9
commit
dfa825f3dd
96
rig-fix-rig-list.patch
Normal file
96
rig-fix-rig-list.patch
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
From dedd8733d6cac622903a58cf7a94503cdbd13d88 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Hunsaker <jhunsake@redhat.com>
|
||||||
|
Date: Tue, 24 May 2022 12:06:46 -0400
|
||||||
|
Subject: [PATCH] [BaseRig] Fix fatal error when querying rig list during
|
||||||
|
pre_action()
|
||||||
|
|
||||||
|
If a rig used the sosreport action, and specified `--initial-sos`, *and*
|
||||||
|
queried `rig list` immediately after the rig was deployed, there was a
|
||||||
|
race condition where the status query would have failed and terminated
|
||||||
|
the rig during `pre_action()` execution.
|
||||||
|
|
||||||
|
Fix this, by first not detaching until all `pre_action`s are completed,
|
||||||
|
and second better handle failed `status` queries better generically.
|
||||||
|
|
||||||
|
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
||||||
|
---
|
||||||
|
rigging/__init__.py | 19 +++++++++++++++----
|
||||||
|
rigging/rigs/__init__.py | 6 +++---
|
||||||
|
2 files changed, 18 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/rigging/__init__.py b/rigging/__init__.py
|
||||||
|
index 245d2d1..04ad08e 100644
|
||||||
|
--- a/rigging/__init__.py
|
||||||
|
+++ b/rigging/__init__.py
|
||||||
|
@@ -234,6 +234,7 @@ class RigConnection():
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, socket_name):
|
||||||
|
+ self.name = socket_name
|
||||||
|
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
|
_address = "/var/run/rig/%s" % socket_name
|
||||||
|
try:
|
||||||
|
@@ -278,10 +279,20 @@ class RigConnection():
|
||||||
|
Returns
|
||||||
|
dict of rig's status information
|
||||||
|
"""
|
||||||
|
- ret = json.loads(self._rig_communicate('status').decode())
|
||||||
|
- if ret['success']:
|
||||||
|
- return ast.literal_eval(ret['result'])
|
||||||
|
- raise Exception
|
||||||
|
+ try:
|
||||||
|
+ ret = json.loads(self._rig_communicate('status').decode())
|
||||||
|
+ if ret['success']:
|
||||||
|
+ return ast.literal_eval(ret['result'])
|
||||||
|
+ except Exception as err:
|
||||||
|
+ print("Error retreiving status for %s: %s" % (self.name, err))
|
||||||
|
+ return {
|
||||||
|
+ 'id': self.name,
|
||||||
|
+ 'pid': '',
|
||||||
|
+ 'rig_type': '',
|
||||||
|
+ 'watch': 'Error retrieving status',
|
||||||
|
+ 'trigger': '',
|
||||||
|
+ 'status': 'Unknown'
|
||||||
|
+ }
|
||||||
|
|
||||||
|
def info(self):
|
||||||
|
"""
|
||||||
|
diff --git a/rigging/rigs/__init__.py b/rigging/rigs/__init__.py
|
||||||
|
index 1d2f2df..f14f312 100644
|
||||||
|
--- a/rigging/rigs/__init__.py
|
||||||
|
+++ b/rigging/rigs/__init__.py
|
||||||
|
@@ -77,6 +77,7 @@ class BaseRig():
|
||||||
|
self.resource_name = self.__class__.__name__.lower()
|
||||||
|
self.parser_usage = self.parser_usage % {'name': self.resource_name}
|
||||||
|
self.pool = None
|
||||||
|
+ self.archive_name = None
|
||||||
|
self.parser = parser
|
||||||
|
self.restart_count = 0
|
||||||
|
subparser = self.parser.add_subparsers()
|
||||||
|
@@ -484,7 +485,6 @@ class BaseRig():
|
||||||
|
conn.sendall(self._fmt_return(command=req['command'],
|
||||||
|
output='No such attribute',
|
||||||
|
success=False))
|
||||||
|
- continue
|
||||||
|
|
||||||
|
def _register_actions(self):
|
||||||
|
"""
|
||||||
|
@@ -536,13 +536,13 @@ class BaseRig():
|
||||||
|
Main entry point for rigs.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
+ self.setup()
|
||||||
|
+ self._register_actions()
|
||||||
|
# detach from console
|
||||||
|
if not self.args['foreground']:
|
||||||
|
print(self.id)
|
||||||
|
self._detach()
|
||||||
|
self.detached = True
|
||||||
|
- self.setup()
|
||||||
|
- self._register_actions()
|
||||||
|
if self.detached:
|
||||||
|
for action in self._actions:
|
||||||
|
self._actions[action].detached = True
|
||||||
|
--
|
||||||
|
2.34.3
|
||||||
|
|
8
rig.spec
8
rig.spec
@ -1,7 +1,7 @@
|
|||||||
Name: rig
|
Name: rig
|
||||||
Summary: Monitor a system for events and trigger specific actions
|
Summary: Monitor a system for events and trigger specific actions
|
||||||
Version: 1.1
|
Version: 1.1
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
Url: https://github.com/TurboTurtle/rig
|
Url: https://github.com/TurboTurtle/rig
|
||||||
Source0: %{url}/archive/%{name}-%{version}.tar.gz
|
Source0: %{url}/archive/%{name}-%{version}.tar.gz
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
@ -12,6 +12,8 @@ BuildRequires: python3-setuptools
|
|||||||
BuildRequires: python3dist(systemd-python)
|
BuildRequires: python3dist(systemd-python)
|
||||||
BuildRequires: python3dist(psutil)
|
BuildRequires: python3dist(psutil)
|
||||||
|
|
||||||
|
Patch1: rig-fix-rig-list.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Rig is a utility designed to watch or monitor specific system resources (e.g.
|
Rig is a utility designed to watch or monitor specific system resources (e.g.
|
||||||
log files, journals, system activity, etc...) and then take specific action
|
log files, journals, system activity, etc...) and then take specific action
|
||||||
@ -20,6 +22,7 @@ troubleshooting and data collection for randomly occurring events.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
|
%patch1 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%py3_build
|
%py3_build
|
||||||
@ -40,6 +43,9 @@ install -p -m644 man/en/rig.1 ${RPM_BUILD_ROOT}%{_mandir}/man1/
|
|||||||
%doc README.md
|
%doc README.md
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
Tue May 31 2022 Jake Hunsaker <jhunsake@redhat.com> - 1.1-3
|
||||||
|
- Backport fix for rig list race condition
|
||||||
|
|
||||||
* Fri May 04 2022 Jake Hunsaker <jhunsake@redhat.com> - 1.1-2
|
* Fri May 04 2022 Jake Hunsaker <jhunsake@redhat.com> - 1.1-2
|
||||||
- Rebase to version 1.1
|
- Rebase to version 1.1
|
||||||
Related: RHBZ#2077096
|
Related: RHBZ#2077096
|
||||||
|
Loading…
Reference in New Issue
Block a user