From b6b7578190bc5de266d08c22984622d5566b8456 Mon Sep 17 00:00:00 2001 From: "Lisak, Peter" Date: Tue, 13 Oct 2015 17:00:41 +0200 Subject: [PATCH] node_timeout as float in configs It is more convenient to use float node_timeout for fine tunning latency. Change-Id: I7c57bba053711a27d3802efe6f2a0bf53483a54f --- doc/source/development_auth.rst | 2 +- swift/account/reaper.py | 2 +- swift/common/db_replicator.py | 2 +- swift/container/server.py | 2 +- swift/container/updater.py | 2 +- swift/obj/updater.py | 2 +- swift/proxy/server.py | 4 ++-- test/unit/account/test_reaper.py | 5 +++++ test/unit/common/test_db_replicator.py | 5 +++++ test/unit/container/test_server.py | 6 ++++++ test/unit/container/test_updater.py | 4 ++-- test/unit/obj/test_updater.py | 4 ++-- test/unit/proxy/test_server.py | 10 ++++++++++ 13 files changed, 38 insertions(+), 12 deletions(-) diff --git a/doc/source/development_auth.rst b/doc/source/development_auth.rst index e913850b5a..bb00ca8fc7 100644 --- a/doc/source/development_auth.rst +++ b/doc/source/development_auth.rst @@ -352,7 +352,7 @@ folks a start on their own code if they want to use repoze.what:: self.ssl = \ conf.get('ssl', 'false').lower() in ('true', 'on', '1', 'yes') self.auth_prefix = conf.get('prefix', '/') - self.timeout = int(conf.get('node_timeout', 10)) + self.timeout = float(conf.get('node_timeout', 10)) def authenticate(self, env, identity): token = identity.get('token') diff --git a/swift/account/reaper.py b/swift/account/reaper.py index e8c8fd03e9..3250cd3ca9 100644 --- a/swift/account/reaper.py +++ b/swift/account/reaper.py @@ -70,7 +70,7 @@ class AccountReaper(Daemon): self.account_ring = None self.container_ring = None self.object_ring = None - self.node_timeout = int(conf.get('node_timeout', 10)) + self.node_timeout = float(conf.get('node_timeout', 10)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) self.myips = whataremyips(conf.get('bind_ip', '0.0.0.0')) self.bind_port = int(conf.get('bind_port', 0)) diff --git a/swift/common/db_replicator.py b/swift/common/db_replicator.py index 54f55a2375..589faa4e69 100644 --- a/swift/common/db_replicator.py +++ b/swift/common/db_replicator.py @@ -166,7 +166,7 @@ class Replicator(Daemon): self.max_diffs = int(conf.get('max_diffs') or 100) self.interval = int(conf.get('interval') or conf.get('run_pause') or 30) - self.node_timeout = int(conf.get('node_timeout', 10)) + self.node_timeout = float(conf.get('node_timeout', 10)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) self.rsync_compress = config_true_value( conf.get('rsync_compress', 'no')) diff --git a/swift/container/server.py b/swift/container/server.py index 293d27f489..821ab9b188 100644 --- a/swift/container/server.py +++ b/swift/container/server.py @@ -86,7 +86,7 @@ class ContainerController(BaseStorageServer): self.log_requests = config_true_value(conf.get('log_requests', 'true')) self.root = conf.get('devices', '/srv/node') self.mount_check = config_true_value(conf.get('mount_check', 'true')) - self.node_timeout = int(conf.get('node_timeout', 3)) + self.node_timeout = float(conf.get('node_timeout', 3)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) #: ContainerSyncCluster instance for validating sync-to values. self.realms_conf = ContainerSyncRealms( diff --git a/swift/container/updater.py b/swift/container/updater.py index a8f84cb081..f070e5f570 100644 --- a/swift/container/updater.py +++ b/swift/container/updater.py @@ -49,7 +49,7 @@ class ContainerUpdater(Daemon): self.account_ring = None self.concurrency = int(conf.get('concurrency', 4)) self.slowdown = float(conf.get('slowdown', 0.01)) - self.node_timeout = int(conf.get('node_timeout', 3)) + self.node_timeout = float(conf.get('node_timeout', 3)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) self.no_changes = 0 self.successes = 0 diff --git a/swift/obj/updater.py b/swift/obj/updater.py index d588de72b1..675c7c509f 100644 --- a/swift/obj/updater.py +++ b/swift/obj/updater.py @@ -48,7 +48,7 @@ class ObjectUpdater(Daemon): self.container_ring = None self.concurrency = int(conf.get('concurrency', 1)) self.slowdown = float(conf.get('slowdown', 0.01)) - self.node_timeout = int(conf.get('node_timeout', 10)) + self.node_timeout = float(conf.get('node_timeout', 10)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) self.successes = 0 self.failures = 0 diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 290818959b..0747a861bb 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -87,8 +87,8 @@ class Application(object): swift_dir = conf.get('swift_dir', '/etc/swift') self.swift_dir = swift_dir - self.node_timeout = int(conf.get('node_timeout', 10)) - self.recoverable_node_timeout = int( + self.node_timeout = float(conf.get('node_timeout', 10)) + self.recoverable_node_timeout = float( conf.get('recoverable_node_timeout', self.node_timeout)) self.conn_timeout = float(conf.get('conn_timeout', 0.5)) self.client_timeout = int(conf.get('client_timeout', 60)) diff --git a/test/unit/account/test_reaper.py b/test/unit/account/test_reaper.py index f0b72db357..52f3ae8ae0 100644 --- a/test/unit/account/test_reaper.py +++ b/test/unit/account/test_reaper.py @@ -226,6 +226,11 @@ class TestReaper(unittest.TestCase): def fake_account_ring(self): return FakeRing() + def test_creation(self): + # later config should be extended to assert more config options + r = reaper.AccountReaper({'node_timeout': '3.5'}) + self.assertEqual(r.node_timeout, 3.5) + def test_delay_reaping_conf_default(self): r = reaper.AccountReaper({}) self.assertEqual(r.delay_reaping, 0) diff --git a/test/unit/common/test_db_replicator.py b/test/unit/common/test_db_replicator.py index b1aeca9965..5ea1f3d631 100644 --- a/test/unit/common/test_db_replicator.py +++ b/test/unit/common/test_db_replicator.py @@ -280,6 +280,11 @@ class TestDBReplicator(unittest.TestCase): def stub_delete_db(self, broker): self.delete_db_calls.append('/path/to/file') + def test_creation(self): + # later config should be extended to assert more config options + replicator = TestReplicator({'node_timeout': '3.5'}) + self.assertEqual(replicator.node_timeout, 3.5) + def test_repl_connection(self): node = {'replication_ip': '127.0.0.1', 'replication_port': 80, 'device': 'sdb1'} diff --git a/test/unit/container/test_server.py b/test/unit/container/test_server.py index 1b768aefa3..e87d24cb46 100644 --- a/test/unit/container/test_server.py +++ b/test/unit/container/test_server.py @@ -92,6 +92,12 @@ class TestContainerController(unittest.TestCase): self.assertEqual(str(policy_index), resp.headers['X-Backend-Storage-Policy-Index']) + def test_creation(self): + # later config should be extended to assert more config options + replicator = container_server.ContainerController( + {'node_timeout': '3.5'}) + self.assertEqual(replicator.node_timeout, 3.5) + def test_get_and_validate_policy_index(self): # no policy is OK req = Request.blank('/sda1/p/a/container_default', method='PUT', diff --git a/test/unit/container/test_updater.py b/test/unit/container/test_updater.py index c2ad673236..74d030912f 100644 --- a/test/unit/container/test_updater.py +++ b/test/unit/container/test_updater.py @@ -64,14 +64,14 @@ class TestContainerUpdater(unittest.TestCase): 'swift_dir': self.testdir, 'interval': '1', 'concurrency': '2', - 'node_timeout': '5', + 'node_timeout': '5.', }) self.assertTrue(hasattr(cu, 'logger')) self.assertTrue(cu.logger is not None) self.assertEqual(cu.devices, self.devices_dir) self.assertEqual(cu.interval, 1) self.assertEqual(cu.concurrency, 2) - self.assertEqual(cu.node_timeout, 5) + self.assertEqual(cu.node_timeout, 5.) self.assertTrue(cu.get_account_ring() is not None) @mock.patch.object(container_updater, 'ismount') diff --git a/test/unit/obj/test_updater.py b/test/unit/obj/test_updater.py index c863d2bae8..db84dbac14 100644 --- a/test/unit/obj/test_updater.py +++ b/test/unit/obj/test_updater.py @@ -84,13 +84,13 @@ class TestObjectUpdater(unittest.TestCase): 'swift_dir': self.testdir, 'interval': '1', 'concurrency': '2', - 'node_timeout': '5'}) + 'node_timeout': '5.'}) self.assertTrue(hasattr(cu, 'logger')) self.assertTrue(cu.logger is not None) self.assertEqual(cu.devices, self.devices_dir) self.assertEqual(cu.interval, 1) self.assertEqual(cu.concurrency, 2) - self.assertEqual(cu.node_timeout, 5) + self.assertEqual(cu.node_timeout, 5.) self.assertTrue(cu.get_container_ring() is not None) @mock.patch('os.listdir') diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 1f664ce86c..8fadb428e4 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -684,6 +684,16 @@ class TestController(unittest.TestCase): @patch_policies([StoragePolicy(0, 'zero', True, object_ring=FakeRing())]) class TestProxyServer(unittest.TestCase): + def test_creation(self): + # later config should be extended to assert more config options + app = proxy_server.Application({'node_timeout': '3.5', + 'recoverable_node_timeout': '1.5'}, + FakeMemcache(), + container_ring=FakeRing(), + account_ring=FakeRing()) + self.assertEqual(app.node_timeout, 3.5) + self.assertEqual(app.recoverable_node_timeout, 1.5) + def test_get_object_ring(self): baseapp = proxy_server.Application({}, FakeMemcache(),