podman does not support {{ index .Id }} format so containers are restarted needlessly

Bug #1904043 reported by Michele Baldessari
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
High
Unassigned

Bug Description

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to paunch (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/762563

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to paunch (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/762567

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to paunch (stable/ussuri)

Reviewed: https://review.opendev.org/762563
Committed: https://git.openstack.org/cgit/openstack/paunch/commit/?id=78e49e2862621f28a6c011ae376cad3ad74b81c5
Submitter: Zuul
Branch: stable/ussuri

commit 78e49e2862621f28a6c011ae376cad3ad74b81c5
Author: Michele Baldessari <email address hidden>
Date: Thu Nov 12 19:21:48 2020 +0100

    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

tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to paunch (stable/train)

Reviewed: https://review.opendev.org/762567
Committed: https://git.openstack.org/cgit/openstack/paunch/commit/?id=7e496911451b5d6fca9766fe1e294c7e5e5523ff
Submitter: Zuul
Branch: stable/train

commit 7e496911451b5d6fca9766fe1e294c7e5e5523ff
Author: Michele Baldessari <email address hidden>
Date: Thu Nov 12 19:21:48 2020 +0100

    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

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to paunch (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/763036

Changed in tripleo:
importance: Undecided → High
status: New → Triaged
milestone: none → wallaby-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/paunch 7.0.3

This issue was fixed in the openstack/paunch 7.0.3 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/paunch 5.4.0

This issue was fixed in the openstack/paunch 5.4.0 release.

Changed in tripleo:
milestone: wallaby-rc1 → xena-1
Changed in tripleo:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.