Skip to content

Commit 1348ca2

Browse files
authored
Add tt cluster rs roles and tt rs roles subcommands (#4622)
Resolves #4433, #4467, #4471, #4480
1 parent 6e58edc commit 1348ca2

File tree

2 files changed

+233
-53
lines changed

2 files changed

+233
-53
lines changed

doc/tooling/tt_cli/cluster.rst

Lines changed: 96 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ To add a new instance ``instance-003`` to the ``replicaset-001`` replica set:
116116

117117
.. code-block:: console
118118
119-
tt cluster publish "http://localhost:2379/myapp?name=instance-003" instance_source.yaml --replicaset replicaset-001
119+
$ tt cluster publish "http://localhost:2379/myapp?name=instance-003" instance_source.yaml --replicaset replicaset-001
120120
121121
122122
.. _tt-cluster-publish-validation:
@@ -265,12 +265,14 @@ subcommands:
265265

266266
- :ref:`promote <tt-cluster-replicaset-promote>`
267267
- :ref:`demote <tt-cluster-replicaset-demote>`
268+
- :ref:`expel <tt-cluster-replicaset-expel>`
269+
- :ref:`roles <tt-cluster-replicaset-roles>`
268270

269271
.. important::
270272

271273
``tt cluster replicaset`` works only with centralized cluster configurations.
272-
To manage replica set leaders in clusters with local YAML configurations,
273-
use :ref:`tt replicaset promote <tt-replicaset-demote>` and :ref:`tt replicaset demote <tt-replicaset-demote>`.
274+
To manage replica sets in clusters with local YAML configurations,
275+
use :ref:`tt replicaset <tt-replicaset>`.
274276

275277
.. _tt-cluster-replicaset-promote:
276278

@@ -332,6 +334,75 @@ to ``ro`` and reloads the configuration.
332334
If failover is ``off``, the command doesn't consider the modes of other
333335
replica set members, so there can be any number of read-write instances in one replica set.
334336

337+
.. _tt-cluster-replicaset-expel:
338+
339+
expel
340+
~~~~~
341+
342+
.. code-block:: console
343+
344+
$ tt cluster replicaset expel CONFIG_URI INSTANCE_NAME [OPTION ...]
345+
346+
``tt cluster replicaset expel`` expels an instance from the cluster. Example:
347+
348+
.. code-block:: console
349+
350+
$ tt cluster replicaset expel "http://localhost:2379" storage-b-002
351+
352+
.. _tt-cluster-replicaset-roles:
353+
354+
roles
355+
~~~~~
356+
357+
.. code-block:: console
358+
359+
$ tt cluster replicaset roles [add|remove] CONFIG_URI ROLE_NAME [OPTION ...]
360+
361+
``tt cluster replicaset roles`` manages :ref:`application roles <application_roles>`
362+
in the configuration scope specified in the command options. It has two subcommands:
363+
364+
* ``add`` adds a role
365+
* ``remove`` removes a role
366+
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:
370+
371+
.. code-block:: console
372+
373+
$ tt cluster replicaset roles add "http://localhost:2379" roles.my-role --replicaset storage-a
374+
375+
To remove a role defined in the global configuration scope:
376+
377+
.. code-block:: console
378+
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+
~~~~~~~~~~~~~~~~~~~~~~
386+
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.
335406

336407
.. _tt-cluster-failover:
337408

@@ -401,34 +472,6 @@ Example:
401472
402473
$ tt cluster failover switch-status http://localhost:2379/myapp b1e938dd-2867-46ab-acc4-3232c2ef7ffe
403474
404-
405-
406-
407-
.. _tt-cluster-replicaset-details:
408-
409-
Implementation details
410-
----------------------
411-
412-
The changes that ``tt cluster replicaset`` makes to the configuration storage
413-
occur transactionally. Each call creates a new revision. In case of a revision mismatch,
414-
an error is raised.
415-
416-
If the cluster configuration is distributed over multiple keys in the configuration
417-
storage (for example, in two paths ``/myapp/config/k1`` and ``/myapp/config/k2``),
418-
the affected instance configuration can be present in more that one of them.
419-
If it is found under several different keys, the command prompts the user to choose
420-
a key for patching. You can skip the selection by adding the ``-f``/``--force`` option:
421-
422-
.. code-block:: console
423-
424-
$ tt cluster replicaset promote "http://localhost:2379/myapp" storage-001-a --force
425-
426-
In this case, the command selects the key for patching automatically. A key's priority
427-
is determined by the detail level of the instance or replica set configuration stored
428-
under this key. For example, when failover is ``off``, a key with
429-
``instance.database`` options takes precedence over a key with the only ``instance`` field.
430-
In case of equal priority, the first key in the lexicographical order is patched.
431-
432475
.. _tt-cluster-authentication:
433476

434477
Authentication
@@ -507,21 +550,34 @@ Options
507550

508551
.. option:: --force
509552

510-
**Applicable to:** ``publish``
553+
**Applicable to:** ``publish``, ``replicaset``
554+
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:`.
557+
558+
.. option:: -G, --global
559+
560+
**Applicable to:** ``replicaset roles``
561+
562+
Apply the operation to the global configuration scope, that is, to all instances.
563+
564+
.. option:: -g, --group
565+
566+
**Applicable to:** ``publish``, ``replicaset roles``
511567

512-
Skip validation when publishing. Default: `false` (validation is enabled).
568+
A name of the configuration group to which the operation applies.
513569

514-
.. option:: --group
570+
.. option:: -i, --instance
515571

516-
**Applicable to:** ``publish``
572+
**Applicable to:** ``replicaset roles``
517573

518-
A name of the configuration group to which the instance belongs.
574+
A name of the instance to which the operation applies.
519575

520-
.. option:: --replicaset
576+
.. option:: -r, --replicaset
521577

522-
**Applicable to:** ``publish``
578+
**Applicable to:** ``publish``, ``replicaset roles``
523579

524-
A name of the replica set to which the instance belongs.
580+
A name of the replica set to which the operation applies.
525581

526582
.. option:: -t, --timeout UINT
527583

@@ -548,7 +604,7 @@ Options
548604

549605
This option is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
550606

551-
**Applicable to:** ``publish``
607+
**Applicable to:** ``publish``, ``replicaset``
552608

553609
Generate hashes and signatures for integrity checks.
554610

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:** ``promote``, ``demote``, ``expel``, ``roles``
642+
643+
Generate hashes and signatures for integrity checks.
644+
521645
.. option:: -y, --yes
522646

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

0 commit comments

Comments
 (0)