Skip to content

tentacle: mgr: ensure that all modules have started before advertising active mgr - #67850

Merged
batrick merged 4 commits into
ceph:tentaclefrom
ljflores:wip-75564-tentacle
Apr 22, 2026
Merged

batrick merged 4 commits into
ceph:tentaclefrom
ljflores:wip-75564-tentacle

Conversation

@ljflores

@ljflores ljflores commented Mar 17, 2026 •

Copy link
Copy Markdown
Member

@github-actions

Copy link
Copy Markdown

Config Diff Tool Output

+ added: mgr_module_load_delay (mgr.yaml.in)
+ added: mgr_module_load_delay_name (mgr.yaml.in)
+ added: mgr_module_load_expiration (mgr.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@yaarith

yaarith commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

adding the rocky10-tentacle label to make testing easier; however, this fix is not specific to Rocky 10.

@ljflores

Copy link
Copy Markdown
Member Author

/config check ok

@ljflores

Copy link
Copy Markdown
Member Author

jenkins test api

@ljflores
ljflores requested a review from batrick April 6, 2026 21:41
@batrick batrick modified the milestones: tentacle, v20.2.2 Apr 7, 2026
@ljflores

ljflores commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

jenkins test api

@ljflores

Copy link
Copy Markdown
Member Author

One related failure from the QA testing:

This occurred in the latest testing because #67641 hasn't been backported to tentacle yet.

@ljflores
ljflores force-pushed the wip-75564-tentacle branch from 0f9e8a1 to 1969755 Compare April 17, 2026 21:59
@ljflores
ljflores requested a review from a team as a code owner April 17, 2026 21:59
@ljflores

ljflores commented Apr 17, 2026 •

Copy link
Copy Markdown
Member Author

Retesting without 740de93 here:
https://pulpito.ceph.com/?branch=wip-lflores-testing-2-2026-04-08-1424-tentacle

Failures, unrelated:

  1. https://tracker.ceph.com/issues/74332 - ceph-kvstore-tool segfault in workunits/cephtool/test_kvstore_tool.sh - (RADOS)
  2. https://tracker.ceph.com/issues/68668 - rados/dashboard: mkfs.xfs: cannot open /dev/vg_nvme/lv_2: Device or resource busy - (Orchestrator)
  3. https://tracker.ceph.com/issues/75821 - tentacle: Error: Container release umbrella != cephadm release tentacle; please use matching version of cephadm - (Orchestrator)
  4. https://tracker.ceph.com/issues/74524 - standalone/osd-backfill-prio.sh/TEST_backfill_pool_priority: "The primary PG X.X didn't become the in progress item on remote" - (RADOS)
  5. https://tracker.ceph.com/issues/74525 - TEST_bluestore_expand fails on "free space added" check (osd-bluefs-volume-ops.sh) - (bluestore)
  6. https://tracker.ceph.com/issues/74517 - drop.ceph.com is unreachable (ceph-post-file) - (RADOS)
  7. https://tracker.ceph.com/issues/74268 - Dashboard fails to start on non-orch-managed installation on Debian Bookworm - (Ceph)
  8. https://tracker.ceph.com/issues/68586 - cephadm: task/test_iscsi_container test hits max timeout - (Orchestrator)
  9. https://tracker.ceph.com/issues/75886 - tentacle: upgrade/parallel: failure to pull reef image during upgrade - (Orchestrator)
  10. https://tracker.ceph.com/issues/70716 - rados/thrash-old-clients: "pg backfill_toofull" warning in cluster log - (RADOS)
  11. https://tracker.ceph.com/issues/74518 - rados/perf: pools reached nearfull (POOL_NEARFULL) - (RADOS)
  12. https://tracker.ceph.com/issues/71344 - Monitor Reconnection Failure and MON_NETSPLIT due to Stale Global Sequence Check During Incoming Connection - (RADOS)

RADOS approved!

@ljflores

Copy link
Copy Markdown
Member Author

jenkins test api

1 similar comment
@ljflores

Copy link
Copy Markdown
Member Author

jenkins test api

----------------- Explanation of Problem ----------------

When the mgr is restarted or failed over via `ceph mgr fail` or during an
upgrade, mgr modules sometimes take longer to start up (this includes
loading their class, commands, and module options, and being removed
from the `pending_modules` map structure). This startup delay can happen
due to a cluster's specific hardware or if a code bottleneck is triggered in
a module’s `serve()` function (each mgr module has a `serve()` function that
performs initialization tasks right when the module is loaded).

When this startup delay occurs, any mgr module command issued against the
cluster around the same time fails with error saying that the command is not
supported:
```
$ ceph mgr fail; ceph fs volume ls
Error ENOTSUP: Warning: due to ceph-mgr restart, some PG states may not be up to date
Module 'volumes' is not enabled/loaded (required by command 'fs volume ls'): use `ceph mgr module enable volumes` to enable it
```

We should try to lighten any bottlenecks in the mgr module `serve()`
functions wherever possible, but the root cause of this failure is that the
mgr sends a beacon to the mon too early, indicating that it is active before
the module loading has completed. Specifically, some of the mgr modules
have loaded their class but have not yet been deleted from the `pending_modules`
structure, indicating that they have not finished starting up.

--------------------- Explanation of Fix  --------------------

This commit improves the criteria for sending the “active” beacon to the mon so
the mgr does not signal that it’s active too early. We do this through the following additions:

1. A new context `ActivePyModules::recheck_modules_start` that will be set if not all modules
   have finished startup.

2. A new function `ActivePyModules::check_all_modules_started()` that checks if modules are
   still pending startup; if all have started up (`pending_modules` is empty), then we send
   the beacon right away. But if some are still pending, we pass the beacon task on to the new
   recheck context `ActivePyModules::recheck_modules_start` so we know to send the beacon later.

3. Logic in ActivePyModules::start_one() that only gets triggered if the modules did not all finish
   startup the first time we checked. We know this is the case if the new recheck context
   `recheck_modules_start` was set from `nullptr`. The beacon is only sent once `pending_modules` is
   confirmed to be empty, which means that all the modules have started up and are ready to support commands.

4. Adjustment of when the booleans `initializing` and `initialized` are set. These booleans come into play in
   MgrStandby::send_beacon() when we check that the active mgr has been initialized (thus, it is available).
   We only send the beacon when this boolean is set. Currently, we set these booleans at the end of Mgr::init(),
   which means that it gets set early before `pending_modules` is clear. With this adjustment, the bools are set
   only after we check that all modules have started up. The send_beacon code is triggered on mgr failover AND on
   every Mgr::tick(), which occurs by default every two seconds. If we don’t adjust when these bools are set, we
   only fix the mgr failover part, but the mgr still sends the beacon too early via Mgr::tick(). Below is the relevant
   code from MgrStandby::send_beacon(), which is triggered in Mgr::background_init() AND in Mgr::tick():
```
  // Whether I think I am available (request MgrMonitor to set me
  // as available in the map)
  bool available = active_mgr != nullptr && active_mgr->is_initialized();

  auto addrs = available ? active_mgr->get_server_addrs() : entity_addrvec_t();
  dout(10) << "sending beacon as gid " << monc.get_global_id() << dendl;

```

--------------------- Reproducing the Bug ----------------------

At face value, this issue is indeterministically reproducible since it
can depend on environmental factors or specific cluster workloads.
However, I was able to deterministically reproduce it by injecting a
bottleneck into the balancer module:
```
diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py
index d12d69f..91c83fa8023 100644
--- a/src/pybind/mgr/balancer/module.py
+++ b/src/pybind/mgr/balancer/module.py
@@ -772,10 +772,10 @@ class Module(MgrModule):
                     self.update_pg_upmap_activity(plan)  # update pg activity in `balancer status detail`
                 self.optimizing = False
+                # causing a bottleneck
+                for i in range(0, 1000):
+                    for j in range (0, 1000):
+                        x = i + j
+                        self.log.debug("hitting the bottleneck in the balancer module")
             self.log.debug('Sleeping for %d', sleep_interval)
             self.event.wait(sleep_interval)
             self.event.clear()
```

Then, the error reproduces every time by running:
```
$ ./bin/ceph mgr fail; ./bin/ceph telemetry show
Error ENOTSUP: Warning: due to ceph-mgr restart, some PG states may not be up to date
Module 'telemetry' is not enabled/loaded (required by command 'telemetry show'): use `ceph mgr module enable telemetry` to enable it
```

With this fix, the active mgr is marked as "initialized" only after all
the modules have started up, and this error goes away. The command may
take a bit longer to execute depending on the extent of the delay.

---------------------- Integration Testing ---------------------

This commit adds a dev-only config that can inject a longer
loading time into the mgr module loading sequence so we can
simulate this scenario in a test.

The config is 0 ms by default since we do not add any delay
outside of testing scenarios. The config can be adjusted
with the following command:
  `ceph config set mgr mgr_module_load_delay <ms>`

A second dev-only config also allows you to specify which
module you want to be delayed in loading time. You may change
this with the following command:
  `ceph config set mgr mgr_module_load_delay_name <module name>`

The workunit added here tests a simulated slow loading module
scenario to ensure that this case is properly handled.

--------------------- Documentation --------------------

The new documentation describes the three existing mgr states so Ceph
operators can better interpret their Ceph status output.

Fixes: https://tracker.ceph.com/issues/71631
Signed-off-by: Laura Flores <[email protected]>
(cherry picked from commit cbd1726)
…eded

----------------- Enhancement to the Original Fix -----------------

During a mgr failover, the active mgr is marked available if:
  1. The mon has chosen a standby to be active
  2. The chosen active mgr has all of its modules initialized

Now that we've improved the criteria for sending the "active" beacon
by enforcing it to retry initializing mgr modules, we need to account
for extreme cases in which the modules are stuck loading for a very long
time, or even indefinitely. In these extreme cases where the modules might
never initialize, we don't want to delay sending the "active" beacon for
too long. This can result in blocking other important mgr functionality,
such as reporting PG availability in the health status. We want
to avoid sending warnings about PGs being unknown in the health status when
that's not ultimately the problem.

To account for an exeptionally long module loading time, I added a new
configurable `mgr_module_load_expiration`. If we exceed this maximum amount
of time (in ms) allotted for the active mgr to load the mgr modules before declaring
availability, the standby will then proceed to mark itself "available" and
send the "active" beacon to the mon and unblock other critical mgr functionality.

If this happens, a health error will be issued at this time, indicating
which mgr modules got stuck initializing (See src/mgr/PyModuleRegistry.cc). The
idea is to unblock the rest of the mgr's critical functionality while making it
clear to Ceph operators that some modules are unusable.

--------------------- Integration Testing --------------------

The workunit was rewritten so it tests for these scenarios:

1. Normal module loading behavior (no health error should be issued)
2. Acceptable delay in module loading behavior (no health error should be
   issued)
3. Unacceptable delay in module loading behavior (a health error should be
   issued)

--------------------- Documentation --------------------

This documentation explains the "Module failed to initialize"
cluster error.

Users are advised to try failing over
the mgr to reboot the module initialization process,
then if the error persists, file a bug report. I decided
to write it this way instead of providing more complex
debugging tips such as advising to disable some mgr modules
since every case will be different depending on which modules
failed to initialize.

In the bug report, developers can ask for the health detail
output to narrow down which module is causing a bottleneck,
and then ask the user to try disabling certain modules until
the mgr is able to fully initialize.

Fixes: https://tracker.ceph.com/issues/71631
Signed-off-by: Laura Flores <[email protected]>
(cherry picked from commit bf25a08)
Now, the command `ceph tell mgr mgr_status` will show a
"pending_modules" field. This is another way for Ceph operators
to check which modules haven't been initalized yet (in addition
to the health error).

This command was also added to testing scenarios in the workunit.

Fixes: https://tracker.ceph.com/issues/71631
Signed-off-by: Laura Flores <[email protected]>
(cherry picked from commit 6822166)
The current check groups modules not being
enabled with failing to initialize. In this commit,
we reorder the checks:

1: Screen for a module being enabled. If it's not,
   issue an EOPNOTSUPP with instructions on how
   to enable it.

2. Screen for if a module is active. If a module
   is enabled, then the cluster expects it to
   be active to support commands. If the module
   took too long to initialize though, we will
   catch this and issue an ETIMEDOUT error with
   a link for troubleshooting.

Now, these two separate issues are not grouped
together, and they are checked in the right order.

Fixes: https://tracker.ceph.com/issues/71631
Signed-off-by: Laura Flores <[email protected]>
(cherry picked from commit fdc072f)
@ljflores
ljflores force-pushed the wip-75564-tentacle branch from 1969755 to 1f93c9f Compare April 21, 2026 15:57
@ljflores

Copy link
Copy Markdown
Member Author

Rebased the branch.

@batrick

batrick commented Apr 21, 2026

Copy link
Copy Markdown
Member

@batrick
batrick merged commit b7c497b into ceph:tentacle Apr 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants