mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
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:
+2
-1
@@ -490,7 +490,8 @@ class Config(object):
|
|||||||
elif not is_local:
|
elif not is_local:
|
||||||
validator = ConfigHandler.CMDLINE_OPTIONS[name][1]
|
validator = ConfigHandler.CMDLINE_OPTIONS[name][1]
|
||||||
if validator(value):
|
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:
|
else:
|
||||||
logger.warning("postgresql parameter %s=%s failed validation, defaulting to %s",
|
logger.warning("postgresql parameter %s=%s failed validation, defaulting to %s",
|
||||||
name, value, ConfigHandler.CMDLINE_OPTIONS[name][0])
|
name, value, ConfigHandler.CMDLINE_OPTIONS[name][0])
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ class TestConfig(unittest.TestCase):
|
|||||||
expected_params = {
|
expected_params = {
|
||||||
'f.oo': 'bar', # not in ConfigHandler.CMDLINE_OPTIONS
|
'f.oo': 'bar', # not in ConfigHandler.CMDLINE_OPTIONS
|
||||||
'max_connections': 100, # IntValidator
|
'max_connections': 100, # IntValidator
|
||||||
|
'wal_keep_size': '128MB', # IntValidator
|
||||||
'wal_level': 'hot_standby', # EnumValidator
|
'wal_level': 'hot_standby', # EnumValidator
|
||||||
}
|
}
|
||||||
input_params = deepcopy(expected_params)
|
input_params = deepcopy(expected_params)
|
||||||
|
|||||||
Reference in New Issue
Block a user