From 3af56437fc995d4e3640aab40c60de1e6509f64b Mon Sep 17 00:00:00 2001 From: dirtycajunrice Date: Mon, 25 Feb 2019 12:18:10 -0600 Subject: [PATCH 1/4] fixes #230 --- pyouroboros/dockerclient.py | 18 ++++++++++++------ pyouroboros/ouroboros.py | 31 +++++++++++++++++-------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/pyouroboros/dockerclient.py b/pyouroboros/dockerclient.py index 9385f84e..57a62777 100644 --- a/pyouroboros/dockerclient.py +++ b/pyouroboros/dockerclient.py @@ -102,6 +102,8 @@ def _pull(self, tag): class Container(BaseImageObject): + mode = 'container' + def __init__(self, docker_client): super().__init__(docker_client) self.monitored = self.monitor_filter() @@ -226,6 +228,12 @@ def monitor_filter(self): return monitored_containers # Socket Functions + def self_check(self): + self.monitored = self.monitor_filter() + me_list = [c for c in self.monitored if 'ouroboros' in c['Names'][0].strip('/')] + if len(me_list) > 1: + self.update_self(count=2, me_list=me_list) + def socket_check(self): depends_on_names = [] hard_depends_on_names = [] @@ -236,10 +244,6 @@ def socket_check(self): self.logger.info('No containers are running or monitored on %s', self.socket) return - me_list = [c for c in self.client.api.containers() if 'ouroboros' in c['Names'][0].strip('/')] - if len(me_list) > 1: - self.update_self(count=2, me_list=me_list) - for container in self.monitored: current_image = container.image current_tag = container.attrs['Config']['Image'] @@ -362,8 +366,8 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No 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('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: @@ -372,6 +376,8 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No class Service(BaseImageObject): + mode = 'service' + def __init__(self, docker_client): super().__init__(docker_client) self.monitored = self.monitor_filter() diff --git a/pyouroboros/ouroboros.py b/pyouroboros/ouroboros.py index 214e239c..3b64ae2f 100644 --- a/pyouroboros/ouroboros.py +++ b/pyouroboros/ouroboros.py @@ -155,21 +155,24 @@ def main(): mode = Service(docker) else: mode = Container(docker) - if config.cron: - scheduler.add_job( - mode.update, - name=f'Cron container update for {socket}', - trigger='cron', - minute=config.cron[0], - hour=config.cron[1], - day=config.cron[2], - month=config.cron[3], - day_of_week=config.cron[4], - misfire_grace_time=15 - ) + + if config.run_once: + scheduler.add_job(mode.update, name=f'Run Once container update for {socket}') else: - if config.run_once: - scheduler.add_job(mode.update, name=f'Run Once container update for {socket}') + if mode.mode == 'container': + scheduler.add_job(mode.self_check, name=f'Self Check for {socket}') + if config.cron: + scheduler.add_job( + mode.update, + name=f'Cron container update for {socket}', + trigger='cron', + minute=config.cron[0], + hour=config.cron[1], + day=config.cron[2], + month=config.cron[3], + day_of_week=config.cron[4], + misfire_grace_time=15 + ) else: scheduler.add_job( mode.update, From 8fbc5efe24e19a48953e75f73b39ca1eb1c1b954 Mon Sep 17 00:00:00 2001 From: dirtycajunrice Date: Mon, 25 Feb 2019 15:43:29 -0600 Subject: [PATCH 2/4] revert bad decision to try to call login() --- pyouroboros/dockerclient.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pyouroboros/dockerclient.py b/pyouroboros/dockerclient.py index 57a62777..302a0602 100644 --- a/pyouroboros/dockerclient.py +++ b/pyouroboros/dockerclient.py @@ -70,16 +70,16 @@ def _pull(self, tag): """Docker pull image tag""" self.logger.debug('Checking tag: %s', tag) try: - if self.config.auth_json: - self.client.login(self.config.auth_json.get( - "username"), self.config.auth_json.get("password")) - if self.config.dry_run: # The authentication doesn't work with this call # See bugs https://github.com/docker/docker-py/issues/2225 return self.client.images.get_registry_data(tag) else: - return self.client.images.pull(tag) + if self.config.auth_json: + return_image = self.client.images.pull(tag, auth_config=self.config.auth_json) + else: + return_image = self.client.images.pull(tag) + return return_image except APIError as e: if '' in str(e): self.logger.debug("Docker api issue. Ignoring") From 7237a155bc24b1ba156982dde408289b8937878f Mon Sep 17 00:00:00 2001 From: dirtycajunrice Date: Wed, 27 Feb 2019 21:44:58 -0600 Subject: [PATCH 3/4] fix name subscript for #243 --- pyouroboros/dockerclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyouroboros/dockerclient.py b/pyouroboros/dockerclient.py index 302a0602..3304ddc7 100644 --- a/pyouroboros/dockerclient.py +++ b/pyouroboros/dockerclient.py @@ -230,7 +230,7 @@ def monitor_filter(self): # Socket Functions def self_check(self): self.monitored = self.monitor_filter() - me_list = [c for c in self.monitored if 'ouroboros' in c['Names'][0].strip('/')] + me_list = [container for container in self.monitored if 'ouroboros' in container.name] if len(me_list) > 1: self.update_self(count=2, me_list=me_list) From 99a5927ce37faa6a095587beb3f5bcd97a3f3b9e Mon Sep 17 00:00:00 2001 From: dirtycajunrice Date: Wed, 27 Feb 2019 21:54:52 -0600 Subject: [PATCH 4/4] Changelog + 1.3.1 --- CHANGELOG.md | 23 ++++++++++++++++++----- pyouroboros/__init__.py | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0920f6dd..6e0c654b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## [1.3.1](https://github.com/pyouroboros/ouroboros/tree/1.3.1) (2019-02-27) +[Full Changelog](https://github.com/pyouroboros/ouroboros/compare/1.3.0...1.3.1) + +**Fixed bugs:** + +- Since 1.3.0, docker login fails [\#243](https://github.com/pyouroboros/ouroboros/issues/243) + +**Closed issues:** + +- Issue when updating containers that use "--net=container" [\#245](https://github.com/pyouroboros/ouroboros/issues/245) + +**Other Pull Requests** + +- v1.3.1 Merge [\#249](https://github.com/pyouroboros/ouroboros/pull/249) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) +- v1.3.1 to develop [\#248](https://github.com/pyouroboros/ouroboros/pull/248) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) +- fix name subscript for \#243 [\#247](https://github.com/pyouroboros/ouroboros/pull/247) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) +- fixes \#230 and \#243 [\#242](https://github.com/pyouroboros/ouroboros/pull/242) ([DirtyCajunRice](https://github.com/DirtyCajunRice)) + ## [1.3.0](https://github.com/pyouroboros/ouroboros/tree/1.3.0) (2019-02-25) [Full Changelog](https://github.com/pyouroboros/ouroboros/compare/1.2.1...1.3.0) @@ -10,7 +28,6 @@ **Fixed bugs:** -- Catch Failed self-updates [\#230](https://github.com/pyouroboros/ouroboros/issues/230) - Cron scheduled missed following successful runs [\#229](https://github.com/pyouroboros/ouroboros/issues/229) - Catch attribute.id error [\#226](https://github.com/pyouroboros/ouroboros/issues/226) - AttachStdout and AttachStderr are not carried over properly [\#221](https://github.com/pyouroboros/ouroboros/issues/221) @@ -418,10 +435,6 @@ - the less code the better [\#8](https://github.com/pyouroboros/ouroboros/pull/8) ([circa10a](https://github.com/circa10a)) - Initial stuff [\#6](https://github.com/pyouroboros/ouroboros/pull/6) ([circa10a](https://github.com/circa10a)) -**Closed issues:** - -- Create good docs [\#7](https://github.com/pyouroboros/ouroboros/issues/7) [[documentation](https://github.com/pyouroboros/ouroboros/labels/documentation)] - **Other Pull Requests** - Docs [\#21](https://github.com/pyouroboros/ouroboros/pull/21) [[documentation](https://github.com/pyouroboros/ouroboros/labels/documentation)] ([circa10a](https://github.com/circa10a)) diff --git a/pyouroboros/__init__.py b/pyouroboros/__init__.py index 6a92b727..591e5da8 100644 --- a/pyouroboros/__init__.py +++ b/pyouroboros/__init__.py @@ -1,2 +1,2 @@ -VERSION = "1.3.0" +VERSION = "1.3.1" BRANCH = "master"