container: force rm --storage on ExecStartPre

This is a workaround to avoid error like following:
```
Error: error creating container storage: the container name "ceph-mgr-magna022" is already in use by "4a5f674e113f837a0cc561dea5d2cd55d16ca159a647b7794ab06c4c276ef701"
```

that doesn't seem to be 100% reproducible but it shows up after a
reboot. The only workaround we came up with at the moment is to run
`podman rm --storage <container>` before starting it.

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

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/6040/head
Guillaume Abrioux 2020-11-12 11:34:41 +01:00 committed by Dimitri Savineau
parent c5f7343a2f
commit 5ba7824c55
15 changed files with 15 additions and 0 deletions

View File

@ -10,6 +10,7 @@ After=network.target
[Service] [Service]
{% 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-crash-%i
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-crash-%i ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-crash-%i
ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-crash-%i \ ExecStart=/usr/bin/{{ container_binary }} run --rm --name ceph-crash-%i \

View File

@ -13,6 +13,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage grafana-server
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop grafana-server ExecStartPre=-/usr/bin/{{ container_binary }} stop grafana-server
{% endif %} {% endif %}

View File

@ -11,6 +11,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage rbd-target-api
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-api ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-api
{% endif %} {% endif %}

View File

@ -11,6 +11,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage rbd-target-gw
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-gw ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-gw
{% endif %} {% endif %}

View File

@ -11,6 +11,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage tcmu-runner
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop tcmu-runner ExecStartPre=-/usr/bin/{{ container_binary }} stop tcmu-runner
{% endif %} {% endif %}

View File

@ -12,6 +12,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-mds-{{ ansible_hostname }}
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }}
{% endif %} {% endif %}

View File

@ -11,6 +11,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-mgr-{{ ansible_hostname }}
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }}
{% endif %} {% endif %}

View File

@ -11,6 +11,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-mon-%i
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i 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'

View File

@ -12,6 +12,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-nfs-%i
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-nfs-%i 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

View File

@ -13,6 +13,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage node-exporter
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f node-exporter 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 \

View File

@ -13,6 +13,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-osd-%i
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i
{% endif %} {% endif %}

View File

@ -14,6 +14,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage alertmanager
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager 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 \

View File

@ -13,6 +13,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage prometheus
{% endif %} {% endif %}
ExecStartPre=-/usr/bin/{{ container_binary }} rm -f prometheus 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 \

View File

@ -11,6 +11,7 @@ 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-rbd-mirror-{{ ansible_hostname }}
{% else %} {% else %}
ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rbd-mirror-{{ ansible_hostname }} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rbd-mirror-{{ ansible_hostname }}
{% endif %} {% endif %}

View File

@ -12,6 +12,7 @@ After=network.target
EnvironmentFile=/var/lib/ceph/radosgw/{{ cluster }}-%i/EnvironmentFile EnvironmentFile=/var/lib/ceph/radosgw/{{ cluster }}-%i/EnvironmentFile
{% 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
ExecStartPre=-/usr/bin/{{ container_binary }} rm --ignore --storage ceph-rgw-{{ ansible_hostname }}-${INST_NAME}
{% 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}
{% endif %} {% endif %}