The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/234
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === It's been a few times now (ref #188, #230) where we're in a tricky situation because a new attribute in LXD makes pylxd crash. It's not fun because it makes us *have* to update pylxd and LXD at the same time. This commit makes models ignore `AttributeError` during `sync()`, which should normally fix this problem once and for all. Depends on #233
From 589dc00fadc8e4dbb01071c1d264f2f6f71cb211 Mon Sep 17 00:00:00 2001 From: Virgil Dupras <[email protected]> Date: Wed, 31 May 2017 21:15:54 -0400 Subject: [PATCH 1/3] Fix broken CI testing The whole test suite was broken lately for three reasons: 1. Version in `setp.cfg` was out of sync with git tagging, making `pbr` scream. 2. `mock_services` is outdated and unmaintained and doesn't work with newer versions of `requests-mock`. 3. The newly added `description` property wasn't properly added in mocked LXD. I've fixed those two problems by updating the `setup.cfg` version, pinning `requests-mock` to the last version to work and adding a `description` field to the mocks. On my machine, all tox tests pass now. --- pylxd/tests/mock_lxd.py | 1 + setup.cfg | 2 +- test-requirements.txt | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pylxd/tests/mock_lxd.py b/pylxd/tests/mock_lxd.py index 10a3273..e5dc19a 100644 --- a/pylxd/tests/mock_lxd.py +++ b/pylxd/tests/mock_lxd.py @@ -185,6 +185,7 @@ def profile_GET(request, context): }, 'created_at': "1983-06-16T00:00:00-00:00", 'last_used_at': "1983-06-16T00:00:00-00:00", + 'description': "Some description", 'devices': { 'root': { 'path': "/", diff --git a/setup.cfg b/setup.cfg index 7abd5b2..62c72db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = pylxd summary = python library for lxd -version = 2.2.2 +version = 2.2.4 description-file = README.rst author = Paul Hummer diff --git a/test-requirements.txt b/test-requirements.txt index ae59d0c..9d3df30 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,3 +4,6 @@ mock>=1.3.0 flake8>=2.5.0 coverage>=4.1 mock-services>=0.3 +# mock-services is old and unmaintained. Doesn't work with newer versions of +# requests-mock. Thus, we have to pin it down. +requests-mock<1.2 From debf7f27fe78009cf90ad7854b3dc91fa45f49e3 Mon Sep 17 00:00:00 2001 From: Virgil Dupras <[email protected]> Date: Wed, 31 May 2017 21:32:38 -0400 Subject: [PATCH 2/3] Removing tox envs from travis cache I suspect that this is what preventing CI checks in PR #233 from passing. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 11974ad..fc7ed01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ script: - test -d .tox/$TOXENV/log && cat .tox/$TOXENV/log/*.log || true cache: directories: - - .tox/$TOXENV - $HOME/.cache/pip after_success: - codecov From 5904292b0c82ad0e16181025056aed208f654ac7 Mon Sep 17 00:00:00 2001 From: Virgil Dupras <[email protected]> Date: Thu, 1 Jun 2017 20:53:36 -0400 Subject: [PATCH 3/3] Make models resilient to new attributes in LXD It's been a few times now (ref #188, #230) where we're in a tricky situation because a new attribute in LXD makes pylxd crash. It's not fun because it makes us *have* to update pylxd and LXD at the same time. This commit makes models ignore `AttributeError` during `sync()`, which should normally fix this problem once and for all. Depends on #233 --- pylxd/models/_model.py | 9 +++++++-- pylxd/tests/mock_lxd.py | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pylxd/models/_model.py b/pylxd/models/_model.py index c24726b..8eda910 100644 --- a/pylxd/models/_model.py +++ b/pylxd/models/_model.py @@ -151,8 +151,13 @@ def sync(self, rollback=False): response = self.api.get() for key, val in response.json()['metadata'].items(): if key not in self.__dirty__ or rollback: - setattr(self, key, val) - self.__dirty__.remove(key) + try: + setattr(self, key, val) + self.__dirty__.remove(key) + except AttributeError: + # We have received an attribute from the server that we don't support + # in our model. Ignore this error, it doesn't hurt us. + pass if rollback: self.__dirty__.clear() diff --git a/pylxd/tests/mock_lxd.py b/pylxd/tests/mock_lxd.py index e5dc19a..201ae67 100644 --- a/pylxd/tests/mock_lxd.py +++ b/pylxd/tests/mock_lxd.py @@ -213,7 +213,8 @@ def profile_GET(request, context): ], 'stateful': False, 'status': "Running", - 'status_code': 103 + 'status_code': 103, + 'unsupportedbypylxd': "This attribute is not supported by pylxd. We want to test whether the mere presence of it makes it crash." }}, 'method': 'GET', 'url': r'^http://pylxd.test/1.0/containers/an-container$',
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
