]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/crash, mgr/status: return negative errno to fix CLI exit code 68282/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 9 Apr 2026 12:37:40 +0000 (20:37 +0800)
committerKefu Chai <k.chai@proxmox.com>
Thu, 9 Apr 2026 12:40:35 +0000 (20:40 +0800)
commit7041f6b6b310165beee46ed45a0d34908716d159
tree4e01914636c7806499594de59f5371ba2228fb70
parent1574115b66e2793ccdc3d906a9ea88bab05f0655
mgr/crash, mgr/status: return negative errno to fix CLI exit code

The crash and status mgr modules return positive errno values (e.g.
errno.EINVAL) on error. However, the ceph CLI (src/ceph.in) only
treats negative return codes as errors:

    if ret < 0:
        final_ret = -ret

A positive return code falls through and the CLI exits with 0, masking
the error. This causes commands like "ceph crash post" and "ceph crash
info <bad-id>" to return success (rc=0) despite failing, with the
error message only appearing on stderr.

This was observed in the wild and worked around in a77b47eeeb57, which added a
stderr != "" check to ceph-crash's post_crash() as a mitigation.

Fix the root cause by negating the errno values in both modules,
consistent with the HandleCommandResult convention
(retval: "E.g. 0 or -errno.EINVAL") and the 154 other call sites
across mgr modules that already use negative errno.

Also add error-path tests for the crash module to cover the three
affected commands (info, post, archive).

See-also: a77b47eeeb5770eeefcf4619ab2105ee7a6a003e
Fixes: https://tracker.ceph.com/issues/75937
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
qa/tasks/mgr/test_crash.py
src/pybind/mgr/crash/module.py
src/pybind/mgr/status/module.py