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

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