From e775941788c27404a1fe0e315ce28618557c3ec1 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 6 Apr 2022 21:56:23 +0200
Subject: [PATCH] L2SS-722: Forget about removing attributes as that is broken
 in hdbpp at the moment.

---
 .../default/toolkit/test_archiver.py              | 10 +++++++++-
 .../tangostationcontrol/toolkit/archiver.py       | 15 +++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py b/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py
index 2c9fc2650..1ead9d257 100644
--- a/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py
+++ b/tangostationcontrol/tangostationcontrol/integration_test/default/toolkit/test_archiver.py
@@ -55,10 +55,12 @@ class TestArchiver(BaseIntegrationTestCase):
         recv_proxy.set_defaults()
         recv_proxy.on()
         self.assertEqual(DevState.ON, recv_proxy.state())
-        
+
+        """
         # Safety operation that prevents event subscriber to go in Fault state
         self.archiver.remove_attributes_in_error()
         time.sleep(3)
+        """
         attr_fullname = 'stat/recv/1/recvtr_translator_busy_r'  # boolean
         self.archiver.add_attribute_to_archiver(attr_fullname, polling_period=1000, archive_event_period=3000)
         time.sleep(3)
@@ -76,11 +78,13 @@ class TestArchiver(BaseIntegrationTestCase):
         self.assertEqual(datetime,type(item.data_time))           # column datetime
         self.assertEqual(bool,type(item.value))                   # column value
 
+        """
         # Remove attribute at the end of the test
         self.archiver.remove_attribute_from_archiver(attr_fullname)
         time.sleep(3)
         # Test if the attribute has been correctly removed
         self.assertFalse(self.archiver.is_attribute_archived(attribute_fqdn(attr_fullname)))
+        """
         recv_proxy.off()
     
     def test_archive_array_attribute(self):
@@ -96,9 +100,11 @@ class TestArchiver(BaseIntegrationTestCase):
         sdp_proxy.on()
         self.assertEqual(DevState.ON, sdp_proxy.state())
 
+        """
         # Safety operation that prevents event subscriber to go in Fault state
         self.archiver.remove_attributes_in_error()
         time.sleep(3)
+        """
         attr_fullname = 'stat/sdp/1/fpga_temp_r'  # double
         self.archiver.add_attribute_to_archiver(attr_fullname, polling_period=1000, archive_event_period=3000)
         time.sleep(3)
@@ -117,11 +123,13 @@ class TestArchiver(BaseIntegrationTestCase):
         self.assertEqual(int,type(item.x))                                  # column index
         self.assertEqual(float,type(item.value))                            # column value
 
+        """
         # Remove attribute at the end of the test
         self.archiver.remove_attribute_from_archiver(attr_fullname)
         time.sleep(3)
         # Test if the attribute has been correctly removed
         self.assertFalse(self.archiver.is_attribute_archived(attribute_fqdn(attr_fullname)))
+        """
         sdp_proxy.off()
     
     def test_get_maximum_device_load(self):
diff --git a/tangostationcontrol/tangostationcontrol/toolkit/archiver.py b/tangostationcontrol/tangostationcontrol/toolkit/archiver.py
index 3b78af4ae..2e178083d 100644
--- a/tangostationcontrol/tangostationcontrol/toolkit/archiver.py
+++ b/tangostationcontrol/tangostationcontrol/toolkit/archiver.py
@@ -25,8 +25,8 @@ def warn_if_attribute_not_found():
             try:
                 return func(self, attribute_name, *args, **kwargs)
             except DevFailed as e:
-                if e.args[0].reason == 'Attribute not found' or 'NOT FOUND in signal list':
-                    logger.warning(f"Attribute {attribute_name} not found!")
+                if e.args[0].reason in ['Attribute not found', 'BadSignalName']:
+                    logger.warning(f"Attribute {attribute_name} not found: {e.args[0].desc}")
                 else:
                     raise
 
@@ -59,7 +59,7 @@ class Archiver():
         self.cm = DeviceProxy(cm_name)
         try: 
             if self.cm.state() == DevState.FAULT:
-                raise Exception(f"Configuration Manager {cm_name} is in FAULT state")
+                raise Exception(f"Configuration Manager {cm_name} is in FAULT state: {self.cm.status()}")
         except Exception as e:
             raise Exception(f"Connection failed with Configuration Manager {cm_name}") from e
         self.es_list = [es_name for es_name in self.get_subscribers(from_db=False)]
@@ -145,7 +145,8 @@ class Archiver():
         dev_polling_time, dev_archive_abs_change, dev_archive_rel_change, dev_archive_period, dev_event_period, dev_strategy = get_global_env_parameters(config_dict, environment)
         # Attributes to be included in archiving stategy
         include_att_list = get_include_attribute_list(device, config_dict, environment)
-        self.remove_attributes_by_device(device, exclude=include_att_list)
+        # TODO Cleanup the subscriber
+        # self.remove_attributes_by_device(device, exclude=include_att_list)
         # Include attributes by custom configuration
         try:        
             for att in include_att_list:
@@ -281,6 +282,10 @@ class Archiver():
         """
         Stops the data archiving of the attribute passed as input, and remove it from the subscriber's list. 
         """
+
+        # Removal of attributes leads to hdbpp-es freezing up, see https://github.com/tango-controls-hdbpp/hdbpp-es/issues/25
+        raise NotImplementedError("Removing attributes is not supported yet")
+
         attribute_name = attribute_fqdn(attribute_name)
         self.cm.AttributeStop(attribute_name)
         self.cm.AttributeRemove(attribute_name)
@@ -341,6 +346,7 @@ class Archiver():
         Starts the archiving of the attribute passed as input.
         The attribute must be already present in the subscriber's list
         """
+        attribute_name = attribute_fqdn(attribute_name)
         self.cm.AttributeStart(attribute_name)
     
     @warn_if_attribute_not_found()
@@ -349,6 +355,7 @@ class Archiver():
         Stops the archiving of the attribute passed as input.
         The attribute must be already present in the subscriber's list
         """
+        attribute_name = attribute_fqdn(attribute_name)
         self.cm.AttributeStop(attribute_name)
     
     def is_attribute_archived(self, attribute_name:str):
-- 
GitLab