From 4f7ba951993df00e172dc6240702c6895f3dd7ef Mon Sep 17 00:00:00 2001 From: James Harrison Date: Thu, 15 Apr 2021 11:26:46 +0100 Subject: [PATCH] MB-45684: Fix cbstats stats_key and stats_vkey error messages The exception is now printed rather than hitting an AttributeError. e.g., Memcached error #1: KEY_ENOENT : Not Found : Rather than the previous: Traceback (most recent call last): File ".../engines/ep/management/cbstats", line 539, in stats_key vbs = mc.stats(cmd) File ".../engines/ep/management/mc_bin_client.py", line 636, in stats cmd, opaque, cas, klen, extralen, data = self._handleKeyedResponse(None) File ".../engines/ep/management/mc_bin_client.py", line 292, in _handleKeyedResponse raise MemcachedError(errcode, msg) mc_bin_client.ErrorKeyEnoent: Memcached error #1: KEY_ENOENT : Not Found : During handling of the above exception, another exception occurred: Traceback (most recent call last): File ".../engines/ep/management/cbstats", line 1010, in main() File ".../engines/ep/management/cbstats", line 1007, in main c.execute() File ".../engines/ep/management/clitool.py", line 83, in execute f[0](mc, *args[2:], **opts.__dict__) File ".../engines/ep/management/cbstats", line 49, in g f(*args, **kwargs) File ".../engines/ep/management/cli_auth_utils.py", line 106, in g f(*args, **kwargs) File ".../engines/ep/management/cbstats", line 541, in stats_key print(e.message) AttributeError: 'ErrorKeyEnoent' object has no attribute 'message' Change-Id: Iae887189b485e1c62dd5f5ceba599e0660502067 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/151234 Reviewed-by: Daniel Owen Tested-by: James Harrison Tested-by: Build Bot --- engines/ep/management/cbstats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/ep/management/cbstats b/engines/ep/management/cbstats index daf78eed78..8ebff75426 100755 --- a/engines/ep/management/cbstats +++ b/engines/ep/management/cbstats @@ -538,7 +538,7 @@ def stats_key(mc, key, vb, *args): print(cmd) vbs = mc.stats(cmd) except mc_bin_client.MemcachedError as e: - print(e.message) + print(e) sys.exit(1) except ValueError as e: print("Failed to parse collection: %s" % str(e)) @@ -563,7 +563,7 @@ def stats_vkey(mc, key, vb, *args): cmd = "%s %s %s %s" % (requestStatKey, key, str(vb), collection) vbs = mc.stats(cmd) except mc_bin_client.MemcachedError as e: - print(e.message) + print(e) sys.exit(1) except ValueError as e: print("Failed to parse collection: %s" % str(e))