From 0d549081d3fd1e6f22e1ae82a686339a3c4ae775 Mon Sep 17 00:00:00 2001 From: Caleb Lemoine <21261388+circa10a@users.noreply.github.com> Date: Fri, 22 Feb 2019 20:22:25 -0600 Subject: [PATCH] Catch self update apierror (#238) * catch api error if self-update cant continue * test fix lint --- pyouroboros/dockerclient.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pyouroboros/dockerclient.py b/pyouroboros/dockerclient.py index 474b525c..80731f91 100644 --- a/pyouroboros/dockerclient.py +++ b/pyouroboros/dockerclient.py @@ -359,12 +359,17 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No self.logger.debug('I need to update! Starting the ouroboros ;)') self_name = 'ouroboros-updated' if old_container.name == 'ouroboros' else 'ouroboros' new_config = set_properties(old=old_container, new=new_image, self_name=self_name) - me_created = self.client.api.create_container(**new_config) - new_me = self.client.containers.get(me_created.get("Id")) - new_me.start() - self.logger.debug('If you strike me down, I shall become more powerful than you could possibly imagine') - self.logger.debug('https://bit.ly/2VVY7GH') - sleep(30) + try: + me_created = self.client.api.create_container(**new_config) + new_me = self.client.containers.get(me_created.get("Id")) + new_me.start() + self.logger.debug('If you strike me down, I shall become \ + more powerful than you could possibly imagine.') + self.logger.debug('https://bit.ly/2VVY7GH') + sleep(30) + except APIError as e: + self.logger.error("Self update failed.") + self.logger.error(e) class Service(BaseImageObject):