diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4b84edec45..cdb2b5e4ef 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,6 +27,11 @@ Changed Contributed by @punkrokk +* Added an enhancement where ST2api.log no longer reports the entire traceback when trying to get a datastore value + that does not exist. It now reports a simplified log for cleaner reading. Addresses and Fixes #4979. (improvement) #4981 + + Contributed by Justin Sostre (@saucetray) + Fixed ~~~~~ * Fixed a bug where `type` attribute was missing for netstat action in linux pack. Fixes #4946 diff --git a/st2common/st2common/exceptions/keyvalue.py b/st2common/st2common/exceptions/keyvalue.py index aef134c600..185a5c606e 100644 --- a/st2common/st2common/exceptions/keyvalue.py +++ b/st2common/st2common/exceptions/keyvalue.py @@ -14,9 +14,11 @@ from __future__ import absolute_import from st2common.exceptions import StackStormBaseException +from st2common.exceptions.db import StackStormDBObjectNotFoundError __all__ = [ 'CryptoKeyNotSetupException', + 'DataStoreKeyNotFoundError', 'InvalidScopeException' ] @@ -25,6 +27,10 @@ class CryptoKeyNotSetupException(StackStormBaseException): pass +class DataStoreKeyNotFoundError(StackStormDBObjectNotFoundError): + pass + + class InvalidScopeException(StackStormBaseException): pass diff --git a/st2common/st2common/persistence/keyvalue.py b/st2common/st2common/persistence/keyvalue.py index e1108e39af..65619e7129 100644 --- a/st2common/st2common/persistence/keyvalue.py +++ b/st2common/st2common/persistence/keyvalue.py @@ -19,7 +19,7 @@ from st2common.constants.triggers import KEY_VALUE_PAIR_UPDATE_TRIGGER from st2common.constants.triggers import KEY_VALUE_PAIR_VALUE_CHANGE_TRIGGER from st2common.constants.triggers import KEY_VALUE_PAIR_DELETE_TRIGGER -from st2common.exceptions.db import StackStormDBObjectNotFoundError +from st2common.exceptions.keyvalue import DataStoreKeyNotFoundError from st2common.models.api.keyvalue import KeyValuePairAPI from st2common.models.db.keyvalue import keyvaluepair_access from st2common.models.system.common import ResourceReference @@ -112,7 +112,7 @@ def get_by_scope_and_name(cls, scope, name): if not query_result: msg = 'The key "%s" does not exist in the StackStorm datastore.' - raise StackStormDBObjectNotFoundError(msg % name) + raise DataStoreKeyNotFoundError(msg % name) return query_result.first() if query_result else None diff --git a/st2common/st2common/router.py b/st2common/st2common/router.py index 83b4c12362..71afc2dc7c 100644 --- a/st2common/st2common/router.py +++ b/st2common/st2common/router.py @@ -32,6 +32,7 @@ from st2common.exceptions import rbac as rbac_exc from st2common.exceptions import auth as auth_exc +from st2common.exceptions.keyvalue import DataStoreKeyNotFoundError from st2common import log as logging from st2common.persistence.auth import User from st2common.rbac.backends import get_rbac_backend @@ -513,6 +514,10 @@ def __init__(self, **entries): try: resp = func(**kw) + except DataStoreKeyNotFoundError as e: + LOG.warning('Failed to call controller function "%s" for operation "%s": %s' % + (func.__name__, endpoint['operationId'], six.text_type(e))) + raise e except Exception as e: LOG.exception('Failed to call controller function "%s" for operation "%s": %s' % (func.__name__, endpoint['operationId'], six.text_type(e)))