Skip to content

Docs for roles/role_cfg #4221

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

Merged
merged 12 commits into from
Jun 10, 2024
Merged

Docs for roles/role_cfg #4221

merged 12 commits into from
Jun 10, 2024

Conversation

andreyaksenov
Copy link
Contributor

@andreyaksenov andreyaksenov commented May 23, 2024

Docs for roles.

  • Created several samples for demonstrating built-in and custom roles:
    • Updated the sharded_cluster_crud sample to using built-in CRUD roles.
    • Added a hello world role without config.
    • Added a hello world role with config.
    • Added a sample that demonstrates how to create an HTTP API role.
  • Updated the main Configuration topic:
  • Created a new Application roles topic inside Developing applications with Tarantool.
  • Config reference:
    • roles/roles_cfg options: roles
    • app options: app

This was linked to issues May 23, 2024
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 2 times, most recently from 1ea3af2 to 1609842 Compare May 27, 2024 08:10
@andreyaksenov andreyaksenov changed the title Roles samples MVP docs for roles/role_cfg May 27, 2024
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 2 times, most recently from b9c3af8 to 12b4c1c Compare May 27, 2024 10:00
@andreyaksenov andreyaksenov linked an issue May 27, 2024 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 3 times, most recently from 0bcfb08 to 8564127 Compare May 27, 2024 10:30
@andreyaksenov andreyaksenov marked this pull request as ready for review May 27, 2024 10:31
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 2 times, most recently from c8cd763 to 6359787 Compare May 27, 2024 12:05
@andreyaksenov andreyaksenov requested a review from ImeevMA May 27, 2024 12:08
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 2 times, most recently from ea06e5e to 92ff4ba Compare June 4, 2024 11:56
@andreyaksenov andreyaksenov linked an issue Jun 4, 2024 that may be closed by this pull request
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 8 times, most recently from 798140c to 2910993 Compare June 6, 2024 12:24
@andreyaksenov andreyaksenov force-pushed the roles-samples branch 2 times, most recently from d07d3e2 to adb540a Compare June 6, 2024 14:01
@andreyaksenov andreyaksenov requested a review from p7nov June 6, 2024 15:00
Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the decent work!

Copy link
Contributor

@p7nov p7nov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, I finally understood what are these application roles :)

One general question: should we maybe provide more cross-links to doc pages where built-in roles and module roles are explained or used? I mean, you say there are built-in roles, and the reader wonders What built-in roles? Is there a list? How to use them?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

An application role is a Lua module that implements specific functions or logic.
You can enable or turn off a particular role for certain instances in a configuration without restarting these instances.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enable or turn off" sounds inconsistent. Let's use one word for the two states (enable/disable or turn on/off)

Loading an application
**********************
This section describes how to enable and configure roles.
To learn how to develop custom roles, see :ref:`application_roles`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You write about custom roles, but there there is no explanation of non custom roles. Maybe add a sentence about them to the first paragraph?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, updated the intro of this section to tell a bit about different types of roles.

As the most of configuration options, roles and their configurations can be defined at :ref:`different levels <configuration_scopes>`.
Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the ``map`` type, there are some specifics of applying the configuration:

- For ``roles``, an instance's role takes precedence over roles defined at another level.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- For ``roles``, an instance's role takes precedence over roles defined at another level.
- For ``roles``, an instance's role overwrites all roles defined at another levels.

Nit: overwrites seems a more straightforward verb to explain that other roles are discarded.


Roles can be divided into the following groups:

- Roles provided by Tarantool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Roles provided by Tarantool.
- Tarantool's built-in roles.

Nit: this sounds more natural to me (if this wording is correct in our terminology).

Comment on lines +26 to +27
- A role is a container for privileges that can be granted to users. Learn more in :ref:`access_control_concepts_roles`.
- A role of a replica set in regard to sharding. Learn more in :ref:`vshard_config_sharding_roles`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A role is a container for privileges that can be granted to users. Learn more in :ref:`access_control_concepts_roles`.
- A role of a replica set in regard to sharding. Learn more in :ref:`vshard_config_sharding_roles`.
- A user role is a container for privileges that can be granted to users. Learn more in :ref:`access_control_concepts_roles`.
- A sharding role of a replica set in regard to sharding. Learn more in :ref:`vshard_config_sharding_roles`.

Just an idea, to decrease readers' confusion a bit

Copy link
Contributor Author

@andreyaksenov andreyaksenov Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user role

Sounds better but a role can also has a role :) So, it's better to keep it as is.

A sharding role of a replica set in regard to sharding.

sharding meets two times in this case and add some confusion.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To validate a role's configuration, you need to define the :ref:`validate([cfg]) <roles_api_reference_validate>` function.
The ``cfg`` argument allows you to get access to the provided :ref:`role's configuration <roles_create_custom_role_config>` and check its validity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ``cfg`` argument allows you to get access to the provided :ref:`role's configuration <roles_create_custom_role_config>` and check its validity.
The ``cfg`` argument provides access to the :ref:`role's configuration <roles_create_custom_role_config>` and check its validity.

Seems shorter and easier to read


.. _roles_create_space:

Specifics of creating spaces
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Specifics of creating spaces
Creating spaces in roles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to creating spaces for applications in general. So, I'm going to move this section outside this topic at some moment.


.. _roles_life_cycle_stopping_roles:

2) *Stopping roles*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Spotting removed roles or smth like that? the current wording surprised me and took some time to understand which roles we're talking about

For roles that :ref:`depend <roles_create_custom_role_dependencies>` on each other, their ``validate()``, ``apply()``, and ``stop()`` functions are executed taking into account the dependencies.
Suppose, there are two independent roles (``role1``, ``role2``) and three roles that depend on each other as follows:

.. code-block:: none
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a verbal explanation? It's unclear to me now.


.. data:: dependencies

(Optional) Define a role's dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(Optional) Define a role's dependencies.
(Optional) Role's dependencies.

Nit: IMO, verbs are not needed in option/parameter/variable descriptions in references.

@andreyaksenov
Copy link
Contributor Author

One general question: should we maybe provide more cross-links to doc pages where built-in roles and module roles are explained or used? I mean, you say there are built-in roles, and the reader wonders What built-in roles? Is there a list? How to use them?

It's a good idea. AFAIK, Tarantool provides only one role for now. For roles provided by external modules, this question goes beyond roles. Currently, I know two external modules that provide its own roles: CRUD and expirationd (and the docs gives a link to CRUD as an example). At the same time, any information for these modules are missing in our docs. I'll create an issue to think how to deal with this.

@andreyaksenov andreyaksenov merged commit fb2dd55 into latest Jun 10, 2024
1 check passed
@andreyaksenov andreyaksenov deleted the roles-samples branch June 10, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants