Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit f801e5809371feb7aad5a188830995bc2da164c0
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Apr 16 16:05:50 2015 +0200
[backend] replaced Thresholds.dirty_vm_terminating_timeout with config option
vm_dirty_terminating_timeout
---------------------------------------------------------------
backend/backend/daemons/vm_master.py | 2 +-
backend/backend/helpers.py | 4 +++-
backend/backend/vm_manage/__init__.py | 1 -
backend/backend/vm_manage/models.py | 4 ++--
backend/tests/deamons/test_vm_master.py | 5 ++++-
5 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/backend/backend/daemons/vm_master.py b/backend/backend/daemons/vm_master.py
index 7f3bbe0..bc4080f 100644
--- a/backend/backend/daemons/vm_master.py
+++ b/backend/backend/daemons/vm_master.py
@@ -49,7 +49,7 @@ class VmMaster(Process):
if last_release is None:
continue
not_re_acquired_in = time.time() - float(last_release)
- if not_re_acquired_in > Thresholds.dirty_vm_terminating_timeout:
+ if not_re_acquired_in >
self.opts.build_groups[vmd.group]["vm_dirty_terminating_timeout"]:
self.log.info("dirty VM `{}` not re-acquired in {}, terminating
it"
.format(vmd.vm_name, not_re_acquired_in))
self.vmm.start_vm_termination(vmd.vm_name,
allowed_pre_state=VmStates.READY)
diff --git a/backend/backend/helpers.py b/backend/backend/helpers.py
index dc97854..e6571d6 100644
--- a/backend/backend/helpers.py
+++ b/backend/backend/helpers.py
@@ -163,7 +163,9 @@ class BackendConfigReader(object):
"vm_spawn_min_interval": _get_conf(
cp, "backend",
"group{}_vm_spawn_min_interval".format(group_id),
default=30, mode="int"),
-
+ "vm_dirty_terminating_timeout": _get_conf(
+ cp, "backend",
"group{}_vm_dirty_terminating_timeout".format(group_id),
+ default=120, mode="int"),
}
opts.build_groups.append(group)
diff --git a/backend/backend/vm_manage/__init__.py
b/backend/backend/vm_manage/__init__.py
index 2532853..d2f781a 100644
--- a/backend/backend/vm_manage/__init__.py
+++ b/backend/backend/vm_manage/__init__.py
@@ -47,5 +47,4 @@ class Thresholds(object):
health_check_max_time = 120 # [s.] if health check wasn't done for this
time, mark check fail
max_check_fails = 2 # maximum number of fails before starting VM
termination
terminating_timeout = 600 # [s.] time before we try to terminate VM again
- dirty_vm_terminating_timeout = 20 # [s.] how long we keep released vms
cycle_timeout = 10 # [s.] timeout for all periodical checks
diff --git a/backend/backend/vm_manage/models.py b/backend/backend/vm_manage/models.py
index de72b72..17b4a0f 100644
--- a/backend/backend/vm_manage/models.py
+++ b/backend/backend/vm_manage/models.py
@@ -10,7 +10,7 @@ class VmDescriptor(object):
self.vm_ip = vm_ip
self.vm_name = vm_name
self.state = state
- self.group = group
+ self.group = int(group)
self.check_fails = 0
@@ -34,7 +34,7 @@ class VmDescriptor(object):
@classmethod
def from_dict(cls, raw):
- vmd = cls(raw["vm_ip"], raw["vm_name"],
raw["group"], raw["state"])
+ vmd = cls(raw.pop("vm_ip"), raw.pop("vm_name"),
raw.pop("group"), raw.pop("state"))
vmd.__dict__.update(raw)
return vmd
diff --git a/backend/tests/deamons/test_vm_master.py
b/backend/tests/deamons/test_vm_master.py
index 61edf8e..b31e397 100644
--- a/backend/tests/deamons/test_vm_master.py
+++ b/backend/tests/deamons/test_vm_master.py
@@ -91,11 +91,13 @@ class TestVmMaster(object):
"max_vm_total": 5,
"max_spawn_processes": 3,
"vm_spawn_min_interval": self.vm_spawn_min_interval,
+ "vm_dirty_terminating_timeout": 120,
},
1: {
"name": "arm",
"archs": ["armV7"],
"vm_spawn_min_interval": self.vm_spawn_min_interval,
+ "vm_dirty_terminating_timeout": 120,
}
},
@@ -187,7 +189,8 @@ class TestVmMaster(object):
self.vm_master.remove_old_dirty_vms()
assert not self.vmm.start_vm_termination.called
- mc_time.time.return_value = Thresholds.dirty_vm_terminating_timeout + 1
+ mc_time.time.return_value =
self.opts.build_groups[0]["vm_dirty_terminating_timeout"] + 1
+
# only "a1" and "b1" should be terminated
self.vm_master.remove_old_dirty_vms()
assert self.vmm.start_vm_termination.called