Fix inspect images calls to not use the index format keyword
Via https://review.opendev.org/#/c/752937/ we added the following code: if container_image: image_id_str = self.runner.inspect( container_image, "{{index .Id}}", o_type='image') if str(image_id_str).strip() != inspect_info.get('Image'): self.log.debug("Deleting container (image updated): " "%s" % container) self.runner.remove_container(container) return True This code works fine in docker: [root@controller-0 ~]# docker inspect --type image --format '{{index .Id}}' f6ec0f326154 sha256:f6ec0f326154a80b6844a03c2de2904bbbefea6cdf87acb606ff869ace1a8dd4 But is problematic in podman (both on 1.6.4 and 2.1.1 versions): [root@controller-0 ~]# podman inspect --type image --format '{{index .Id}}' undercloud-0.ctlplane.redhat.local:8787/rh-osbs/rhosp16-openstack-cinder-volume:16.2_20201110.2-hotfixupdate2 ERRO[0000] Error printing inspect output: Template parsing error: template: image:1:8: executing "image" at <.Id>: can't evaluate field Id in type *entities.ImageInspectReport This has the side-effect of restarting all containers at each identical redeploy. We can just drop the 'index' in the query since it works in both docker and podman: [root@controller-0 ~]# docker inspect --type image --format '{{.Id}}' f6ec0f326154 sha256:f6ec0f326154a80b6844a03c2de2904bbbefea6cdf87acb606ff869ace1a8dd4 [root@controller-0 ~]# podman inspect --type image --format '{{.Id}}' 5093412f3a08 Change-Id: I8b1fbbb7499a69e7a131fd8650c6f50fb4ab978e Closes-Bug: #1904043
This commit is contained in:
parent
e6efb9d61d
commit
7e49691145
|
@ -248,7 +248,7 @@ class BaseBuilder(object):
|
|||
|
||||
if container_image:
|
||||
image_id_str = self.runner.inspect(
|
||||
container_image, "{{index .Id}}", o_type='image')
|
||||
container_image, "{{.Id}}", o_type='image')
|
||||
if str(image_id_str).strip() != inspect_info.get('Image'):
|
||||
self.log.debug("Deleting container (image updated): "
|
||||
"%s" % container)
|
||||
|
|
|
@ -652,7 +652,7 @@ three-12345678 three''', '', 0),
|
|||
calls = [
|
||||
mock.call('one'),
|
||||
mock.call('127.0.0.1:8787/centos:7',
|
||||
'{{index .Id}}',
|
||||
'{{.Id}}',
|
||||
o_type='image')
|
||||
]
|
||||
mock_inspect.has_calls(calls)
|
||||
|
@ -795,7 +795,7 @@ three-12345678 three''', '', 0),
|
|||
calls = [
|
||||
mock.call('one'),
|
||||
mock.call('127.0.0.1:8787/centos:7',
|
||||
'{{index .Id}}',
|
||||
'{{.Id}}',
|
||||
o_type='image')
|
||||
]
|
||||
mock_inspect.has_calls(calls)
|
||||
|
|
Loading…
Reference in New Issue