mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
Use docker pull
by default in ansible-test.
This commit is contained in:
parent
80c559bdef
commit
9b5c782a0b
3 changed files with 45 additions and 1 deletions
|
@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function
|
|||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
import lib.pytar
|
||||
import lib.thread
|
||||
|
@ -12,6 +13,7 @@ from lib.executor import (
|
|||
SUPPORTED_PYTHON_VERSIONS,
|
||||
EnvironmentConfig,
|
||||
IntegrationConfig,
|
||||
SubprocessError,
|
||||
ShellConfig,
|
||||
TestConfig,
|
||||
create_shell_command,
|
||||
|
@ -28,6 +30,7 @@ from lib.manage_ci import (
|
|||
from lib.util import (
|
||||
ApplicationError,
|
||||
run_command,
|
||||
display,
|
||||
)
|
||||
|
||||
BUFFER_SIZE = 256 * 256
|
||||
|
@ -99,6 +102,11 @@ def delegate_docker(args, exclude, require):
|
|||
test_image = args.docker
|
||||
privileged = args.docker_privileged
|
||||
|
||||
if util_image:
|
||||
docker_pull(args, util_image)
|
||||
|
||||
docker_pull(args, test_image)
|
||||
|
||||
util_id = None
|
||||
test_id = None
|
||||
|
||||
|
@ -195,6 +203,26 @@ def delegate_docker(args, exclude, require):
|
|||
capture=True)
|
||||
|
||||
|
||||
def docker_pull(args, image):
|
||||
"""
|
||||
:type args: EnvironmentConfig
|
||||
:type image: str
|
||||
"""
|
||||
if not args.docker_pull:
|
||||
display.warning('Skipping docker pull for "%s". Image may be out-of-date.' % image)
|
||||
return
|
||||
|
||||
for _ in range(1, 10):
|
||||
try:
|
||||
run_command(args, ['docker', 'pull', image])
|
||||
return
|
||||
except SubprocessError:
|
||||
display.warning('Failed to pull docker image "%s". Waiting a few seconds before trying again.' % image)
|
||||
time.sleep(3)
|
||||
|
||||
raise ApplicationError('Failed to pull docker image "%s".' % image)
|
||||
|
||||
|
||||
def docker_put(args, container_id, src, dst):
|
||||
"""
|
||||
:type args: EnvironmentConfig
|
||||
|
|
|
@ -1103,6 +1103,7 @@ class EnvironmentConfig(CommonConfig):
|
|||
|
||||
self.docker_privileged = args.docker_privileged if 'docker_privileged' in args else False # type: bool
|
||||
self.docker_util = docker_qualify_image(args.docker_util if 'docker_util' in args else None) # type: str | None
|
||||
self.docker_pull = args.docker_pull if 'docker_pull' in args else False # type: bool
|
||||
|
||||
self.tox_sitepackages = args.tox_sitepackages # type: bool
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue