From 25b696df08757b71e75288d37dfe78cae5abd571 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 0cda1dc77ad..b4e6034f64c 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 b8acd1d25a7..512a20883e1 100644 --- a/src/config/svc-monitor/svc_monitor/svc_monitor.py +++ b/src/config/svc-monitor/svc_monitor/svc_monitor.py @@ -696,6 +696,7 @@ def _create_service_instance(self, si): st.virtualization_type) except Exception: cgitb_error_log(self) + si.launch_count += 1 def _delete_service_instance(self, vm): self.logger.log_info("Deleting VM %s %s" % @@ -766,7 +767,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)