Skip to content

Commit ed3c236

Browse files
Merge pull request #249 from pyouroboros/develop
v1.3.1 Merge
2 parents c10a48b + 1aca5bc commit ed3c236

File tree

4 files changed

+53
-31
lines changed

4 files changed

+53
-31
lines changed

CHANGELOG.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change Log
22

3+
## [1.3.1](https://github.com/pyouroboros/ouroboros/tree/1.3.1) (2019-02-27)
4+
[Full Changelog](https://github.com/pyouroboros/ouroboros/compare/1.3.0...1.3.1)
5+
6+
**Fixed bugs:**
7+
8+
- Since 1.3.0, docker login fails [\#243](https://github.com/pyouroboros/ouroboros/issues/243)
9+
10+
**Closed issues:**
11+
12+
- Issue when updating containers that use "--net=container" [\#245](https://github.com/pyouroboros/ouroboros/issues/245)
13+
14+
**Other Pull Requests**
15+
16+
- v1.3.1 Merge [\#249](https://github.com/pyouroboros/ouroboros/pull/249) ([DirtyCajunRice](https://github.com/DirtyCajunRice))
17+
- v1.3.1 to develop [\#248](https://github.com/pyouroboros/ouroboros/pull/248) ([DirtyCajunRice](https://github.com/DirtyCajunRice))
18+
- fix name subscript for \#243 [\#247](https://github.com/pyouroboros/ouroboros/pull/247) ([DirtyCajunRice](https://github.com/DirtyCajunRice))
19+
- fixes \#230 and \#243 [\#242](https://github.com/pyouroboros/ouroboros/pull/242) ([DirtyCajunRice](https://github.com/DirtyCajunRice))
20+
321
## [1.3.0](https://github.com/pyouroboros/ouroboros/tree/1.3.0) (2019-02-25)
422
[Full Changelog](https://github.com/pyouroboros/ouroboros/compare/1.2.1...1.3.0)
523

@@ -10,7 +28,6 @@
1028

1129
**Fixed bugs:**
1230

13-
- Catch Failed self-updates [\#230](https://github.com/pyouroboros/ouroboros/issues/230)
1431
- Cron scheduled missed following successful runs [\#229](https://github.com/pyouroboros/ouroboros/issues/229)
1532
- Catch attribute.id error [\#226](https://github.com/pyouroboros/ouroboros/issues/226)
1633
- AttachStdout and AttachStderr are not carried over properly [\#221](https://github.com/pyouroboros/ouroboros/issues/221)
@@ -418,10 +435,6 @@
418435
- the less code the better [\#8](https://github.com/pyouroboros/ouroboros/pull/8) ([circa10a](https://github.com/circa10a))
419436
- Initial stuff [\#6](https://github.com/pyouroboros/ouroboros/pull/6) ([circa10a](https://github.com/circa10a))
420437

421-
**Closed issues:**
422-
423-
- Create good docs [\#7](https://github.com/pyouroboros/ouroboros/issues/7) [[documentation](https://github.com/pyouroboros/ouroboros/labels/documentation)]
424-
425438
**Other Pull Requests**
426439

427440
- Docs [\#21](https://github.com/pyouroboros/ouroboros/pull/21) [[documentation](https://github.com/pyouroboros/ouroboros/labels/documentation)] ([circa10a](https://github.com/circa10a))

pyouroboros/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VERSION = "1.3.0"
1+
VERSION = "1.3.1"
22
BRANCH = "master"

pyouroboros/dockerclient.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ def _pull(self, tag):
7070
"""Docker pull image tag"""
7171
self.logger.debug('Checking tag: %s', tag)
7272
try:
73-
if self.config.auth_json:
74-
self.client.login(self.config.auth_json.get(
75-
"username"), self.config.auth_json.get("password"))
76-
7773
if self.config.dry_run:
7874
# The authentication doesn't work with this call
7975
# See bugs https://github.com/docker/docker-py/issues/2225
8076
return self.client.images.get_registry_data(tag)
8177
else:
82-
return self.client.images.pull(tag)
78+
if self.config.auth_json:
79+
return_image = self.client.images.pull(tag, auth_config=self.config.auth_json)
80+
else:
81+
return_image = self.client.images.pull(tag)
82+
return return_image
8383
except APIError as e:
8484
if '<html>' in str(e):
8585
self.logger.debug("Docker api issue. Ignoring")
@@ -102,6 +102,8 @@ def _pull(self, tag):
102102

103103

104104
class Container(BaseImageObject):
105+
mode = 'container'
106+
105107
def __init__(self, docker_client):
106108
super().__init__(docker_client)
107109
self.monitored = self.monitor_filter()
@@ -226,6 +228,12 @@ def monitor_filter(self):
226228
return monitored_containers
227229

228230
# Socket Functions
231+
def self_check(self):
232+
self.monitored = self.monitor_filter()
233+
me_list = [container for container in self.monitored if 'ouroboros' in container.name]
234+
if len(me_list) > 1:
235+
self.update_self(count=2, me_list=me_list)
236+
229237
def socket_check(self):
230238
depends_on_names = []
231239
hard_depends_on_names = []
@@ -236,10 +244,6 @@ def socket_check(self):
236244
self.logger.info('No containers are running or monitored on %s', self.socket)
237245
return
238246

239-
me_list = [c for c in self.client.api.containers() if 'ouroboros' in c['Names'][0].strip('/')]
240-
if len(me_list) > 1:
241-
self.update_self(count=2, me_list=me_list)
242-
243247
for container in self.monitored:
244248
current_image = container.image
245249
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
362366
me_created = self.client.api.create_container(**new_config)
363367
new_me = self.client.containers.get(me_created.get("Id"))
364368
new_me.start()
365-
self.logger.debug('If you strike me down, I shall become \
366-
more powerful than you could possibly imagine.')
369+
self.logger.debug('If you strike me down, I shall become '
370+
'more powerful than you could possibly imagine.')
367371
self.logger.debug('https://bit.ly/2VVY7GH')
368372
sleep(30)
369373
except APIError as e:
@@ -372,6 +376,8 @@ def update_self(self, count=None, old_container=None, me_list=None, new_image=No
372376

373377

374378
class Service(BaseImageObject):
379+
mode = 'service'
380+
375381
def __init__(self, docker_client):
376382
super().__init__(docker_client)
377383
self.monitored = self.monitor_filter()

pyouroboros/ouroboros.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,24 @@ def main():
155155
mode = Service(docker)
156156
else:
157157
mode = Container(docker)
158-
if config.cron:
159-
scheduler.add_job(
160-
mode.update,
161-
name=f'Cron container update for {socket}',
162-
trigger='cron',
163-
minute=config.cron[0],
164-
hour=config.cron[1],
165-
day=config.cron[2],
166-
month=config.cron[3],
167-
day_of_week=config.cron[4],
168-
misfire_grace_time=15
169-
)
158+
159+
if config.run_once:
160+
scheduler.add_job(mode.update, name=f'Run Once container update for {socket}')
170161
else:
171-
if config.run_once:
172-
scheduler.add_job(mode.update, name=f'Run Once container update for {socket}')
162+
if mode.mode == 'container':
163+
scheduler.add_job(mode.self_check, name=f'Self Check for {socket}')
164+
if config.cron:
165+
scheduler.add_job(
166+
mode.update,
167+
name=f'Cron container update for {socket}',
168+
trigger='cron',
169+
minute=config.cron[0],
170+
hour=config.cron[1],
171+
day=config.cron[2],
172+
month=config.cron[3],
173+
day_of_week=config.cron[4],
174+
misfire_grace_time=15
175+
)
173176
else:
174177
scheduler.add_job(
175178
mode.update,

0 commit comments

Comments
 (0)