Repository navigation
cephadm: Version Tracking - #65592
Conversation
55974ff to
98723d4
Compare
|
|
||
| Cephadm tracks all cluster version history and allows accessing | ||
| of this information for debugging purposes. Information is handled | ||
| with two main CLI commands. |
There was a problem hiding this comment.
This information is managed with two CLI commands.
There was a problem hiding this comment.
Is this information captured already, or only once this code is merged and released? If a cluster is midway through an upgrade, or, say, RGW is redeployed with a hotfix, there will be multiple versions of daemons in play. In these cases, what version will be recorded?
There was a problem hiding this comment.
This information would be captured once the code is merged and released. Right now it's only the main cluster version that is recorded, so that would be during bootstrap and when upgrade is marked complete. It doe not yet deal with the scenario upgrade is partial or track specific daemon versions yet.
There was a problem hiding this comment.
Ack, thanks. Suggest that we make that clear. As currently worded a reader might reasonably think that prior releases will be shown.
There was a problem hiding this comment.
Ack, so make clear that version history is only stored after this change is added?
There was a problem hiding this comment.
Changes implemented
|
|
||
| ceph cephadm get-cluster-version-history | ||
|
|
||
| This command will display the entire version history stored in |
There was a problem hiding this comment.
This command displays the stored version history in chronological order.
|
Interesting concept - but I do need to ask right away about the use of the sqlite functions. I was under the impression that cephadm avoids using the mgr sqlite support. The major reason is that cephadm is expected to work when there are no osds and no pools (the .mgr pool stores the sqlite db objects). With that reason - it becomes a bit harder to justify storing some cephadm data one way, but other data another.* Have you discussed the use of the ceph sqlite3 storage with anyone else from the cephadm team yet? Have you tested this feature works as expected if the .mgr pool is unavailable? Did you investigate using other mechanisms for storing this data?
|
I've discussed it with the ceph l3 engineering team and my mentor Prashant Dhange, we wanted to use sqlite for its relational data capabilities which is used currently to match cluster version with time it was put in that version. There were other possible options like KV store, but KV store doesn't have the ability to relate data on the scale of sqlite, also this feature does work when .mgr pool is unavailable, any function that tries to access the mgr db will first check if its ready, if it is not ready it will stop and send an errno message. |
Yep, that's the reason to want to use it.
Well, the entire rest of cephadm uses KV based on existing helper functions. This includes stuff like the inventory, which is a non-trivial amount of data. It has drawbacks of course but I do still wonder what the scale of this data would be. What do you imagine (in bytes) would be used approximately after say 3 years?
I'm not entirely sure what you mean by this. If you are saying: if pools can't exist we won't record anything and that's OK - well fair enough. But consider a scenario like the following Admin A begins installing ceph by bootstrapping a cluster and maybe a few mon nodes but never gets around to installing OSDs before leaving the company. A few months later Admin B decides to return to the never-completed ceph cluster and starts by performing an upgrade FIRST to make sure all bits are using a recent ceph before resuming setting up the other parts of the cluster. This upgrade would not be logged in this scenario, right? Also consider the user experience of running the commands when the .mgr pool does not exist. An errno carries less information, but we can often try to produce errors that are explain to the user the why a failure: "db unavailable" vs "db unavailable - no OSDs deployed". Just food for thought. |
|
Oh, BTW I noticed the Signed-off-by check failing. You have the trailer in the commits but I think they are incorrectly formatted and that's why the check is failing. Try reformatting them as: The important bit (I think) is to surround your email address with angle brackets. PS. Git can do that for you if you configure it: for example - https://sourcecodeera.com/blogs/DavidLee/How-do-you-sign-off-on-commits-in-Git |
Sorry I think my wording was bad, by scale I meant ability to store data in a relational manner not scale as in total bytes, I am unsure of the exact byte amount, that would depend on if this feature is expanded to track specific daemon versions, if it was just the current state of storing the cluster version, there would be very little space requirement since total cluster upgrades would be rarer you would only expect a few entries. You are correct in the scenario that osds are not up and an upgrade is initiated the version history there would not be tracked, I did see though in my testing that when trying to upgrade without osds present there is warnings given to the user I assumed that this scenario would be very rare. I can see why we would want to consider it though. Edit: Checking my code I realized that I actually block the upgrade process if the mgr db is not ready by raising orchestrator error, which looks like its causing an error in the make check, the error seems to be caused by a ceph option not being set properly during upgrade start? That's a good idea the error message could be made more descriptive. |
I'll look into this. |
98723d4 to
fce1f96
Compare
7a809c6 to
7e904af
Compare
7c8a422 to
0d828a5
Compare
adk3798
left a comment
There was a problem hiding this comment.
Overall idea seems good. My review offers little on the DB specific stuff but I think I'm okay with what's being done as long as it doesn't cause any regressions
|
I suggest making the PR / commit messages an imperative, e.g. "cephadm: Add version tracking". |
I will keep in mind for future. I think rebasing to fix all previous commit titles would be too much for too little. |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
Can one of the admins verify this patch? |
b3a4e78 to
189f8d5
Compare
| try: | ||
| ret, out, err = self.mgr.check_mon_command({ | ||
| 'prefix': 'config dump', | ||
| 'format': 'json', | ||
| }) | ||
| except Exception as e: | ||
| self.mgr.log.error(f'Version Tracker: {e}') | ||
| config_dump = None | ||
| else: | ||
| if not out: | ||
| config_dump = None | ||
| else: | ||
| config_dump = json.loads(out) |
There was a problem hiding this comment.
This code will blowup if the json is malformed (shouldn't happen anyway). I'd recommend using better:
def add_cluster_version(self, version: str, time: str, params: dict, status: UpgradeStatus) -> None:
# Extracts config dump json and stores in config_dump variable
try:
ret, out, err = self.mgr.check_mon_command({
'prefix': 'config dump',
'format': 'json',
})
config_dump = json.loads(out) if out else None
except Exception as e:
self.mgr.log.error(f'Version Tracker: {e}')
config_dump = None
| # Changes status field depending on if upgrade was completed or was stopped | ||
| raw = self.mgr.get_store_prefix(VERSION_HISTORY_KEY_PREFIX) | ||
| latest_entry_key, latest_entry_value = next(reversed(raw.items())) | ||
|
|
There was a problem hiding this comment.
plz remove all the non-funcional white lines .. they just make the code hard to read follow. In general , I'd recommend to only introduce lines to separate big non-related logic blocks.
| res = {k[prefix_len:]: json.loads(v) for (k, v) in raw.items()} | ||
|
|
||
| if not res: | ||
| return 0, 'No Cluster Version History Stored', '' |
There was a problem hiding this comment.
this is not the right place to handle return codes/strings... you are just returning always the same values. Plz move this to the module.py this function should only return a string with the version history
|
|
||
| def remove_cluster_version_history(self, all: Optional[bool] = False, before: Optional[str] = None, after: Optional[str] = None) -> Tuple[int, str, str]: | ||
| if not all and not before and not after: | ||
| return -errno.EINVAL, '', 'requires at least one of the options "all", "before", "after" to be set' |
There was a problem hiding this comment.
this error handling has to be done in the module.py, the version module should return errors or raise exceptions if needed
| This command displays stored version history stored in | ||
| chronological order. If ``--all`` is passed all info | ||
| stored will be displayed as well, currently this would | ||
| only be the config dump. |
There was a problem hiding this comment.
@timqn22 I'd recommend not using all as argument bcz it can be easily mistaken with filtering. I'd recommend using something else (maybe --show-details or --show-config) ...
There was a problem hiding this comment.
@rkachach would --config be acceptable, the option doesn't work properly with - in name for some reason.
8731739 to
649031f
Compare
| if err: | ||
| return HandleCommandResult(retval=err, stderr=msg) | ||
| return HandleCommandResult(retval=err, stdout=msg) |
There was a problem hiding this comment.
This is equivalent to this compact version:
kwargs = {'stderr': msg} if err else {'stdout': msg}
return HandleCommandResult(retval=err, **kwargs)
649031f to
095bbef
Compare
This change rewrites the version tracker to use kv store instead of sql to store version information, the output is now nested jsons, with keys being the datetime of the upgrade, additionally config dump information is also extracted and recorded by the version tracker. A suite of unittest have also been added. Signed-off-by: Timothy Q Nguyen <[email protected]>
aee9a04 to
3f80ebc
Compare
I added code to handle in the case that someone is upgrading from a version that doesn't have the version tracker code. This is handle by adding an entry in update_cluster_version_status if no entries are found which would indicate that it's likely this edge case, this could also be triggered if someoned deleted all their previous entries which isn't advised anyways, it also covers the issue that the code wil fail badly if there were no entries. The reason the previous code didn't handle this edge case is because it adds entries on upgrade start which the code wouldn't be present until after they upgrade their mgrs. Signed-off-by: Timothy Q Nguyen <[email protected]>
3f80ebc to
ab033c1
Compare
|
@timqn22 Hi, Has failed on the following: 026-07-25T14:30:46.248 INFO:[email protected]:Jul 25 14:30:45 trial107 ceph-mon[93812]: Upgrade: unexpected exception during _do_upgrade
2026-07-25T14:30:46.248 INFO:[email protected]: Traceback (most recent call last):
2026-07-25T14:30:46.248 INFO:[email protected]: File "/usr/share/ceph/mgr/cephadm/upgrade.py", line 885, in continue_upgrade
2026-07-25T14:30:46.248 INFO:[email protected]: self._do_upgrade()
2026-07-25T14:30:46.248 INFO:[email protected]: File "/usr/share/ceph/mgr/cephadm/upgrade.py", line 2132, in _do_upgrade
2026-07-25T14:30:46.248 INFO:[email protected]: self._mark_upgrade_complete()
2026-07-25T14:30:46.248 INFO:[email protected]: File "/usr/share/ceph/mgr/cephadm/upgrade.py", line 1891, in _mark_upgrade_complete
2026-07-25T14:30:46.249 INFO:[email protected]: self.mgr.version_tracker.update_cluster_version_status(status=UpgradeStatus.COMPLETE)
2026-07-25T14:30:46.249 INFO:[email protected]: File "/usr/share/ceph/mgr/cephadm/version_tracker.py", line 52, in update_cluster_version_status
2026-07-25T14:30:46.249 INFO:[email protected]: latest_entry_key, latest_entry_value = next(reversed(raw.items())) |
Hi, yes this should be fix with the newly pushed code. |
cephadm: Version Tracking Reviewed-by: Adam King <[email protected]> (cherry picked from commit ff93b87)
cephadm: Version Tracking Reviewed-by: Adam King <[email protected]> Signed-off-by: Timothy Q Nguyen <[email protected]> (cherry picked from commit ff93b87)
This adds the version tracking feature to the Cephadm module. The version tracker tracks Ceph cluster version history and allows access to the information through CLI commands, ceph cephadm get-cluster-version-history and ceph cephadm remove-cluster-version-history. This is meant to support our developers/debuggers in their workflow.
Fixes: https://tracker.ceph.com/issues/73124
Signed-off-by: Timothy Q Nguyen [email protected]
Test Run (Personal Cluster with Modified Image):