diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2022-09-09 12:03:07 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-27 03:13:12 +0000 |
commit | 2cfc78ff27a7ed95e7632f7749f8d09383be308b (patch) | |
tree | c984bd2dc8a5b3fd3a9c12cf82f9802b3510fb1e /buildscripts | |
parent | b7025a4b61e658d1d07c56e057fcc13e792d6fb4 (diff) | |
download | mongo-2cfc78ff27a7ed95e7632f7749f8d09383be308b.tar.gz |
SERVER-69060 Guard server parameters on feature flags
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/idl/idl/ast.py | 1 | ||||
-rw-r--r-- | buildscripts/idl/idl/binder.py | 12 | ||||
-rw-r--r-- | buildscripts/idl/idl/generator.py | 9 | ||||
-rw-r--r-- | buildscripts/idl/idl/parser.py | 1 | ||||
-rw-r--r-- | buildscripts/idl/idl/syntax.py | 1 |
5 files changed, 20 insertions, 4 deletions
diff --git a/buildscripts/idl/idl/ast.py b/buildscripts/idl/idl/ast.py index c49bfee0be5..da791000a07 100644 --- a/buildscripts/idl/idl/ast.py +++ b/buildscripts/idl/idl/ast.py @@ -367,6 +367,7 @@ class Condition(common.SourceLocation): self.expr = None # type: str self.constexpr = None # type: str self.preprocessor = None # type: str + self.feature_flag = None # type: str super(Condition, self).__init__(file_name, line, column) diff --git a/buildscripts/idl/idl/binder.py b/buildscripts/idl/idl/binder.py index 6ffaf2d5108..38b646e162f 100644 --- a/buildscripts/idl/idl/binder.py +++ b/buildscripts/idl/idl/binder.py @@ -942,8 +942,8 @@ def _bind_validator(ctxt, validator): return ast_validator -def _bind_condition(condition): - # type: (syntax.Condition) -> ast.Condition +def _bind_condition(condition, condition_for): + # type: (syntax.Condition, str) -> ast.Condition """Bind a condition from the idl.syntax tree.""" if not condition: @@ -954,6 +954,10 @@ def _bind_condition(condition): ast_condition.constexpr = condition.constexpr ast_condition.preprocessor = condition.preprocessor + if condition.feature_flag: + assert condition_for == 'server_parameter' + ast_condition.feature_flag = condition.feature_flag + return ast_condition @@ -1374,7 +1378,7 @@ def _bind_server_parameter(ctxt, param): ast_param = ast.ServerParameter(param.file_name, param.line, param.column) ast_param.name = param.name ast_param.description = param.description - ast_param.condition = _bind_condition(param.condition) + ast_param.condition = _bind_condition(param.condition, condition_for='server_parameter') ast_param.redact = param.redact ast_param.test_only = param.test_only ast_param.deprecated_name = param.deprecated_name @@ -1500,7 +1504,7 @@ def _bind_config_option(ctxt, globals_spec, option): node.arg_vartype = option.arg_vartype node.cpp_vartype = option.cpp_vartype node.cpp_varname = option.cpp_varname - node.condition = _bind_condition(option.condition) + node.condition = _bind_condition(option.condition, condition_for='config') node.requires = option.requires node.conflicts = option.conflicts diff --git a/buildscripts/idl/idl/generator.py b/buildscripts/idl/idl/generator.py index 3cb145c09eb..64c7f504146 100644 --- a/buildscripts/idl/idl/generator.py +++ b/buildscripts/idl/idl/generator.py @@ -2504,6 +2504,15 @@ class _CppSourceFileWriter(_CppFileWriterBase): if param.test_only: self._writer.write_line('scp_%d->setTestOnly();' % (param_no)) + if param.condition and param.condition.feature_flag: + ffs = [sp for sp in params if sp.name == param.condition.feature_flag] + if len(ffs) == 0: + raise ValueError("Unable to find feature flag named %s" % + (param.condition.feature_flag)) + assert len(ffs) == 1 + self._writer.write_line( + 'scp_%d->setFeatureFlag(&%s);' % (param_no, ffs[0].cpp_varname)) + self._gen_server_parameter_deprecated_aliases(param_no, param) self.write_empty_line() diff --git a/buildscripts/idl/idl/parser.py b/buildscripts/idl/idl/parser.py index 5f4d0cbec19..b89c1724273 100644 --- a/buildscripts/idl/idl/parser.py +++ b/buildscripts/idl/idl/parser.py @@ -302,6 +302,7 @@ def _parse_condition(ctxt, node): "preprocessor": _RuleDesc("scalar"), "constexpr": _RuleDesc("scalar"), "expr": _RuleDesc("scalar"), + "feature_flag": _RuleDesc("scalar"), }) return condition diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py index 90d53bebeae..77453397478 100644 --- a/buildscripts/idl/idl/syntax.py +++ b/buildscripts/idl/idl/syntax.py @@ -734,6 +734,7 @@ class Condition(common.SourceLocation): self.expr = None # type: str self.constexpr = None # type: str self.preprocessor = None # type: str + self.feature_flag = None # type: str super(Condition, self).__init__(file_name, line, column) |