Skip to content

Commit

Permalink
Merge pull request #249 from pyouroboros/develop
Browse files Browse the repository at this point in the history
v1.3.1 Merge
  • Loading branch information
dirtycajunrice authored Feb 28, 2019
2 parents c10a48b + 1aca5bc commit ed3c236
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 31 deletions.
23 changes: 18 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion pyouroboros/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = "1.3.0"
VERSION = "1.3.1"
BRANCH = "master"
28 changes: 17 additions & 11 deletions pyouroboros/dockerclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<html>' in str(e):
self.logger.debug("Docker api issue. Ignoring")
Expand All @@ -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()
Expand Down Expand Up @@ -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 = []
Expand All @@ -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']
Expand Down Expand Up @@ -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:
Expand All @@ -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()
Expand Down
31 changes: 17 additions & 14 deletions pyouroboros/ouroboros.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ed3c236

Please sign in to comment.