Bug 1106 : Kill processes still running after join call timeout reached, also timeout... 90/9190/3
authorbravof <fbravo@whitestack.com>
Thu, 25 Jun 2020 21:30:55 +0000 (17:30 -0400)
committerbravof <fbravo@whitestack.com>
Thu, 25 Jun 2020 21:47:08 +0000 (17:47 -0400)
Change-Id: I9fce3b4c4322d717a93207d9c34136ba75108a3e
Signed-off-by: bravof <fbravo@whitestack.com>
osm_mon/collector/infra_collectors/base_osinfra.py
osm_mon/collector/service.py
osm_mon/collector/utils/openstack.py
osm_mon/tests/unit/collector/utils/test_openstack.py

index bce363c..050e525 100644 (file)
@@ -100,8 +100,8 @@ class BaseOpenStackInfraCollector(BaseVimInfraCollector):
 
     def _build_keystone_client(self, vim_account: dict) -> keystone_client.Client:
         sess = OpenstackUtils.get_session(vim_account)
-        return keystone_client.Client(session=sess)
+        return keystone_client.Client(session=sess, timeout=10)
 
     def _build_nova_client(self, vim_account: dict) -> nova_client.Client:
         sess = OpenstackUtils.get_session(vim_account)
-        return nova_client.Client("2", session=sess)
+        return nova_client.Client("2", session=sess, timeout=10)
index c04f548..7673aed 100644 (file)
@@ -127,7 +127,10 @@ class CollectorService:
             processes.append(p)
             p.start()
         for process in processes:
-            process.join(timeout=10)
+            process.join(timeout=20)
+        for process in processes:
+            if process.is_alive():
+                process.kill()
         metrics = []
         while not self.queue.empty():
             metrics.append(self.queue.get())
index 2ec85be..09c472c 100644 (file)
@@ -49,4 +49,4 @@ class OpenstackUtils:
                            project_name=creds['vim_tenant_name'],
                            project_domain_name=project_domain_name,
                            user_domain_name=user_domain_name)
-        return session.Session(auth=auth, verify=verify_ssl)
+        return session.Session(auth=auth, verify=verify_ssl, timeout=10)
index 76adc55..7cfa4bf 100644 (file)
@@ -43,7 +43,7 @@ class OpenstackUtilsTest(TestCase):
         OpenstackUtils.get_session(creds)
 
         mock_session.Session.assert_called_once_with(
-            auth=mock.ANY, verify=True)
+            auth=mock.ANY, verify=True, timeout=10)
 
     def test_session_with_insecure(self, mock_session):
         creds = {
@@ -58,7 +58,7 @@ class OpenstackUtilsTest(TestCase):
         OpenstackUtils.get_session(creds)
 
         mock_session.Session.assert_called_once_with(
-            auth=mock.ANY, verify=False)
+            auth=mock.ANY, verify=False, timeout=10)
 
     def test_session_with_insecure_false(self, mock_session):
         creds = {
@@ -72,4 +72,4 @@ class OpenstackUtilsTest(TestCase):
         }
         OpenstackUtils.get_session(creds)
         mock_session.Session.assert_called_once_with(
-            auth=mock.ANY, verify=True)
+            auth=mock.ANY, verify=True, timeout=10)