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