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

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