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" diff --git a/pyouroboros/dockerclient.py b/pyouroboros/dockerclient.py index 9385f84e..3304ddc7 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") @@ -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 = [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) + 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,