From 0fb546d48cf4ad7a2a5de111863635e0fe212f54 Mon Sep 17 00:00:00 2001 From: Simon Richardson Date: Thu, 9 Jan 2020 12:48:22 +0000 Subject: [PATCH] Unknown facade The following changes how we handle future compatibility. In an effort to improve compatibility with Juju and it's clients. Previously the client would attempt to negotiate every facade that Juju would have ever released, which allows backwards compatibility but not forward. With the following changes we're essentially unrestricting forward compatibility. Allowing the client to speak to future Juju's even if the facade version isn't known. We warn the user as much as possible about the missing facade version, before ignoring it and allowing accessing to be done. In reality this means if you try and access a facade that doesn't exist in the library, but does in Juju, it won't work. --- juju/client/connection.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/juju/client/connection.py b/juju/client/connection.py index 3385242b..51942f45 100644 --- a/juju/client/connection.py +++ b/juju/client/connection.py @@ -690,8 +690,10 @@ def _build_facades(self, facades): # client can define the non-conservitive facade client pinning. if name in self.specified_facades: known = self.specified_facades[name]['versions'] - else: + elif name in client_facades: known = client_facades[name]['versions'] + else: + raise errors.JujuConnectionError("unexpected facade {}".format(name)) discovered = facade['versions'] version = max(set(known).intersection(set(discovered))) except ValueError: @@ -699,6 +701,12 @@ def _build_facades(self, facades): # there is just no way to know how to communicate with the # facades we're trying to call. log.warning("unknown common facade version for {}".format(name)) + except errors.JujuConnectionError: + # If the facade isn't with in the local facades then it's not + # possible to reason about what version should be used. In this + # case we should log the facade was found, but we couldn't + # handle it. + log.warning("unexpected facade {} found, unable to decipher version to use".format(name)) else: self.facades[name] = version