Repository navigation
mgr/ActivePyModules: use RAII for perf schema section management - #69181
SrinivasaBharath merged 1 commit into
Conversation
tchaikov
left a comment
There was a problem hiding this comment.
the commit message reads:
This fixes a crash ..
...
Fixes: https://tracker.ceph.com/issues/74693
but it does not -- it's a refactoring instead of a fix. probably we should drop these statement and tag.
37ca0a4 to
b316c96
Compare
Agreed, these were fixed already by adding a guard around the final close_sections in #68213. For clarity, I've amended my commit message to reflect that this is a refactor for RAII. I've pushed the new commit, implementing the changes requested from your review. I ran clang-format on only the perf schema functions for this commit, let me know if you think it'd be a good idea to do so for the entire ActivePyModules file. Thanks for the review! |
afae75d to
abe794b
Compare
|
@tchaikov I believe I've gotten to everything, and have pushed a new commit |
bf230a1 to
1eb0f78
Compare
|
Hey @tchaikov I believe my newest commit has covered your review if you wanted to take another look. Thanks for reviewing! |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
please resolve the conflicts and ping me again. |
Refactor get_perf_schema_python() and get_unlabeled_perf_schema_python() to use Formatter::ObjectSection and Formatter::ArraySection RAII helpers instead of manual close_section() calls. Manual closes have have led to crashes when close_section() calls were left unguarded, for example when an OSD with no perf counters had it's perf counters queried. Fixes: https://tracker.ceph.com/issues/74693 Signed-off-by: stzuraski898 <[email protected]>
1eb0f78 to
078b140
Compare
|
@tchaikov I've resolved the conflict, thanks! |
|
This is an automated message by src/script/redmine-upkeep.py. I found one or more
The referenced tickets are: Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them. |
…_schema PR ceph#69181 (tracker ceph#74693) refactored get_unlabeled_perf_schema_python() and get_perf_schema_python() in ActivePyModules.cc to replace manual open_object_section()/close_section() pairs with RAII Formatter::ObjectSection guards and std::optional lifetime management. The existing QA coverage had four gaps: - get_perf_schema_python() was never called by any test - get_unlabeled_perf_schema() was called but its return value was discarded - The wildcard (svc_type="") and by-service (svc_id="") daemon-selection branches were never exercised - The label-transition branch (same counter group, different label set) inside get_perf_schema_python() was never triggered Changes: src/pybind/mgr/selftest/module.py: - Add _collect_perf_schema() which runs all schema queries, asserts structural and value correctness (field presence, type bitmask range 1..31, priority range 0..10, units in {0,1}), and returns the raw data as a dict for external inspection. - Add 'mgr self-test perf-schema-test' CLI command that calls _collect_perf_schema() and returns the result as JSON on stdout, allowing the teuthology test to assert on real values rather than relying on assertions hidden inside the mgr process. - Fold _self_test_perf_counters() into a one-line call to _collect_perf_schema() so selftest run coverage is preserved. qa/tasks/mgr/test_module_selftest.py: - Add test_selftest_perf_schema() which calls 'ceph mgr self-test perf-schema-test', parses the JSON, and asserts all top-level keys and empty-state sentinels are present and correct. qa/tasks/mgr/test_perf_schema.py (new): - TestPerfSchema MgrTestCase with eight focused test methods that call 'ceph mgr self-test perf-schema-test', parse the JSON, and assert using self.assert*. Covers: exact-lookup, wildcard (get_all), by-service (get_by_service), empty daemon state, and labeled schema structure for both get_unlabeled_perf_schema and get_perf_schema. qa/suites/rados/mgr/tasks/4-units/perf_schema.yaml (new): - Drops into the existing pick-one 4-units/ slot. No other YAML changes required; cephfs_test_runner picks up the new test class automatically. Fixes: https://tracker.ceph.com/issues/74693 Signed-off-by: Steven Zuraski <[email protected]> Assisted by: IBM Bob
…_schema PR ceph#69181 (tracker ceph#74693) refactored get_unlabeled_perf_schema_python() and get_perf_schema_python() in ActivePyModules.cc to replace manual open_object_section()/close_section() pairs with RAII Formatter::ObjectSection guards and std::optional lifetime management. The existing QA coverage had three gaps: - get_perf_schema_python() was never called by any test - get_unlabeled_perf_schema() was called but its return value was discarded - The wildcard (svc_type="") and by-service (svc_id="") daemon-selection branches were never exercised Changes: src/pybind/mgr/selftest/module.py: - Add _collect_perf_schema() which runs all schema queries, asserts structural and value correctness (field presence, type bitmask range 1..31, priority range 0..10, units in {0,1}) using self.PERFCOUNTER_* constants from MgrModule, and returns the raw data as a dict for external inspection. - Add 'mgr self-test perf-schema-test' CLI command that calls _collect_perf_schema() and returns the result as JSON on stdout, allowing the teuthology test to assert on real values rather than relying on assertions hidden inside the mgr process. - Fold _self_test_perf_counters() into a one-line call to _collect_perf_schema() so selftest run coverage is preserved. qa/tasks/mgr/test_perf_schema.py (new): - TestPerfSchema MgrTestCase with six focused test methods that call 'ceph mgr self-test perf-schema-test', parse the JSON, and assert structural correctness using self.assert*. Covers: exact-lookup, wildcard (get_all), by-service (get_by_service), empty daemon state, and labeled schema structure for both get_unlabeled_perf_schema and get_perf_schema. Value-range validation is intentionally left to the mgr-side assertions in _collect_perf_schema() to avoid duplication. qa/suites/rados/mgr/tasks/4-units/perf_schema.yaml (new): - Drops into the existing pick-one 4-units/ slot. No other YAML changes required; cephfs_test_runner picks up the new test class automatically. Fixes: https://tracker.ceph.com/issues/74693 Signed-off-by: stzuraski898 <[email protected]> Assisted by: IBM Bob
…_schema PR ceph#69181 (tracker ceph#74693) refactored get_unlabeled_perf_schema_python() and get_perf_schema_python() in ActivePyModules.cc to use RAII Formatter::ObjectSection guards. The existing QA coverage had three gaps: get_perf_schema_python() was never called, get_unlabeled_perf_schema() return value was discarded, and the wildcard/by-service daemon-selection branches were never exercised. Add _collect_perf_schema() to selftest/module.py which exercises all six query variants (exact, wildcard, by-service for both labeled and unlabeled) and asserts structural correctness inline. Expose it via three new CLI commands — 'mgr self-test perf-schema-test' (returns full JSON), 'mgr self-test dump-unlabeled-perf-schema', and 'mgr self-test dump-perf-schema' — so teuthology tests can inspect real values rather than relying on assertions hidden inside the mgr process. Update _self_test_perf_counters() to call get_perf_schema() rather than get_unlabeled_perf_schema() to preserve existing selftest run coverage. Add qa/tasks/mgr/test_perf_schema.py with seven test methods covering exact-lookup, wildcard, by-service, empty daemon state, and labeled schema structure for both APIs. Add qa/suites/rados/mgr/tasks/4-units/perf_schema.yaml to drop into the existing pick-one slot. Fixes: https://tracker.ceph.com/issues/74693 Signed-off-by: stzuraski898 <[email protected]> Assisted by: IBM Bob
…_schema PR ceph#69181 (tracker ceph#74693) refactored get_unlabeled_perf_schema_python() and get_perf_schema_python() in ActivePyModules.cc to use RAII Formatter::ObjectSection guards, but left test coverage gaps. Add _collect_perf_schema() to selftest/module.py as a pure collector that calls all six query variants (exact, wildcard, by-service for both labeled and unlabeled APIs) and returns the raw results. Expose it via three CLI commands: ceph mgr self-test perf-schema-test ceph mgr self-test dump-unlabeled-perf-schema <svc_type> <svc_id> ceph mgr self-test dump-perf-schema <svc_type> <svc_id> Add qa/tasks/mgr/test_perf_schema.py with seven test methods that assert the structural shape of each query variant: exact lookup keyed by 'osd.0', wildcard covering all daemons, by-service filtering, labeled schema list-of-entries structure (labels + counters dicts), and empty-result behaviour for a non-existent service type. Add qa/suites/rados/mgr/tasks/4-units/perf_schema.yaml to slot the new test into the existing pick-one teuthology task suite. Also call both get_unlabeled_perf_schema() and get_perf_schema() in _self_test_perf_counters() so that 'mgr self-test run' smoke-tests both APIs. Fixes: https://tracker.ceph.com/issues/79553 Signed-off-by: stzuraski898 <[email protected]> Assisted by: IBM Bob
…_schema PR ceph#69181 (tracker ceph#74693) refactored get_unlabeled_perf_schema_python() and get_perf_schema_python() in ActivePyModules.cc to use RAII Formatter::ObjectSection guards, but left test coverage gaps. Add _collect_perf_schema() to selftest/module.py as a pure collector that calls all six query variants (exact, wildcard, by-service for both labeled and unlabeled APIs) and returns the raw results. Expose it via three CLI commands: ceph mgr self-test perf-schema-test ceph mgr self-test dump-unlabeled-perf-schema <svc_type> <svc_id> ceph mgr self-test dump-perf-schema <svc_type> <svc_id> Add qa/tasks/mgr/test_perf_schema.py with seven test methods that assert the structural shape of each query variant: exact lookup keyed by 'osd.0', wildcard covering all daemons, by-service filtering, labeled schema list-of-entries structure (labels + counters dicts), and empty-result behaviour for a non-existent service type. Add qa/suites/rados/mgr/tasks/4-units/perf_schema.yaml to slot the new test into the existing pick-one teuthology task suite. Also call both get_unlabeled_perf_schema() and get_perf_schema() in _self_test_perf_counters() so that 'mgr self-test run' smoke-tests both APIs. Fixes: https://tracker.ceph.com/issues/79553 Signed-off-by: stzuraski898 <[email protected]> Assisted by: IBM Bob
Refactor get_perf_schema_python() and get_unlabeled_perf_schema_python() to use Formatter::ObjectSection and Formatter::ArraySection RAII helpers instead of manual close_section() calls. Manual closes have have led to crashes when close_section() calls were left unguarded, for example when an OSD with no perf counters had it's perf counters queried.
Following up on comments within the original PR here: #67156
Modified both labeled and unlabeled paths to use RAII to have code consistency.
An additional related PR, made in response to findings from Unit Tests, can be found here #68213.
PR 68213 also resolves the segfault caused by an OSD having no counters hitting an unguarded close_section, but the RAII approach is ideal, and worthy of another PR.
Fixes: https://tracker.ceph.com/issues/74693
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.