]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: guard close_section calls in get_perf_schema_python 68213/head
authorLumir Sliva <61183145+lumir-sliva@users.noreply.github.com>
Sat, 4 Apr 2026 15:25:15 +0000 (17:25 +0200)
committerLumir Sliva <61183145+lumir-sliva@users.noreply.github.com>
Sat, 4 Apr 2026 15:25:15 +0000 (17:25 +0200)
When a daemon exists in the daemon state map but has no perf counters
(e.g. an OSD that was running but is now down or destroyed), the loop
in get_perf_schema_python never executes, leaving prev_key_name empty
and no formatter sections opened. The unconditional close_section()
calls after the loop then trigger an assertion failure in PyFormatter
(cursor != root).

Add the same `if (!prev_key_name.empty())` guard that already protects
the close_section() calls inside the loop, so we only close sections
that were actually opened.

Fixes: https://tracker.ceph.com/issues/75745
Signed-off-by: Lumir Sliva <61183145+lumir-sliva@users.noreply.github.com>
src/mgr/ActivePyModules.cc

index ab5e40898a7c244c9c2bb390447330ba7c0522f9..051c9517af7176341be704f9396a83c13ddcf796 100644 (file)
@@ -1264,8 +1264,10 @@ PyObject* ActivePyModules::get_perf_schema_python(
                << dendl;
          }
        }
-       f.close_section();  // close 'counters'
-       f.close_section();  // close 'counter object' section
+       if (!prev_key_name.empty()) {
+         f.close_section();  // close 'counters'
+         f.close_section();  // close 'counter object' section
+       }
       });
     }
   } else {