Repository navigation
mgr/prometheus: Fix healthcheck history column alignment and sort order - #71147
Prachi-Lasurkar wants to merge 1 commit into
Conversation
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
NitzanMordhai
left a comment
There was a problem hiding this comment.
@Prachi-Lasurkar, please see my comment
| max(len(k) for k in self.healthcheck.keys())) | ||
| fmt = (f"{{healthcheck_name:<{col_width}}} {{first_seen:<20}} " | ||
| f"{{last_seen:<20}} {{count:>5}} {{active:^6}}") | ||
| out.append(fmt.format( |
There was a problem hiding this comment.
col_width is computed from one self.healthcheck.keys() snapshot, but the header/rows below are built from a second, independent .keys() call plus per-key self.healthcheck[k] lookups. ThreadSafeLRUCacheDict only locks each individual call, not a read spanning several of them, and str never takes self.lock (the RLock check() holds while mutating).
So MetricCollectionThread can run check() between these snapshots:
- A new/longer healthcheck name added after col_width is computed won't fit -> reintroduces the misalignment bug this PR fixes.
- An entry evicted (LRU) between the .keys() snapshot and the later self.healthcheck[k] lookup -> KeyError.
Simplest fix: take one atomic snapshot via .items() (already lock-protected as a single call) and build everything off it.
There was a problem hiding this comment.
Thank you for the review, @NitzanMordhai!
You are right, the multiple independent .keys() and [k] calls were not atomic, leaving a window for MetricCollectionThread to mutate the dict between them.
Fixed by taking a single atomic snapshot at the start of str via self.healthcheck.items(), which locks once, copies the entire dict into a plain Python list, and releases. All subsequent operations - empty check, col_width, sort, rows, and footer count now work exclusively from this frozen snapshot with no further live dict access.
Please let me know if you have further feedback.
There was a problem hiding this comment.
@Prachi-Lasurkar thanks, please fix the following ci test errors:
338/352 Test #4: run-tox-mgr ...............................***Failed 457.99 sec 20:51:53 Requirement already satisfied: tox in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (4.63.0) 20:51:53 Requirement already satisfied: cachetools>=7.0.3 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (7.2.0) 20:51:53 Requirement already satisfied: colorama>=0.4.6 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (0.4.6) 20:51:53 Requirement already satisfied: filelock>=3.25 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (3.32.7) 20:51:53 Requirement already satisfied: packaging>=26 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (26.3) 20:51:53 Requirement already satisfied: platformdirs>=4.9.4 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (4.11.11) 20:51:53 Requirement already satisfied: pluggy>=1.6 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (1.6.0) 20:51:53 Requirement already satisfied: pyproject-api>=1.10 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (1.11.2) 20:51:53 Requirement already satisfied: python-discovery>=1.4.4 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (1.6.1) 20:51:53 Requirement already satisfied: tomli-w>=1.2 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (1.2.0) 20:51:53 Requirement already satisfied: tomli>=2.4 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (2.4.1) 20:51:53 Requirement already satisfied: typing-extensions>=4.15 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (4.16.0) 20:51:53 Requirement already satisfied: virtualenv>=21.1 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from tox) (21.9.0) 20:51:53 Requirement already satisfied: distlib<1,>=0.3.7 in /ceph/build/mgr-virtualenv/lib/python3.10/site-packages (from virtualenv>=21.1->tox) (0.4.3) 20:51:53 flake8: install_deps /ceph/src/pybind/mgr> python -I -m pip install flake8 20:51:53 flake8: commands[0] /ceph/src/pybind/mgr> flake8 --config=tox.ini alerts balancer cephadm ceph_secrets ceph_secrets_client.py ceph_secrets_types.py cli_api crash devicehealth diskprediction_local hello nvmeof iostat localpool mgr_module.py mgr_util.py cherrypy_mgr.py nfs object_format.py orchestrator prometheus rbd_support rgw selftest smb 20:51:53 prometheus/module.py:357:29: E128 continuation line under-indented for visual indent 20:51:53 prometheus/module.py:358:29: E128 continuation line under-indented for visual indent 20:51:53 2 E128 continuation line under-indented for visual indent 20:51:53 flake8: exit 1 (2.70 seconds) /ceph/src/pybind/mgr> flake8 --config=tox.ini alerts balancer cephadm ceph_secrets ceph_secrets_client.py ceph_secrets_types.py cli_api crash devicehealth diskprediction_local hello nvmeof iostat localpool mgr_module.py mgr_util.py cherrypy_mgr.py nfs object_format.py orchestrator prometheus rbd_support rgw selftest smb pid=159967 20:51:53 flake8: FAIL ✖ in 5.87 seconds
There was a problem hiding this comment.
@NitzanMordhai, I’ve made the code changes accordingly. Please review them.
|
ok to test |
c076fd3 to
75abae5
Compare
Dynamically calculate the healthcheck name column width to prevent misalignment and sort entries by Last Seen in descending order, showing the most recently active checks first. Fixes: https://tracker.ceph.com/issues/79527 Signed-off-by: Prachi Lasurkar <[email protected]>
75abae5 to
03d77d7
Compare
|
This PR has been added to wip-bharath9-testing-20261027.065249-main. |
Dynamically calculate the healthcheck name column width to prevent
misalignment and sort entries by Last Seen in descending order,
showing the most recently active checks first.
Fixes: https://tracker.ceph.com/issues/79527
Before Changes:
After Changes:
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.