|
|
a15636 |
From dedd8733d6cac622903a58cf7a94503cdbd13d88 Mon Sep 17 00:00:00 2001
|
|
|
a15636 |
From: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
a15636 |
Date: Tue, 24 May 2022 12:06:46 -0400
|
|
|
a15636 |
Subject: [PATCH] [BaseRig] Fix fatal error when querying rig list during
|
|
|
a15636 |
pre_action()
|
|
|
a15636 |
|
|
|
a15636 |
If a rig used the sosreport action, and specified `--initial-sos`, *and*
|
|
|
a15636 |
queried `rig list` immediately after the rig was deployed, there was a
|
|
|
a15636 |
race condition where the status query would have failed and terminated
|
|
|
a15636 |
the rig during `pre_action()` execution.
|
|
|
a15636 |
|
|
|
a15636 |
Fix this, by first not detaching until all `pre_action`s are completed,
|
|
|
a15636 |
and second better handle failed `status` queries better generically.
|
|
|
a15636 |
|
|
|
a15636 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
a15636 |
---
|
|
|
a15636 |
rigging/__init__.py | 19 +++++++++++++++----
|
|
|
a15636 |
rigging/rigs/__init__.py | 6 +++---
|
|
|
a15636 |
2 files changed, 18 insertions(+), 7 deletions(-)
|
|
|
a15636 |
|
|
|
a15636 |
diff --git a/rigging/__init__.py b/rigging/__init__.py
|
|
|
a15636 |
index 245d2d1..04ad08e 100644
|
|
|
a15636 |
--- a/rigging/__init__.py
|
|
|
a15636 |
+++ b/rigging/__init__.py
|
|
|
a15636 |
@@ -234,6 +234,7 @@ class RigConnection():
|
|
|
a15636 |
"""
|
|
|
a15636 |
|
|
|
a15636 |
def __init__(self, socket_name):
|
|
|
a15636 |
+ self.name = socket_name
|
|
|
a15636 |
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
|
a15636 |
_address = "/var/run/rig/%s" % socket_name
|
|
|
a15636 |
try:
|
|
|
a15636 |
@@ -278,10 +279,20 @@ class RigConnection():
|
|
|
a15636 |
Returns
|
|
|
a15636 |
dict of rig's status information
|
|
|
a15636 |
"""
|
|
|
a15636 |
- ret = json.loads(self._rig_communicate('status').decode())
|
|
|
a15636 |
- if ret['success']:
|
|
|
a15636 |
- return ast.literal_eval(ret['result'])
|
|
|
a15636 |
- raise Exception
|
|
|
a15636 |
+ try:
|
|
|
a15636 |
+ ret = json.loads(self._rig_communicate('status').decode())
|
|
|
a15636 |
+ if ret['success']:
|
|
|
a15636 |
+ return ast.literal_eval(ret['result'])
|
|
|
a15636 |
+ except Exception as err:
|
|
|
a15636 |
+ print("Error retreiving status for %s: %s" % (self.name, err))
|
|
|
a15636 |
+ return {
|
|
|
a15636 |
+ 'id': self.name,
|
|
|
a15636 |
+ 'pid': '',
|
|
|
a15636 |
+ 'rig_type': '',
|
|
|
a15636 |
+ 'watch': 'Error retrieving status',
|
|
|
a15636 |
+ 'trigger': '',
|
|
|
a15636 |
+ 'status': 'Unknown'
|
|
|
a15636 |
+ }
|
|
|
a15636 |
|
|
|
a15636 |
def info(self):
|
|
|
a15636 |
"""
|
|
|
a15636 |
diff --git a/rigging/rigs/__init__.py b/rigging/rigs/__init__.py
|
|
|
a15636 |
index 1d2f2df..f14f312 100644
|
|
|
a15636 |
--- a/rigging/rigs/__init__.py
|
|
|
a15636 |
+++ b/rigging/rigs/__init__.py
|
|
|
a15636 |
@@ -77,6 +77,7 @@ class BaseRig():
|
|
|
a15636 |
self.resource_name = self.__class__.__name__.lower()
|
|
|
a15636 |
self.parser_usage = self.parser_usage % {'name': self.resource_name}
|
|
|
a15636 |
self.pool = None
|
|
|
a15636 |
+ self.archive_name = None
|
|
|
a15636 |
self.parser = parser
|
|
|
a15636 |
self.restart_count = 0
|
|
|
a15636 |
subparser = self.parser.add_subparsers()
|
|
|
a15636 |
@@ -484,7 +485,6 @@ class BaseRig():
|
|
|
a15636 |
conn.sendall(self._fmt_return(command=req['command'],
|
|
|
a15636 |
output='No such attribute',
|
|
|
a15636 |
success=False))
|
|
|
a15636 |
- continue
|
|
|
a15636 |
|
|
|
a15636 |
def _register_actions(self):
|
|
|
a15636 |
"""
|
|
|
a15636 |
@@ -536,13 +536,13 @@ class BaseRig():
|
|
|
a15636 |
Main entry point for rigs.
|
|
|
a15636 |
"""
|
|
|
a15636 |
try:
|
|
|
a15636 |
+ self.setup()
|
|
|
a15636 |
+ self._register_actions()
|
|
|
a15636 |
# detach from console
|
|
|
a15636 |
if not self.args['foreground']:
|
|
|
a15636 |
print(self.id)
|
|
|
a15636 |
self._detach()
|
|
|
a15636 |
self.detached = True
|
|
|
a15636 |
- self.setup()
|
|
|
a15636 |
- self._register_actions()
|
|
|
a15636 |
if self.detached:
|
|
|
a15636 |
for action in self._actions:
|
|
|
a15636 |
self._actions[action].detached = True
|
|
|
a15636 |
--
|
|
|
a15636 |
2.34.3
|
|
|
a15636 |
|