Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen socket is not created after restart of the instance, if set using environmental variable. #9485

Closed
better0fdead opened this issue Dec 14, 2023 · 3 comments · Fixed by #9499
Assignees
Labels
3.0 Target is 3.0 and all newer release/master branches bug Something isn't working config

Comments

@better0fdead
Copy link

Bug description
If setting box.cfg{listen} using "TT_LISTEN" environmental variable, socket is not created after restart of the instance.

  • OS: Linux
  • OS Version: Ubuntu 20.04.6 LTS
  • Architecture: x86_64
Tarantool 3.0.0-beta1-0-g18eaeb7
Target: Linux-x86_64-Debug
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/tmp/tarantool_install357019311/dynamic-build/tarantool-prefix -DENABLE_BACKTRACE=TRUE
Compiler: GNU-9.4.0
C_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/tmp/tarantool_install357019311=. -std=c11 -Wall -Wextra -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type -Werror -g -ggdb -O0 
CXX_FLAGS: -fexceptions -funwind-tables -fasynchronous-unwind-tables -fno-common -msse2 -Wformat -Wformat-security -Werror=format-security -fstack-protector-strong -fPIC -fmacro-prefix-map=/tmp/tarantool_install357019311=. -std=c++11 -Wall -Wextra -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type -Werror -g -ggdb -O0 

Steps to reproduce

Config file:

credentials:
  users:
    guest:
      roles: [super]

log:
  to: file
  file: tnt_{{ instance_name }}.log

groups:
  group-001:
    replicasets:
      replicaset-001:
        instances:
          master: {}

Instances file:

master:

Set environmental variable 'TT_LISTEN':

better0fdead@better0fdead:~/tt-system$ pwd
/home/better0fdead/tt-system
better0fdead@better0fdead:~/tt-system$ export TT_LISTEN=/home/better0fdead/tt-system/t.sock

Start tarantool instance.

better0fdead@better0fdead:~/tt-system$ tarantool --name master --config ./config.yml 

In another console check that socket was created.

better0fdead@better0fdead:~$ cd tt-system/
better0fdead@better0fdead:~/tt-system$ ls 
config.yml  instances.yml  tnt_master.log  t.sock  var

Stop instance and start again.

^Cbetter0fdead@better0fdead:~/tt-system$ tarantool --name master --config ./config.yml 

In another console check that socket is not here.

better0fdead@better0fdead:~/tt-system$ ls -al
total 28
drwxrwxr-x  3 better0fdead better0fdead 4096 дек 14 14:41 .
drwxr-xr-x 40 better0fdead better0fdead 4096 дек 14 14:38 ..
-rw-rw-r--  1 better0fdead better0fdead  210 дек 12 15:58 config.yml
-rw-rw-r--  1 better0fdead better0fdead    9 ноя 30 01:37 instances.yml
-rw-r-----  1 better0fdead better0fdead 8135 дек 14 14:41 tnt_master.log
drwxrwxr-x  4 better0fdead better0fdead 4096 дек 14 14:39 var

Check env:

better0fdead@better0fdead:~/tt-system$ printenv | grep 'TT_LISTEN'
TT_LISTEN=/home/better0fdead/tt-system/t.sock

Log file:

2023-12-14 14:39:39.101 [11734] main/103/interactive I> Tarantool 3.0.0-beta1-0-g18eaeb7 Linux-x86_64-Debug
2023-12-14 14:39:39.101 [11734] main/103/interactive I> log level 5 (INFO)
2023-12-14 14:39:39.101 [11734] main/103/interactive I> wal/engine cleanup is paused
2023-12-14 14:39:39.102 [11734] main/103/interactive I> mapping 268435456 bytes for memtx tuple arena...
2023-12-14 14:39:39.102 [11734] main/103/interactive I> Actual slab_alloc_factor calculated on the basis of desired slab_alloc_factor = 1.044274
2023-12-14 14:39:39.102 [11734] main/103/interactive I> mapping 134217728 bytes for vinyl tuple arena...
2023-12-14 14:39:39.109 [11734] main/103/interactive I> update replication_synchro_quorum = 1
2023-12-14 14:39:39.109 [11734] main/103/interactive I> instance uuid 4f26aeaf-db23-6762-000a-393c973eddbe
2023-12-14 14:39:39.109 [11734] main/103/interactive I> tx_binary: bound to unix/:(socket)
2023-12-14 14:39:39.109 [11734] main/103/interactive I> initializing an empty data directory
2023-12-14 14:39:39.124 [11734] main/103/interactive I> assigned id 1 to replica 4f26aeaf-db23-6762-000a-393c973eddbe
2023-12-14 14:39:39.125 [11734] main/103/interactive I> update replication_synchro_quorum = 1
2023-12-14 14:39:39.125 [11734] main/103/interactive I> assigned name master to replica 4f26aeaf-db23-6762-000a-393c973eddbe
2023-12-14 14:39:39.125 [11734] main/103/interactive I> replicaset uuid 2ab78dc2-4652-3699-00e4-12df0ae32351
2023-12-14 14:39:39.125 [11734] main/103/interactive I> replicaset name: replicaset-001
2023-12-14 14:39:39.126 [11734] snapshot/101/main I> saving snapshot `var/lib/master/00000000000000000000.snap.inprogress'
2023-12-14 14:39:39.129 [11734] snapshot/101/main I> done
2023-12-14 14:39:39.129 [11734] main/103/interactive I> ready to accept requests
2023-12-14 14:39:39.129 [11734] main/104/gc I> wal/engine cleanup is resumed
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'custom_proc_title' configuration option to "tarantool - master"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'instance_name' configuration option to "master"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'log' configuration option to "file:tnt_master.log"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'log_nonblock' configuration option to false
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'replicaset_name' configuration option to "replicaset-001"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'instance_uuid' configuration option to "4f26aeaf-db23-6762-000a-393c973eddbe"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'listen' configuration option to "/home/better0fdead/tt-system/t.sock"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'replicaset_uuid' configuration option to "2ab78dc2-4652-3699-00e4-12df0ae32351"
2023-12-14 14:39:39.130 [11734] main/103/interactive/box.load_cfg I> set 'metrics' configuration option to {"labels":{"alias":"master"},"include":["all"],"exclude":[]}
2023-12-14 14:39:39.130 [11734] main/105/checkpoint_daemon I> scheduled next checkpoint for Thu Dec 14 16:02:15 2023
2023-12-14 14:39:39.135 [11734] main/114/console/unix/:./var/run/master/tarantool.control/socket I> started
2023-12-14 14:39:39.136 [11734] main I> entering the event loop
2023-12-14 14:41:30.760 [11734] main C> got signal 2 - Interrupt
2023-12-14 14:41:30.760 [11734] main/117/iproto.shutdown I> tx_binary: stopped
2023-12-14 14:41:32.362 [11924] main/103/interactive I> Tarantool 3.0.0-beta1-0-g18eaeb7 Linux-x86_64-Debug
2023-12-14 14:41:32.363 [11924] main/103/interactive I> log level 5 (INFO)
2023-12-14 14:41:32.363 [11924] main/103/interactive I> wal/engine cleanup is paused
2023-12-14 14:41:32.364 [11924] main/103/interactive I> mapping 268435456 bytes for memtx tuple arena...
2023-12-14 14:41:32.364 [11924] main/103/interactive I> Actual slab_alloc_factor calculated on the basis of desired slab_alloc_factor = 1.044274
2023-12-14 14:41:32.364 [11924] main/103/interactive I> mapping 134217728 bytes for vinyl tuple arena...
2023-12-14 14:41:32.364 [11924] main/103/interactive/box.upgrade I> Recovering snapshot with schema version 3.0.0
2023-12-14 14:41:32.369 [11924] main/103/interactive I> update replication_synchro_quorum = 1
2023-12-14 14:41:32.369 [11924] main/103/interactive I> instance uuid 4f26aeaf-db23-6762-000a-393c973eddbe
2023-12-14 14:41:32.369 [11924] main/103/interactive I> instance vclock {1: 1}
2023-12-14 14:41:32.369 [11924] main/103/interactive I> tx_binary: bound to unix/:(socket)
2023-12-14 14:41:32.369 [11924] main/103/interactive I> recovery start
2023-12-14 14:41:32.369 [11924] main/103/interactive I> recovering from `var/lib/master/00000000000000000000.snap'
2023-12-14 14:41:32.377 [11924] main/103/interactive I> replicaset name: replicaset-001
2023-12-14 14:41:32.377 [11924] main/103/interactive I> replicaset uuid 2ab78dc2-4652-3699-00e4-12df0ae32351
2023-12-14 14:41:32.384 [11924] main/103/interactive I> assigned id 1 to replica 4f26aeaf-db23-6762-000a-393c973eddbe
2023-12-14 14:41:32.384 [11924] main/103/interactive I> update replication_synchro_quorum = 1
2023-12-14 14:41:32.384 [11924] main/103/interactive I> assigned name master to replica 4f26aeaf-db23-6762-000a-393c973eddbe
2023-12-14 14:41:32.384 [11924] main/103/interactive I> recover from `var/lib/master/00000000000000000000.xlog'
2023-12-14 14:41:32.384 [11924] main/103/interactive I> done `var/lib/master/00000000000000000000.xlog'
2023-12-14 14:41:32.384 [11924] main/103/interactive I> recover from `var/lib/master/00000000000000000001.xlog'
2023-12-14 14:41:32.384 [11924] main/103/interactive I> done `var/lib/master/00000000000000000001.xlog'
2023-12-14 14:41:32.385 [11924] main/103/interactive I> ready to accept requests
2023-12-14 14:41:32.385 [11924] main/103/interactive I> leaving orphan mode
2023-12-14 14:41:32.385 [11924] main/104/gc I> wal/engine cleanup is resumed
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'custom_proc_title' configuration option to "tarantool - master"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'instance_name' configuration option to "master"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'log' configuration option to "file:tnt_master.log"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'log_nonblock' configuration option to false
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'replicaset_name' configuration option to "replicaset-001"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'instance_uuid' configuration option to "4f26aeaf-db23-6762-000a-393c973eddbe"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'listen' configuration option to "/home/better0fdead/tt-system/t.sock"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'replicaset_uuid' configuration option to "2ab78dc2-4652-3699-00e4-12df0ae32351"
2023-12-14 14:41:32.385 [11924] main/103/interactive/box.load_cfg I> set 'metrics' configuration option to {"labels":{"alias":"master"},"include":["all"],"exclude":[]}
2023-12-14 14:41:32.385 [11924] main/105/checkpoint_daemon I> scheduled next checkpoint for Thu Dec 14 16:27:03 2023
2023-12-14 14:41:32.392 [11924] main/103/interactive I> tx_binary: stopped
2023-12-14 14:41:32.392 [11924] main/103/interactive/box.load_cfg I> set 'listen' configuration option to null
2023-12-14 14:41:32.392 [11924] main/103/interactive I> update replication_synchro_quorum = 1
2023-12-14 14:41:32.393 [11924] main/105/checkpoint_daemon I> scheduled next checkpoint for Thu Dec 14 15:49:17 2023
2023-12-14 14:41:32.395 [11924] main/103/interactive/socket I> tcp_server: remove dead UNIX socket: ./var/run/master/tarantool.control
2023-12-14 14:41:32.396 [11924] main/117/console/unix/:./var/run/master/tarantool.control/socket I> started
2023-12-14 14:41:32.396 [11924] main I> entering the event loop

Actual behavior

After restart of the instance socket is not created.

Expected behavior

After restart of the instance socket is created.

@better0fdead better0fdead added the bug Something isn't working label Dec 14, 2023
@Totktonada
Copy link
Member

Defaults are passed to box.cfg(), if they're not provided by one of configuration sources: env, file, etcd (EE), tarantool storage (EE). We should support old environment variable names such as IPROTO_LISTEN in the environment configuration source. At the moment, it supports only new names generated from the configuration structure such as TT_IPROTO_LISTEN. The list is shown by the tarantool --help-env-list command.

I agree that we should consider it as a bug and support the old names (where possible) in the env configuration source.

@better0fdead
Copy link
Author

better0fdead commented Dec 14, 2023

Defaults are passed to box.cfg(), if they're not provided by one of configuration sources: env, file, etcd (EE), tarantool storage (EE). We should support old environment variable names such as IPROTO_LISTEN in the environment configuration source. At the moment, it supports only new names generated from the configuration structure such as TT_IPROTO_LISTEN. The list is shown by the tarantool --help-env-list command.

I agree that we should consider it as a bug and support the old names (where possible) in the env configuration source.

Ok, thanks for answer. I understood that but why an old "TT_LISTEN"(which as i understood should not work) variable still works with first launch?

@Totktonada
Copy link
Member

Tarantool re-reads a configuration and applies it second time if there is an existing snapshot. The idea is that the startup may take a long time and the configuration may be changed while it was starting. See c80b121 for details.

Here we lean on the assumption that an attempt to call box.cfg() with unchanged options do nothing. It seems, this assumption breaks if there are box.cfg's environment variables (see 1b33012).

I need to test/dig it a bit more to say for sure.

Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 18, 2023
TODO: changelog
TODO: doc request -- list supported and unsupported vars

Fixes tarantool#9485
@Totktonada Totktonada self-assigned this Dec 18, 2023
@Totktonada Totktonada added 3.0 Target is 3.0 and all newer release/master branches config labels Dec 18, 2023
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 21, 2023
There may be some confusion, so let's start with a background
information.

There are `TT_*` environment variables introduced in commit 1b33012
("box: set box.cfg options via environment variables"). They're
interpreted by the `box.cfg()` call.

There are `TT_*` environment variables introduced in commit 82b0cff
("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 variables.

This commit offers a partial solution: it performs mapping of the most
of box.cfg's options to box.cfg's environment variables and adds them
into the configuration data if the configuration value is not provided
in another way (new env var, file, etcd, tarantool storage).

This mapping mostly works, but technically it is incomplete. At least it
doesn't handle the following environment variables.

* `TT_LOG`
* `TT_METRICS`
* `TT_INSTANCE_NAME`
* `TT_REPLICASET_NAME`
* `TT_CLUSTER_NAME`
* `TT_FORCE_RECOVERY`,
* `TT_READ_ONLY`
* `TT_BOOTSTRAP_LEADER`
* `TT_REPLICATION_CONNECT_QUORUM`

If there is a demand, it is possible to support `TT_LOG`, `TT_METRICS`
and `TT_BOOTSTRAP_LEADER`, while the rest of the options are either have
no sense in the declarative configuration flow or deprecated.

Fixes tarantool#9485

NO_DOC=looks more like a bug fix
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 24, 2023
This function makes it easier to run a code that can't be run directly
for some reason: for example, it needs the initialized database.

It is a wrapper around treegen and justrun.

Part of tarantool#9485

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 24, 2023
There may be some confusion, so let's start with a background
information.

There are `TT_*` environment variables introduced in commit 1b33012
("box: set box.cfg options via environment variables"). They're
interpreted by the `box.cfg()` call.

There are `TT_*` environment variables introduced in commit 82b0cff
("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 tarantool#9485

NO_DOC=looks more like a bug fix or a kind of compatibility layer
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 24, 2023
This function makes it easier to run a code that can't be run directly
for some reason: for example, it needs the initialized database.

It is a wrapper around treegen and justrun.

Part of tarantool#9485

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 24, 2023
There may be some confusion, so let's start with a background
information.

There are `TT_*` environment variables introduced in commit 1b33012
("box: set box.cfg options via environment variables"). They're
interpreted by the `box.cfg()` call.

There are `TT_*` environment variables introduced in commit 82b0cff
("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 tarantool#9485

NO_DOC=looks more like a bug fix or a kind of compatibility layer
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 25, 2023
This function makes it easier to run a code that can't be run directly
for some reason: for example, it needs the initialized database.

It is a wrapper around treegen and justrun.

Part of tarantool#9485

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC
Totktonada added a commit to Totktonada/tarantool that referenced this issue Dec 25, 2023
There may be some confusion, so let's start with a background
information.

There are `TT_*` environment variables introduced in commit 1b33012
("box: set box.cfg options via environment variables"). They're
interpreted by the `box.cfg()` call.

There are `TT_*` environment variables introduced in commit 82b0cff
("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 tarantool#9485

NO_DOC=looks more like a bug fix or a kind of compatibility layer
Totktonada added a commit that referenced this issue Dec 25, 2023
This function makes it easier to run a code that can't be run directly
for some reason: for example, it needs the initialized database.

It is a wrapper around treegen and justrun.

Part of #9485

NO_DOC=testing helper change
NO_CHANGELOG=see NO_DOC
NO_TEST=see NO_DOC
Totktonada added a commit that referenced this issue Dec 25, 2023
There may be some confusion, so let's start with a background
information.

There are `TT_*` environment variables introduced in commit 1b33012
("box: set box.cfg options via environment variables"). They're
interpreted by the `box.cfg()` call.

There are `TT_*` environment variables introduced in commit 82b0cff
("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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 Target is 3.0 and all newer release/master branches bug Something isn't working config
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants