Blame SOURCES/rig-fix-rig-list.patch

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