config: handle box.cfg's TT_* env vars
There may be some confusion, so let's start with a background information. There are `TT_*` environment variables introduced in commit 1b330121 ("box: set box.cfg options via environment variables"). They're interpreted by the `box.cfg()` call. There are `TT_*` environment variables introduced in commit 82b0cff9 ("config: introduce env source"). They're interpreted by the declarative configuration logic, when tarantool starts with the `--name <...>` CLI option. box.cfg's env variables have names deduced from box.cfg option names, while config's env variable names are deduced from the config schema. Some options have the same names here and there, for example `TT_REPLICATION_ANON` (from `box.cfg.replication_anon` and `replication.anon`). However, there are ones that have different names, for example `TT_LISTEN` and `TT_IPROTO_LISTEN`. Moreover, the declarative configuration has its own restrictions on the configuration data. For example, `TT_IPROTO_LISTEN` is always a list of URIs (like `[{"uri": <...>, "params": {<...>}}]`), not a single URI, not a string, not a number. The declarative configuration has a certain shape and doesn't allow polymorphic values. Next, handling of box.cfg's variables by the old code in `load_cfg.lua` doesn't work well with the declarative configuration flow. The main reason is that the new configuration flow calls `box.cfg()` with all the `box.cfg` values set, including default ones. If a user removes an option from its config, it applies its default. On the same time it instructs `box.cfg()` to don't read the corresponding environment variables. This commit offers a partial solution: it adds support of the most of the box.cfg environment variables. The values are added into the configuration data with the lowest priority: if the same value is set in, for example, a file configuration, the file's value is preferred. The following box.cfg's environment variables are not handled in this commit. * `TT_LOG` * `TT_METRICS` * `TT_INSTANCE_NAME` * `TT_REPLICASET_NAME` * `TT_CLUSTER_NAME` * `TT_FORCE_RECOVERY`, * `TT_READ_ONLY` * `TT_BOOTSTRAP_LEADER` * `TT_REPLICATION` * `TT_REPLICATION_CONNECT_QUORUM` Fixes #9485 NO_DOC=looks more like a bug fix or a kind of compatibility layer
Showing
- changelogs/unreleased/config-handle-old-box-cfg-env-variables.md 4 additions, 0 deletions...ogs/unreleased/config-handle-old-box-cfg-env-variables.md
- src/box/lua/config/source/env.lua 76 additions, 0 deletionssrc/box/lua/config/source/env.lua
- test/config-luatest/box_cfg_env_test.lua 307 additions, 0 deletionstest/config-luatest/box_cfg_env_test.lua
Loading
Please register or sign in to comment