Skip to content

Commit 0fe0789

Browse files
authored
Merge pull request ceph#64161 from tchaikov/wip-doc-mgr-module-config
doc: Document ceph-mgr module configuration options Reviewed-by: Zac Dover <[email protected]> Reviewed-by: Ville Ojamo <[email protected]>
2 parents 251f177 + 121192f commit 0fe0789

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

doc/dev/config.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ the configuration. Just like with set_val, you should call apply_changes after
9696
calling these functions to make sure your changes get applied.
9797

9898

99+
.. _dev config defining options:
100+
99101
Defining config options
100102
=======================
101103

@@ -104,6 +106,13 @@ by their consumers. If an option is only used by ceph-osd, it should go to
104106
``osd.yaml.in``. All the ``.yaml.in`` files are translated into ``.cc`` and ``.h`` files
105107
at build time by ``y2c.py``.
106108

109+
.. note::
110+
Ceph-mgr modules use the same configuration system as other Ceph components,
111+
but their configuration options are defined within each module's Python
112+
implementation. For details on defining mgr module configuration options,
113+
see :ref:`mgr module dev configuration options`.
114+
115+
107116
Each option is represented using a YAML mapping (dictionary). A typical option looks like
108117

109118
.. code-block:: yaml

doc/mgr/modules.rst

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ be automatically processed. Example:
400400
401401
.. _`Rule of Silence`: http://www.linfo.org/rule_of_silence.html
402402

403+
.. _mgr module dev configuration options:
403404

404405
Configuration options
405406
---------------------
@@ -412,15 +413,71 @@ Modules can load and store configuration options using the
412413
certificates). If you want to persist module-internal data or
413414
binary configuration data consider using the `KV store`_.
414415

415-
You must declare your available configuration options in the
416-
``MODULE_OPTIONS`` class attribute, like this:
416+
Configuration options must be declared in the ``MODULE_OPTIONS`` class attribute:
417417

418418
.. code-block:: python
419419
420420
MODULE_OPTIONS = [
421-
Option(name="my_option")
421+
Option(name="check_interval",
422+
level=OptionLevel.ADVANCED,
423+
default=60,
424+
type="secs",
425+
desc="The interval in seconds to check the inbox",
426+
long_desc="The interval in seconds to check the inbox. Set to 0 to disable the check",
427+
min=0,
428+
runtime=True)
422429
]
423430
431+
The example above demonstrates most supported properties, though typically only
432+
a subset is needed. The following properties are supported:
433+
434+
**name**
435+
The option's name. This is the only required property.
436+
437+
**type** (optional, default: ``str``)
438+
The option's data type. Supported types:
439+
440+
* ``uint`` - unsigned 64-bit integer
441+
* ``int`` - signed 64-bit integer
442+
* ``str`` - string
443+
* ``float`` - double-precision floating point
444+
* ``bool`` - boolean
445+
* ``addr`` - Ceph messenger address for peer communication
446+
* ``addrvec`` - comma-separated list of Ceph messenger addresses
447+
* ``uuid`` - UUID as defined by `RFC 4122 <https://www.ietf.org/rfc/rfc4122.txt>`_
448+
* ``size`` - size value (stored as uint64_t)
449+
* ``secs`` - timespan in format ``"<number><unit>..."``, e.g., ``"3h 2m 1s"`` or ``"3weeks"``
450+
451+
Supported units: ``s``, ``sec``, ``second(s)``, ``m``, ``min``, ``minute(s)``,
452+
``h``, ``hr``, ``hour(s)``, ``d``, ``day(s)``, ``w``, ``wk``, ``week(s)``,
453+
``mo``, ``month(s)``, ``y``, ``yr``, ``year(s)``
454+
455+
* ``millisecs`` - timespan in milliseconds
456+
457+
**desc**
458+
Short description (can be a sentence fragment).
459+
460+
**long_desc**
461+
Detailed description using complete sentences or paragraphs.
462+
463+
**default**
464+
Default value for the option.
465+
466+
**min** / **max**
467+
Minimum and maximum allowed values.
468+
469+
**enum_allowed**
470+
For ``str`` type options, a list of allowed string values. Values outside this set are rejected.
471+
472+
**see_also**
473+
List of related option names (used in documentation only).
474+
475+
**tags**
476+
List of tags for categorizing the option (used in documentation only).
477+
478+
**runtime** (default: ``False``)
479+
Whether the option can be updated after module loading.
480+
424481
If you try to use ``set_module_option`` or ``get_module_option`` on options
425482
not declared in ``MODULE_OPTIONS``, an exception will be raised.
426483

0 commit comments

Comments
 (0)