podman: always remove container on start

In case of failure, the systemd ExecStop isn't executed so the container
isn't removed. After a reboot of a failed node, the container doesn't
start because the old container is still present in created state.
We should always try to remove the container in ExecStartPre for this
situation.
A normal reboot doesn't trigger this issue and this also doesn't affect
nodes running containers via docker.
This behaviour was introduced by d43769d.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1858865

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit 47b7c00287)
pull/5592/head
Dimitri Savineau 2020-07-21 09:32:50 -04:00 committed by Dimitri Savineau
parent 02e7468b4a
commit d408c75d76
14 changed files with 14 additions and 19 deletions

View File

@ -15,8 +15,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop grafana-server ExecStartPre=-/usr/bin/{{ container_binary }} stop grafana-server
ExecStartPre=-/usr/bin/{{ container_binary }} rm grafana-server
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm grafana-server
ExecStart=/usr/bin/{{ container_binary }} run --rm --name=grafana-server \ ExecStart=/usr/bin/{{ container_binary }} run --rm --name=grafana-server \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-api ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-api
ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-api
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-api
ExecStart=/usr/bin/{{ container_binary }} run --rm \ ExecStart=/usr/bin/{{ container_binary }} run --rm \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-gw ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-gw
ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-gw
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-gw
ExecStart=/usr/bin/{{ container_binary }} run --rm \ ExecStart=/usr/bin/{{ container_binary }} run --rm \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop tcmu-runner ExecStartPre=-/usr/bin/{{ container_binary }} stop tcmu-runner
ExecStartPre=-/usr/bin/{{ container_binary }} rm tcmu-runner
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm tcmu-runner
ExecStart=/usr/bin/{{ container_binary }} run --rm \ ExecStart=/usr/bin/{{ container_binary }} run --rm \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -14,8 +14,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mds-{{ ansible_hostname }}
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mds-{{ ansible_hostname }}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mgr-{{ ansible_hostname }}
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mgr-{{ ansible_hostname }}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -11,9 +11,8 @@ After=network.target
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i
ExecStartPre=/bin/sh -c '"$(command -v mkdir)" -p /etc/ceph /var/lib/ceph/mon' ExecStartPre=/bin/sh -c '"$(command -v mkdir)" -p /etc/ceph /var/lib/ceph/mon'
ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-mon-%i \ ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-mon-%i \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}

View File

@ -12,9 +12,8 @@ After=network.target
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-nfs-%i
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-nfs-%i
ExecStartPre={{ '/bin/mkdir' if ansible_os_family == 'Debian' else '/usr/bin/mkdir' }} -p /etc/ceph /etc/ganesha /var/lib/nfs/ganesha /var/log/ganesha ExecStartPre={{ '/bin/mkdir' if ansible_os_family == 'Debian' else '/usr/bin/mkdir' }} -p /etc/ceph /etc/ganesha /var/lib/nfs/ganesha /var/log/ganesha
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}

View File

@ -13,9 +13,8 @@ After=network.target
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f node-exporter
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f node-exporter
ExecStart=/usr/bin/{{ container_binary }} run --rm --name=node-exporter \ ExecStart=/usr/bin/{{ container_binary }} run --rm --name=node-exporter \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -15,8 +15,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i
ExecStart={% if ceph_osd_numactl_opts != "" %} ExecStart={% if ceph_osd_numactl_opts != "" %}
numactl \ numactl \
{{ ceph_osd_numactl_opts }} \ {{ ceph_osd_numactl_opts }} \

View File

@ -14,9 +14,8 @@ WorkingDirectory={{ alertmanager_data_dir }}
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager
ExecStart=/usr/bin/{{ container_binary }} run --rm --name=alertmanager \ ExecStart=/usr/bin/{{ container_binary }} run --rm --name=alertmanager \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -13,9 +13,8 @@ After=network.target
EnvironmentFile=-/etc/environment EnvironmentFile=-/etc/environment
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f prometheus
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f prometheus
ExecStart=/usr/bin/{{ container_binary }} run --rm --name=prometheus \ ExecStart=/usr/bin/{{ container_binary }} run --rm --name=prometheus \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rbd-mirror-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rbd-mirror-{{ ansible_hostname }}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rbd-mirror-{{ ansible_hostname }}
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rbd-mirror-{{ ansible_hostname }}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \

View File

@ -14,8 +14,8 @@ EnvironmentFile=/var/lib/ceph/radosgw/{{ cluster }}-%i/EnvironmentFile
ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rgw-{{ ansible_hostname }}-${INST_NAME} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rgw-{{ ansible_hostname }}-${INST_NAME}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rgw-{{ ansible_hostname }}-${INST_NAME}
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rgw-{{ ansible_hostname }}-${INST_NAME}
ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \
{% if container_binary == 'podman' %} {% if container_binary == 'podman' %}
-d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \