Reduce the usage of "podman inspect" command

- pull_missing_images: when podman is used, do not use "inspect" but
  "podman images exists" command. We only need to know if the image
  already exists, no need to fetch all its config.

- unique_container_name: use container_exist to find out of the
  container already exists instead of calling the "inspect" command.

Related-Bug #1833081
Change-Id: I1aad33bcdcede1034bc8e1267b07f84c34a09958
This commit is contained in:
Emilien Macchi 2019-06-17 10:51:13 -04:00
parent 277eb726b9
commit 6e2ef79af3
2 changed files with 20 additions and 8 deletions

View File

@ -226,10 +226,15 @@ class BaseBuilder(object):
for image in sorted(images):
# only pull if the image does not exist locally
if self.runner.inspect(image,
output_format='exists',
o_type='image'):
continue
if self.runner.cont_cmd == 'docker':
if self.runner.inspect(image,
output_format='exists',
o_type='image'):
continue
else:
img_exist = self.runner.image_exist(image)
if img_exist == 0:
continue
try:
(cmd_stdout, cmd_stderr) = self._pull(image)

View File

@ -117,10 +117,17 @@ class BaseRunner(object):
def unique_container_name(self, container):
container_name = container
while self.inspect(container_name, output_format='exists', quiet=True):
suffix = ''.join(random.choice(
string.ascii_lowercase + string.digits) for i in range(8))
container_name = '%s-%s' % (container, suffix)
if self.cont_cmd == 'docker':
while self.inspect(container_name, output_format='exists',
quiet=True):
suffix = ''.join(random.choice(
string.ascii_lowercase + string.digits) for i in range(8))
container_name = '%s-%s' % (container, suffix)
else:
while self.container_exist(container_name, quiet=True):
suffix = ''.join(random.choice(
string.ascii_lowercase + string.digits) for i in range(8))
container_name = '%s-%s' % (container, suffix)
return container_name
def discover_container_name(self, container, cid):