From dd27bc86c13aaa9f678563e2e24df9559d031ea1 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Thu, 30 Apr 2015 14:53:14 +0800 Subject: [PATCH] Make the number machines to be reserved configurable Signed-off-by: Yuan Zhou --- docs/siteconfig.rst | 4 ++++ teuthology/config.py | 1 + teuthology/task/internal.py | 4 +++- teuthology/test/test_config.py | 11 +++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/siteconfig.rst b/docs/siteconfig.rst index 1ec42e802e..a4895fa0f8 100644 --- a/docs/siteconfig.rst +++ b/docs/siteconfig.rst @@ -18,6 +18,10 @@ Here is a sample configuration with many of the options set and documented:: # only used by teuthology-suite. default_machine_type: awesomebox + # Control how many machines need to be free in the cluster. 0 means + # Teuthology can use the entire cluster. + reserve_machines: 5 + # The host and port to use for the beanstalkd queue. This is required # for scheduled jobs. queue_host: localhost diff --git a/teuthology/config.py b/teuthology/config.py index 9ccd024e0e..145ee97deb 100644 --- a/teuthology/config.py +++ b/teuthology/config.py @@ -127,6 +127,7 @@ class TeuthologyConfig(YamlConfig): _defaults = { 'archive_base': '/var/lib/teuthworker/archive', 'automated_scheduling': False, + 'reserve_machines': 5, 'ceph_git_base_url': 'https://github.com/ceph/', 'gitbuilder_host': 'gitbuilder.ceph.com', 'lab_domain': 'front.sepia.ceph.com', diff --git a/teuthology/task/internal.py b/teuthology/task/internal.py index e850be4991..6ba2f69e70 100644 --- a/teuthology/task/internal.py +++ b/teuthology/task/internal.py @@ -78,7 +78,9 @@ def lock_machines(ctx, config): machine_type = config[1] how_many = config[0] # We want to make sure there are always this many machines available - to_reserve = 5 + to_reserve = teuth_config.reserve_machines + assert isinstance(to_reserve, int), 'reserve_machines must be integer' + assert (to_reserve >= 0), 'reserve_machines should >= 0' # change the status during the locking process report.try_push_job_info(ctx.config, dict(status='waiting')) diff --git a/teuthology/test/test_config.py b/teuthology/test/test_config.py index c3853739d2..fee44bf1f2 100644 --- a/teuthology/test/test_config.py +++ b/teuthology/test/test_config.py @@ -87,6 +87,17 @@ class TestTeuthologyConfig(TestYamlConfig): "git://git.ceph.com/" assert conf_obj.ceph_git_base_url == "git://git.ceph.com/" + def test_get_reserve_machines_default(self): + conf_obj = self.test_class() + conf_obj.yaml_path = '' + conf_obj.load() + assert conf_obj.reserve_machines == 5 + + def test_set_reserve_machines_via_private(self): + conf_obj = self.test_class() + conf_obj._conf['reserve_machines'] = 2 + assert conf_obj.reserve_machines == 2 + def test_set_nonstandard(self): conf_obj = self.test_class() conf_obj.something = 'something else' -- 2.39.5