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
This commit is contained in:
Alexander Kukushkin
2023-09-26 08:31:55 +02:00
committed by GitHub
parent fe16c3610e
commit 2bd821a768
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -490,7 +490,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])
+1
View File
@@ -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)