mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Merge pull request #164 from dlorenc/pullfix
Fix log_check_call in docker_daemon.
This commit is contained in:
commit
d4eb31517e
1 changed files with 14 additions and 6 deletions
|
@ -80,6 +80,7 @@ class PullDockerImages(Task):
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from bootstrapvz.common.exceptions import TaskError
|
from bootstrapvz.common.exceptions import TaskError
|
||||||
|
from subprocess import CalledProcessError
|
||||||
images = info.manifest.plugins['docker_daemon'].get('pull_images', [])
|
images = info.manifest.plugins['docker_daemon'].get('pull_images', [])
|
||||||
retries = info.manifest.plugins['docker_daemon'].get('pull_images_retries', 10)
|
retries = info.manifest.plugins['docker_daemon'].get('pull_images_retries', 10)
|
||||||
|
|
||||||
|
@ -93,22 +94,29 @@ class PullDockerImages(Task):
|
||||||
daemon = subprocess.Popen([bin_docker, '-d', '--graph', graph_dir, '-H', socket, '-p', pidfile])
|
daemon = subprocess.Popen([bin_docker, '-d', '--graph', graph_dir, '-H', socket, '-p', pidfile])
|
||||||
# wait for docker daemon to start.
|
# wait for docker daemon to start.
|
||||||
for _ in range(retries):
|
for _ in range(retries):
|
||||||
if log_check_call([bin_docker, '-H', socket, 'version']) == 0:
|
try:
|
||||||
|
log_check_call([bin_docker, '-H', socket, 'version'])
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
except CalledProcessError:
|
||||||
|
time.sleep(1)
|
||||||
for img in images:
|
for img in images:
|
||||||
# docker load if tarball.
|
# docker load if tarball.
|
||||||
if img.endswith('.tar.gz') or img.endswith('.tgz'):
|
if img.endswith('.tar.gz') or img.endswith('.tgz'):
|
||||||
cmd = [bin_docker, '-H', socket, 'load', '-i', img]
|
cmd = [bin_docker, '-H', socket, 'load', '-i', img]
|
||||||
if log_check_call(cmd) != 0:
|
try:
|
||||||
msg = 'error loading docker image {img}.'.format(img=img)
|
log_check_call(cmd)
|
||||||
|
except CalledProcessError as e:
|
||||||
|
msg = 'error {e} loading docker image {img}.'.format(img=img, e=e)
|
||||||
raise TaskError(msg)
|
raise TaskError(msg)
|
||||||
# docker pull if image name.
|
# docker pull if image name.
|
||||||
else:
|
else:
|
||||||
cmd = [bin_docker, '-H', socket, 'pull', img]
|
cmd = [bin_docker, '-H', socket, 'pull', img]
|
||||||
if log_check_call(cmd) != 0:
|
try:
|
||||||
msg = 'error pulling docker image {img}.'.format(img=img)
|
log_check_call(cmd)
|
||||||
|
except CalledProcessError as e:
|
||||||
|
msg = 'error {e} pulling docker image {img}.'.format(img=img, e=e)
|
||||||
raise TaskError(msg)
|
raise TaskError(msg)
|
||||||
finally:
|
finally:
|
||||||
# shutdown docker daemon.
|
# shutdown docker daemon.
|
||||||
daemon.terminate()
|
daemon.terminate()
|
||||||
|
os.remove(os.path.join(info.workspace, 'docker.sock'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue