Skip to content

Commit e33444f

Browse files
committed
Add tt replicaset roles subcommand
1 parent db4b1c8 commit e33444f

File tree

2 files changed

+174
-53
lines changed

2 files changed

+174
-53
lines changed

doc/tooling/tt_cli/cluster.rst

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ expel
345345
346346
``tt cluster replicaset expel`` expels an instance from the cluster. Example:
347347

348+
.. code-block:: console
349+
348350
$ tt cluster replicaset expel "http://localhost:2379" storage-b-002
349351
350352
.. _tt-cluster-replicaset-roles:
@@ -362,22 +364,45 @@ in the configuration scope specified in the command options. It has two subcomma
362364
* ``add`` adds a role
363365
* ``remove`` removes a role
364366

365-
Use the ``--global``, ``--group``, ``--replicaset``, ``--instance`` options to select
366-
the configuration scope to add or remove the role. For example, to add a role to
367-
all instances in a replicaset:
367+
Use the ``--global``, ``--group``, ``--replicaset``, ``--instance`` options to specify
368+
the configuration scope to add or remove roles. For example, to add a role to
369+
all instances in a replica set:
368370

369371
.. code-block:: console
370372
371-
$ tt cluster replicaset roles add "http://localhost:2379" roles.my-role \
372-
--replicaset storage-a
373+
$ tt cluster replicaset roles add "http://localhost:2379" roles.my-role --replicaset storage-a
373374
374375
To remove a role defined in the global configuration scope:
375376

376377
.. code-block:: console
377378
378-
$ tt cluster replicaset roles remove "http://localhost:2379" roles.my-role \
379-
--global
379+
$ tt cluster replicaset roles remove "http://localhost:2379" roles.my-role --global
380+
381+
382+
.. _tt-cluster-replicaset-details:
383+
384+
Implementation details
385+
~~~~~~~~~~~~~~~~~~~~~~
380386

387+
The changes that ``tt cluster replicaset`` makes to the configuration storage
388+
occur transactionally. Each call creates a new revision. In case of a revision mismatch,
389+
an error is raised.
390+
391+
If the cluster configuration is distributed over multiple keys in the configuration
392+
storage (for example, in two paths ``/myapp/config/k1`` and ``/myapp/config/k2``),
393+
the affected instance configuration can be present in more that one of them.
394+
If it is found under several different keys, the command prompts the user to choose
395+
a key for patching. You can skip the selection by adding the ``-f``/``--force`` option:
396+
397+
.. code-block:: console
398+
399+
$ tt cluster replicaset promote "http://localhost:2379/myapp" storage-001-a --force
400+
401+
In this case, the command selects the key for patching automatically. A key's priority
402+
is determined by the detail level of the instance or replica set configuration stored
403+
under this key. For example, when failover is ``off``, a key with
404+
``instance.database`` options takes precedence over a key with the only ``instance`` field.
405+
In case of equal priority, the first key in the lexicographical order is patched.
381406

382407
.. _tt-cluster-failover:
383408

@@ -447,34 +472,6 @@ Example:
447472
448473
$ tt cluster failover switch-status http://localhost:2379/myapp b1e938dd-2867-46ab-acc4-3232c2ef7ffe
449474
450-
451-
452-
453-
.. _tt-cluster-replicaset-details:
454-
455-
Implementation details
456-
----------------------
457-
458-
The changes that ``tt cluster replicaset`` makes to the configuration storage
459-
occur transactionally. Each call creates a new revision. In case of a revision mismatch,
460-
an error is raised.
461-
462-
If the cluster configuration is distributed over multiple keys in the configuration
463-
storage (for example, in two paths ``/myapp/config/k1`` and ``/myapp/config/k2``),
464-
the affected instance configuration can be present in more that one of them.
465-
If it is found under several different keys, the command prompts the user to choose
466-
a key for patching. You can skip the selection by adding the ``-f``/``--force`` option:
467-
468-
.. code-block:: console
469-
470-
$ tt cluster replicaset promote "http://localhost:2379/myapp" storage-001-a --force
471-
472-
In this case, the command selects the key for patching automatically. A key's priority
473-
is determined by the detail level of the instance or replica set configuration stored
474-
under this key. For example, when failover is ``off``, a key with
475-
``instance.database`` options takes precedence over a key with the only ``instance`` field.
476-
In case of equal priority, the first key in the lexicographical order is patched.
477-
478475
.. _tt-cluster-authentication:
479476

480477
Authentication
@@ -555,28 +552,28 @@ Options
555552

556553
**Applicable to:** ``publish``, ``replicaset``
557554

558-
Skip validation when publishing. Default: `false` (validation is enabled).
559-
TODO: update for replicaset
555+
- ``publish``: skip validation when publishing. Default: `false` (validation is enabled).
556+
- ``replicaset``: skip key selection for patching. Learn more in :ref:`tt-cluster-replicaset-details:`.
560557

561558
.. option:: -G, --global
562559

563560
**Applicable to:** ``replicaset roles``
564561

565562
Apply the operation to the global configuration scope, that is, to all instances.
566563

567-
.. option:: --group
564+
.. option:: -g, --group
568565

569566
**Applicable to:** ``publish``, ``replicaset roles``
570567

571568
A name of the configuration group to which the operation applies.
572569

573-
.. option:: --instance
570+
.. option:: -i, --instance
574571

575572
**Applicable to:** ``replicaset roles``
576573

577574
A name of the instance to which the operation applies.
578575

579-
.. option:: --replicaset
576+
.. option:: -r, --replicaset
580577

581578
**Applicable to:** ``publish``, ``replicaset roles``
582579

doc/tooling/tt_cli/replicaset.rst

Lines changed: 137 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Managing replica sets
2020
* :ref:`vshard <tt-replicaset-vshard>`
2121
* :ref:`bootstrap <tt-replicaset-bootstrap>`
2222
* :ref:`rebootstrap <tt-replicaset-rebootstrap>`
23+
* :ref:`roles <tt-replicaset-roles>`
2324

2425
.. _tt-replicaset-status:
2526

@@ -391,6 +392,98 @@ To automatically confirm reboostrap, add the ``-y``/``--yes`` option:
391392
392393
$ tt replicaset rebootstrap myapp:storage-001 -y
393394
395+
.. _tt-replicaset-roles:
396+
397+
roles
398+
-----
399+
400+
.. code-block:: console
401+
402+
$ tt replicaset roles [add|remove] APPLICATION[:APP_INSTANCE] ROLE_NAME [OPTIONS ...]
403+
# or
404+
$ tt rs roles [add|remove] APPLICATION[:APP_INSTANCE] ROLE_NAME [OPTIONS ...]
405+
406+
``tt replicaset roles`` (``tt rs roles``) manages :ref:`application roles <application_roles>`
407+
in the cluster.
408+
This command works on Tarantool clusters with a local YAML
409+
configuration and Cartridge clusters. It has two subcommands:
410+
411+
* ``add`` adds a role
412+
* ``remove`` removes a role
413+
414+
.. note::
415+
416+
To manage roles in a Tarantool cluster with a :ref:`centralized configuration <configuration_etcd>`,
417+
use :ref:`tt cluster replicaset roles <tt-cluster-replicaset-roles>`.
418+
419+
420+
.. _tt-replicaset-roles-config:
421+
422+
Managing roles in clusters with local YAML configurations
423+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
424+
425+
When called on clusters with local YAML configurations, ``tt replicaset roles``
426+
subcommands add or remove the corresponding lines from the configuration file
427+
and reload the configuration.
428+
429+
Use the ``--global``, ``--group``, ``--replicaset``, ``--instance`` options to specify
430+
the configuration scope to add or remove roles. For example, to add a role to
431+
all instances in a replica set:
432+
433+
.. code-block:: console
434+
435+
$ tt replicaset roles add my-app roles.my-role --replicaset storage-a
436+
437+
You can also manage roles of a specific instance by specifying its name after the application name:
438+
439+
.. code-block:: console
440+
441+
$ tt replicaset roles add my-app:router-001 roles.my-role
442+
443+
To remove a role defined in the global configuration scope:
444+
445+
.. code-block:: console
446+
447+
$ tt replicaset roles remove my-app roles.my-role --global
448+
449+
If some instances of the affected scope are running outside the current ``tt``
450+
environment, ``tt replicaset roles`` can't ensure the configuration reload on
451+
them and reports an error. You can skip this check by adding the ``-f``/``--force`` option:
452+
453+
.. code-block:: console
454+
455+
$ tt replicaset roles add my-app roles.my-role --replicaset storage-a --force
456+
457+
458+
.. _tt-replicaset-roles-cartridge:
459+
460+
Managing roles in Cartridge clusters
461+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
462+
463+
.. include:: _includes/cartridge_deprecation_note.rst
464+
465+
When called on Cartridge clusters, ``tt replicaset roles`` subcommands add or remove
466+
Cartridge `cluster roles <https://www.tarantool.io/en/doc/2.11/book/cartridge/cartridge_dev/#cluster-roles>`__.
467+
468+
Cartridge cluster roles are defined per replica set. Thus, you can use the
469+
``--replicaset`` and ``--group`` options to define a role's scope. In this case,
470+
a group is a `vshard group <https://www.tarantool.io/en/doc/2.11/book/cartridge/cartridge_dev/#using-multiple-vshard-storage-groups>`__.
471+
472+
To add a role to a Cartridge cluster replica set:
473+
474+
.. code-block:: console
475+
476+
$ tt replicaset roles add my-cartridge-app my-role --replicaset storage-001
477+
478+
To remove a role from a vshard group:
479+
480+
.. code-block:: console
481+
482+
$ tt replicaset roles remove my-cartridge-app my-role --group cold-data
483+
484+
Learn more about `Cartridge cluster roles <https://www.tarantool.io/en/doc/2.11/book/cartridge/cartridge_dev/#cluster-roles>`_.
485+
486+
394487
.. _tt-replicaset-orchestrator:
395488

396489
Selecting the application orchestrator manually
@@ -462,7 +555,7 @@ Options
462555

463556
Force a custom orchestrator for Tarantool 2.x clusters.
464557

465-
.. option:: --file FILE
558+
.. option:: --file STRING
466559

467560
**Applicable to:** ``bootstrap``
468561

@@ -473,51 +566,82 @@ Options
473566

474567
.. option:: -f, --force
475568

476-
**Applicable to:** ``promote``, ``demote``
569+
**Applicable to:** ``promote``, ``demote``, ``roles``
477570

478-
Skip promotion or demotion if the specified instance is not running in the same environment.
571+
Skip operation on instances not running in the same environment.
479572

480-
.. option:: --replicaset REPLICASET
573+
.. option:: -G, --global
481574

482-
**Applicable to:** ``bootstrap``
575+
**Applicable to:** ``roles`` on Tarantool 3.x and later
576+
577+
Apply the operation to the global configuration scope, that is, to all instances.
578+
579+
.. option:: -g, --group STRING
580+
581+
**Applicable to:** ``roles``
582+
583+
A name of the configuration group to which the operation applies.
584+
585+
586+
.. option:: -i, --instance STRING
587+
588+
**Applicable to:** ``roles``
483589

484-
A replica set name for instance bootstrapping.
590+
A name of the instance to which the operation applies. Not applicable to Cartridge clusters.
591+
Learn more in :ref:`tt-replicaset-roles-cartridge`.
592+
593+
.. option:: -r, --replicaset STRING
594+
595+
**Applicable to:** ``bootstrap``, ``roles``
596+
597+
A name of the replica set to which the operation applies.
485598

486599
See also: :ref:`tt-replicaset-bootstrap-instance`
487600

488-
.. option:: -u USERNAME, --username USERNAME
601+
.. option:: -u, --username STRING
489602

490603
A Tarantool user for connecting to the instance using a URI.
491604

492-
.. option:: -p PASSWORD, --password PASSWORD
605+
.. option:: -p, --password STRING
493606

494607
The user's password.
495608

496-
.. option:: --sslcertfile FILEPATH
609+
.. option:: --sslcertfile STRING
497610

498611
The path to an SSL certificate file for encrypted connections for the URI case.
499612

500-
.. option:: --sslkeyfile FILEPATH
613+
.. option:: --sslkeyfile STRING
501614

502615
The path to a private SSL key file for encrypted connections for the URI case.
503616

504-
.. option:: --sslcafile FILEPATH
617+
.. option:: --sslcafile STRING
505618

506619
The path to a trusted certificate authorities (CA) file for encrypted connections for the URI case.
507620

508621
.. option:: --sslciphers STRING
509622

510623
The list of SSL cipher suites used for encrypted connections for the URI case, separated by colons (``:``).
511624

512-
.. option:: --timeout
625+
.. option:: --timeout UINT
513626

514627
**Applicable to:** ``promote``, ``demote``, ``expel``, ``vshard``, ``bootstrap``
515628

516629
The timeout for completing the operation, in seconds. Default:
517630

518-
- ``3`` for ``promote``, ``demote``, ``expel``
631+
- ``3`` for ``promote``, ``demote``, ``expel``, ``roles``
519632
- ``10`` for ``vshard`` and ``bootstrap``
520633

634+
.. option:: --with-integrity-check STRING
635+
636+
.. admonition:: Enterprise Edition
637+
:class: fact
638+
639+
This option is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
640+
641+
**Applicable to:** ``publish``, ``replicaset``
642+
643+
Generate hashes and signatures for integrity checks.
644+
521645
.. option:: -y, --yes
522646

523647
**Applicable to:** ``rebootstrap``

0 commit comments

Comments
 (0)