From fbfdc89df52c092853b1685e1ab30a852509d7d1 Mon Sep 17 00:00:00 2001 From: Chinemerem Date: Fri, 13 Dec 2024 12:19:25 -0800 Subject: [PATCH] Require that updater_workers be a postive integer Previously, it was possible for updater_workers to be a negative integer or zero. This change enforces that updater_workers should be a positive integer. Change-Id: Ie40194b406aeedcf8c38a3c273ab768e2b643a5d --- swift/obj/updater.py | 3 ++- test/unit/obj/test_updater.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/swift/obj/updater.py b/swift/obj/updater.py index 8b77001ba4..293182b38b 100644 --- a/swift/obj/updater.py +++ b/swift/obj/updater.py @@ -427,7 +427,8 @@ class ObjectUpdater(Daemon): self.interval = float(conf.get('interval', 300)) self.container_ring = None self.concurrency = int(conf.get('concurrency', 8)) - self.updater_workers = int(conf.get('updater_workers', 1)) + self.updater_workers = config_positive_int_value( + conf.get('updater_workers', 1)) if 'slowdown' in conf: self.logger.warning( 'The slowdown option is deprecated in favor of ' diff --git a/test/unit/obj/test_updater.py b/test/unit/obj/test_updater.py index 0cac9beecf..e087c355f3 100644 --- a/test/unit/obj/test_updater.py +++ b/test/unit/obj/test_updater.py @@ -184,6 +184,8 @@ class TestObjectUpdater(unittest.TestCase): check_bad({'interval': 'foo'}) check_bad({'concurrency': 'bar'}) check_bad({'concurrency': '1.0'}) + check_bad({'updater_workers': '0'}) + check_bad({'updater_workers': '-1'}) check_bad({'slowdown': 'baz'}) check_bad({'objects_per_second': 'quux'}) check_bad({'max_objects_per_container_per_second': '-0.1'})