From 5ceba8126969578489de556f54c9b3c7935af4a2 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Tue, 26 Sep 2023 08:31:55 +0200 Subject: [PATCH] Bugfix for GUC's values with units (#2883) Despite being validated by `IntValidator` some GUC's couldn't be casted directly to `int` because they include suffix. Example: `128MB`. Close https://github.com/zalando/patroni/issues/2879 --- patroni/config.py | 3 ++- tests/test_config.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/patroni/config.py b/patroni/config.py index 437ce4ec..0b6797b1 100644 --- a/patroni/config.py +++ b/patroni/config.py @@ -342,7 +342,8 @@ class Config(object): elif not is_local: validator = ConfigHandler.CMDLINE_OPTIONS[name][1] if validator(value): - pg_params[name] = int(value) if isinstance(validator, IntValidator) else value + int_val = parse_int(value) if isinstance(validator, IntValidator) else None + pg_params[name] = int_val if isinstance(int_val, int) else value else: logger.warning("postgresql parameter %s=%s failed validation, defaulting to %s", name, value, ConfigHandler.CMDLINE_OPTIONS[name][0]) diff --git a/tests/test_config.py b/tests/test_config.py index bd8d0a90..f0a780bc 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -155,6 +155,7 @@ class TestConfig(unittest.TestCase): expected_params = { 'f.oo': 'bar', # not in ConfigHandler.CMDLINE_OPTIONS 'max_connections': 100, # IntValidator + 'wal_keep_size': '128MB', # IntValidator 'wal_level': 'hot_standby', # EnumValidator } input_params = deepcopy(expected_params)