From c65a703f3e677accff3ad4f44444581d064b9fc5 Mon Sep 17 00:00:00 2001 From: Rudra Rugge Date: Tue, 23 Jun 2015 12:26:03 -0700 Subject: [PATCH] Port in use error caused by gevent threads If the first launch of a service VM coincides with the timer for service instance check then there is a possibility that the same port might be used to launch service VMs. Added mutual exclusion to ensure that the timer check only happens after the first launch. Change-Id: Ieef15683f20e08cd1df221ff17a0c9fed4cf6b89 Closes-Bug: #1463745 --- src/config/svc-monitor/svc_monitor/config_db.py | 1 + src/config/svc-monitor/svc_monitor/svc_monitor.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/svc-monitor/svc_monitor/config_db.py b/src/config/svc-monitor/svc_monitor/config_db.py index 181f1ace8b9..4490e2a03e2 100644 --- a/src/config/svc-monitor/svc_monitor/config_db.py +++ b/src/config/svc-monitor/svc_monitor/config_db.py @@ -317,6 +317,7 @@ def __init__(self, uuid, obj_dict=None): self.virtual_machines = set() self.params = None self.state = 'init' + self.launch_count = 0 self.image = None self.flavor = None self.max_instances = 0 diff --git a/src/config/svc-monitor/svc_monitor/svc_monitor.py b/src/config/svc-monitor/svc_monitor/svc_monitor.py index d7874340ee6..251e3fcb2c1 100644 --- a/src/config/svc-monitor/svc_monitor/svc_monitor.py +++ b/src/config/svc-monitor/svc_monitor/svc_monitor.py @@ -719,6 +719,7 @@ def _create_service_instance(self, si): st.virtualization_type) except Exception: cgitb_error_log(self) + si.launch_count += 1 self.logger.log_info("SI %s creation succeed" % (':').join(si.fq_name)) def _delete_service_instance(self, vm): @@ -790,7 +791,7 @@ def timer_callback(monitor): si_id_list = list(ServiceInstanceSM._dict.keys()) for si_id in si_id_list: si = ServiceInstanceSM.get(si_id) - if not si: + if not si or not si.launch_count: continue if not monitor._check_service_running(si): monitor._relaunch_service_instance(si)