From d61095d97921042eb05bd9354a50b223f0ee0c58 Mon Sep 17 00:00:00 2001 From: Adam King Date: Mon, 14 Apr 2025 16:57:30 -0400 Subject: [PATCH] mgr/rgw: include message field in reported errors This is in response to trying to debug ``` [ceph: root@vm-00 /]# ceph rgw realm bootstrap -i specs/rgw.yaml Error EEXIST: ``` The lack of useful information in the error message made this more difficult than it needed to be. With this patch, the same error now gives ``` [ceph: root@vm-00 /]# ceph rgw realm bootstrap -i specs/rgw.yaml failed to create system user: Command error (-17): user create --uid sysuser-my_realm_ck --display-name sysuser-my_realm_ck --system --rgw-zonegroup my_zonegroup_ck --zonegroup-id 428a28d1-c8a9-4c12-a408-29507ef23842 --rgw-zone my_zone_ck --zone-id 161ee2ab-bc96-4729-a2b5-0d170e347129 stdout: stderr:could not create user: unable to parse parameters, user: sysuser-my_realm_ck exists Error EEXIST: ``` which is a bit more verbose than is maybe needed, but at least gives you actual hints as to what went wrong Signed-off-by: Adam King (cherry picked from commit 61e2b24b467beea2b38ab9c16f6ecc72987b830e) --- src/pybind/mgr/rgw/module.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/rgw/module.py b/src/pybind/mgr/rgw/module.py index f42c9cc64ec3a..82560a567a826 100644 --- a/src/pybind/mgr/rgw/module.py +++ b/src/pybind/mgr/rgw/module.py @@ -210,7 +210,33 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): RGWAM(self.env).realm_bootstrap(spec, start_radosgw) except RGWAMException as e: self.log.error('cmd run exception: (%d) %s' % (e.retcode, e.message)) - return HandleCommandResult(retval=e.retcode, stdout=e.stdout, stderr=e.stderr) + # The RGWAM code isn't always consistent about what goes into stdout + # and message fields. What is known is there are definitely some cases + # where the message field contains useful info and the stdout field + # does not, which means just giving the stdout can result in not so useful + # return messages, e.g. + # + # [ceph: root@vm-00 /]# ceph rgw realm bootstrap -i specs/rgw.yaml + # Error EEXIST: + # + # For that reason, we want to include the msg in what we return. Doing so + # transformed the same error case that just gave us "Error EEXIST:" into + # + # [ceph: root@vm-00 /]# ceph rgw realm bootstrap -i specs/rgw.yaml + # failed to create system user: Command error (-17): user create --uid sysuser-my_realm_ck + # --display-name sysuser-my_realm_ck --system --rgw-zonegroup my_zonegroup_ck --zonegroup-id + # 428a28d1-c8a9-4c12-a408-29507ef23842 --rgw-zone my_zone_ck --zone-id 161ee2ab-bc96-4729-a2b5-0d170e347129 + # stdout: + # stderr:could not create user: unable to parse parameters, user: sysuser-my_realm_ck exists + # Error EEXIST: + # + # which is much more useful + msg = e.message + if msg and e.stdout and (e.stdout not in msg): + msg = f'{msg}; {e.stdout}' + elif e.stdout: + msg = e.stdout + return HandleCommandResult(retval=e.retcode, stdout=msg, stderr=e.stderr) except PoolCreationError as e: self.log.error(f'Pool creation failure: {str(e)}') return HandleCommandResult(retval=-errno.EINVAL, stderr=str(e)) -- 2.39.5