Skip to content

Commit

Permalink
MB-45684: Fix cbstats stats_key and stats_vkey error messages
Browse files Browse the repository at this point in the history
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 <module>
    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 <[email protected]>
Tested-by: James Harrison <[email protected]>
Tested-by: Build Bot <[email protected]>
  • Loading branch information
jameseh96 authored and owend74 committed Apr 15, 2021
1 parent 8723f19 commit 4f7ba95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions engines/ep/management/cbstats
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit 4f7ba95

Please sign in to comment.