summaryrefslogtreecommitdiffstats
path: root/openstack/common/rpc
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2012-06-21 12:20:33 -0700
committerDan Smith <danms@us.ibm.com>2012-06-21 15:35:12 -0700
commit510fc472728f5746d4ef8346a874699235f58fa3 (patch)
tree4aeba051e0a7b74dfd1a5059bd03abbc89ca3233 /openstack/common/rpc
parent9cc979fee72e8b64ddca5cf5f4889541001e7c1b (diff)
downloadoslo-510fc472728f5746d4ef8346a874699235f58fa3.tar.gz
oslo-510fc472728f5746d4ef8346a874699235f58fa3.tar.xz
oslo-510fc472728f5746d4ef8346a874699235f58fa3.zip
Avoid erroneous "Unsupported RPC Version" message if method is missing
The recent RPC versioning support introduced some odd behavior if a non- existent method is called. Instead of reporting that the method does not exist (as the code used to do, in the form of an AttributeError), it now Reports "Unsupported RPC Version". This is highly confusing, as the RPC versions *do* match and is just a result of the logic used to check every advertised RPC proxy for the method. This patch notes if any of the RPC versions matched the requested one, and if so, raises an AttributeError if the method is never found, instead of UnsupportedRpcVersion. Also add unit tests for the cases where a method is missing, both when the API version matches and not. Change-Id: Icb7b13fa890000f1bd03382d5cce747e3311ef6a
Diffstat (limited to 'openstack/common/rpc')
-rw-r--r--openstack/common/rpc/dispatcher.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/openstack/common/rpc/dispatcher.py b/openstack/common/rpc/dispatcher.py
index 7319eb2..4aabce2 100644
--- a/openstack/common/rpc/dispatcher.py
+++ b/openstack/common/rpc/dispatcher.py
@@ -92,14 +92,20 @@ class RpcDispatcher(object):
if not version:
version = '1.0'
+ had_compatible = False
for proxyobj in self.callbacks:
if hasattr(proxyobj, 'RPC_API_VERSION'):
rpc_api_version = proxyobj.RPC_API_VERSION
else:
rpc_api_version = '1.0'
+ is_compatible = self._is_compatible(rpc_api_version, version)
+ had_compatible = had_compatible or is_compatible
if not hasattr(proxyobj, method):
continue
- if self._is_compatible(rpc_api_version, version):
+ if is_compatible:
return getattr(proxyobj, method)(ctxt, **kwargs)
- raise rpc_common.UnsupportedRpcVersion(version=version)
+ if had_compatible:
+ raise AttributeError("No such RPC function '%s'" % method)
+ else:
+ raise rpc_common.UnsupportedRpcVersion(version=version)