From: bravof Date: Thu, 25 Jun 2020 21:30:55 +0000 (-0400) Subject: Bug 1106 : Kill processes still running after join call timeout reached, also timeout... X-Git-Tag: v8.0.1rc1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=a4adf09ea1752ef6b71b56702c645ddc3cd95ad1;p=osm%2FMON.git Bug 1106 : Kill processes still running after join call timeout reached, also timeouts added to nova and keystone clients. Join timeout increased from 10 to 20 Change-Id: I9fce3b4c4322d717a93207d9c34136ba75108a3e Signed-off-by: bravof (cherry picked from commit d9e56359b64a3934ea5eb7c18bc517c4fc9fa160) --- diff --git a/osm_mon/collector/infra_collectors/base_osinfra.py b/osm_mon/collector/infra_collectors/base_osinfra.py index bce363c..050e525 100644 --- a/osm_mon/collector/infra_collectors/base_osinfra.py +++ b/osm_mon/collector/infra_collectors/base_osinfra.py @@ -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) diff --git a/osm_mon/collector/service.py b/osm_mon/collector/service.py index c04f548..7673aed 100644 --- a/osm_mon/collector/service.py +++ b/osm_mon/collector/service.py @@ -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()) diff --git a/osm_mon/collector/utils/openstack.py b/osm_mon/collector/utils/openstack.py index 2ec85be..09c472c 100644 --- a/osm_mon/collector/utils/openstack.py +++ b/osm_mon/collector/utils/openstack.py @@ -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) diff --git a/osm_mon/tests/unit/collector/utils/test_openstack.py b/osm_mon/tests/unit/collector/utils/test_openstack.py index 76adc55..7cfa4bf 100644 --- a/osm_mon/tests/unit/collector/utils/test_openstack.py +++ b/osm_mon/tests/unit/collector/utils/test_openstack.py @@ -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)