]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rgw: include message field in reported errors
authorAdam King <adking@redhat.com>
Mon, 14 Apr 2025 20:57:30 +0000 (16:57 -0400)
committerAdam King <adking@redhat.com>
Thu, 24 Jul 2025 15:08:57 +0000 (11:08 -0400)
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 <adking@redhat.com>
(cherry picked from commit 61e2b24b467beea2b38ab9c16f6ecc72987b830e)

src/pybind/mgr/rgw/module.py

index f42c9cc64ec3a205f111ac83d24a51e77504170f..82560a567a8264b34d1d5f45dab72df864000282 100644 (file)
@@ -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))