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

config: access configuration of other cluster members #4105

Closed
Tracked by #4294
TarantoolBot opened this issue Mar 19, 2024 · 0 comments · Fixed by #4331
Closed
Tracked by #4294

config: access configuration of other cluster members #4105

TarantoolBot opened this issue Mar 19, 2024 · 0 comments · Fixed by #4331
Assignees

Comments

@TarantoolBot
Copy link
Collaborator

TarantoolBot commented Mar 19, 2024

Related dev. issue(s): tarantool/tarantool#9680

Product: Tarantool
Since: 3.1
Root document:

SME: @Totktonada

Details

config:instances()

Lists all instances of the cluster.

Returns a table of the following format.

{
    [<instance_name>] = {
        instance_name = <...>,
        replicaset_name = <...>,
        group_name = <...>,
    },
    <...>
}

If an action should be performed for each instance of the given cluster,
it can be written this way:

for instance_name in pairs(config:instances()) do
    action(instance_name)
end

If replicaset/group names matter, the instances may be filtered this
way:

-- Perform an action for all instances of the given replicaset.
for instance_name, def in pairs(config:instances()) do
    if def.replicaset_name == box.info.replicaset.name then
        action(instance_name)
    end
end

config:get(<...>, {instance = '<...>'})

The new instance option of the config:get() method allows to
retrieve a configuration value of another instance from the given
cluster.

Example:

-- Collect all the enabled roles within the cluster.
local enabled_roles = {}
for instance_name in pairs(config:instances()) do
    local roles = config:get('roles', {instance = instance_name})
    for _, role in ipairs(roles) do
        enabled_roles[role] = true
    end
end

Note: There is a difference between a missing instance option and the
instance option that is equal to the given instance name. The former
returns an instance configuration taking into account instance
configuration sources (environment variables). The latter takes into
account only cluster configuration, so the environment variables are
ignored.

Requested by @ Totktonada in tarantool/tarantool@30a9c1c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants