From 47b7c00287f310ab38e442ba2a147e9f7faab1ee Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 21 Jul 2020 09:32:50 -0400 Subject: [PATCH] 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 --- roles/ceph-grafana/templates/grafana-server.service.j2 | 2 +- roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 | 2 +- roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 | 2 +- roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 | 2 +- roles/ceph-mds/templates/ceph-mds.service.j2 | 2 +- roles/ceph-mgr/templates/ceph-mgr.service.j2 | 2 +- roles/ceph-mon/templates/ceph-mon.service.j2 | 3 +-- roles/ceph-nfs/templates/ceph-nfs.service.j2 | 3 +-- roles/ceph-node-exporter/templates/node_exporter.service.j2 | 3 +-- roles/ceph-osd/templates/ceph-osd.service.j2 | 2 +- roles/ceph-prometheus/templates/alertmanager.service.j2 | 3 +-- roles/ceph-prometheus/templates/prometheus.service.j2 | 3 +-- roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 | 2 +- roles/ceph-rgw/templates/ceph-radosgw.service.j2 | 2 +- 14 files changed, 14 insertions(+), 19 deletions(-) diff --git a/roles/ceph-grafana/templates/grafana-server.service.j2 b/roles/ceph-grafana/templates/grafana-server.service.j2 index 7019e4099..780cb9174 100644 --- a/roles/ceph-grafana/templates/grafana-server.service.j2 +++ b/roles/ceph-grafana/templates/grafana-server.service.j2 @@ -15,8 +15,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop grafana-server -ExecStartPre=-/usr/bin/{{ container_binary }} rm grafana-server {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm grafana-server ExecStart=/usr/bin/{{ container_binary }} run --rm --name=grafana-server \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 b/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 index 7d08ff6e7..e340c11a5 100644 --- a/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 +++ b/roles/ceph-iscsi-gw/templates/rbd-target-api.service.j2 @@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-api -ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-api {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-api ExecStart=/usr/bin/{{ container_binary }} run --rm \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 b/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 index 20afb3ffb..93294dc1f 100644 --- a/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 +++ b/roles/ceph-iscsi-gw/templates/rbd-target-gw.service.j2 @@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop rbd-target-gw -ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-gw {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm rbd-target-gw ExecStart=/usr/bin/{{ container_binary }} run --rm \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 b/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 index 505ee3cf6..0b1579b27 100644 --- a/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 +++ b/roles/ceph-iscsi-gw/templates/tcmu-runner.service.j2 @@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop tcmu-runner -ExecStartPre=-/usr/bin/{{ container_binary }} rm tcmu-runner {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm tcmu-runner ExecStart=/usr/bin/{{ container_binary }} run --rm \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-mds/templates/ceph-mds.service.j2 b/roles/ceph-mds/templates/ceph-mds.service.j2 index 561c516b3..5aba9f419 100644 --- a/roles/ceph-mds/templates/ceph-mds.service.j2 +++ b/roles/ceph-mds/templates/ceph-mds.service.j2 @@ -14,8 +14,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mds-{{ ansible_hostname }} -ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mds-{{ ansible_hostname }} {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mds-{{ ansible_hostname }} ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-mgr/templates/ceph-mgr.service.j2 b/roles/ceph-mgr/templates/ceph-mgr.service.j2 index 30b410909..c9c2d8e9b 100644 --- a/roles/ceph-mgr/templates/ceph-mgr.service.j2 +++ b/roles/ceph-mgr/templates/ceph-mgr.service.j2 @@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-mgr-{{ ansible_hostname }} -ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mgr-{{ ansible_hostname }} {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mgr-{{ ansible_hostname }} ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-mon/templates/ceph-mon.service.j2 b/roles/ceph-mon/templates/ceph-mon.service.j2 index 8944d4f5d..169cca71a 100644 --- a/roles/ceph-mon/templates/ceph-mon.service.j2 +++ b/roles/ceph-mon/templates/ceph-mon.service.j2 @@ -11,9 +11,8 @@ After=network.target EnvironmentFile=-/etc/environment {% if container_binary == 'podman' %} ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid -{% else %} -ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-mon-%i 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 \ {% if container_binary == 'podman' %} diff --git a/roles/ceph-nfs/templates/ceph-nfs.service.j2 b/roles/ceph-nfs/templates/ceph-nfs.service.j2 index 6cc4c7cd6..603ae12b3 100644 --- a/roles/ceph-nfs/templates/ceph-nfs.service.j2 +++ b/roles/ceph-nfs/templates/ceph-nfs.service.j2 @@ -12,9 +12,8 @@ After=network.target EnvironmentFile=-/etc/environment {% if container_binary == 'podman' %} ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid -{% else %} -ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-nfs-%i {% 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 ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ {% if container_binary == 'podman' %} diff --git a/roles/ceph-node-exporter/templates/node_exporter.service.j2 b/roles/ceph-node-exporter/templates/node_exporter.service.j2 index 8d35d32db..38928b700 100644 --- a/roles/ceph-node-exporter/templates/node_exporter.service.j2 +++ b/roles/ceph-node-exporter/templates/node_exporter.service.j2 @@ -13,9 +13,8 @@ After=network.target EnvironmentFile=-/etc/environment {% if container_binary == 'podman' %} ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid -{% else %} -ExecStartPre=-/usr/bin/{{ container_binary }} rm -f node-exporter {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm -f node-exporter ExecStart=/usr/bin/{{ container_binary }} run --rm --name=node-exporter \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-osd/templates/ceph-osd.service.j2 b/roles/ceph-osd/templates/ceph-osd.service.j2 index 721efcbac..fad7b3104 100644 --- a/roles/ceph-osd/templates/ceph-osd.service.j2 +++ b/roles/ceph-osd/templates/ceph-osd.service.j2 @@ -15,8 +15,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-osd-%i -ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm -f ceph-osd-%i ExecStart={% if ceph_osd_numactl_opts != "" %} numactl \ {{ ceph_osd_numactl_opts }} \ diff --git a/roles/ceph-prometheus/templates/alertmanager.service.j2 b/roles/ceph-prometheus/templates/alertmanager.service.j2 index aa0460f9d..c6e6df27c 100644 --- a/roles/ceph-prometheus/templates/alertmanager.service.j2 +++ b/roles/ceph-prometheus/templates/alertmanager.service.j2 @@ -14,9 +14,8 @@ WorkingDirectory={{ alertmanager_data_dir }} EnvironmentFile=-/etc/environment {% if container_binary == 'podman' %} ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid -{% else %} -ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager ExecStart=/usr/bin/{{ container_binary }} run --rm --name=alertmanager \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-prometheus/templates/prometheus.service.j2 b/roles/ceph-prometheus/templates/prometheus.service.j2 index f9aecc8fd..9f9d70710 100644 --- a/roles/ceph-prometheus/templates/prometheus.service.j2 +++ b/roles/ceph-prometheus/templates/prometheus.service.j2 @@ -13,9 +13,8 @@ After=network.target EnvironmentFile=-/etc/environment {% if container_binary == 'podman' %} ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid -{% else %} -ExecStartPre=-/usr/bin/{{ container_binary }} rm -f prometheus {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm -f prometheus ExecStart=/usr/bin/{{ container_binary }} run --rm --name=prometheus \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 b/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 index b48a5feb2..8e0fb8838 100644 --- a/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 +++ b/roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2 @@ -13,8 +13,8 @@ EnvironmentFile=-/etc/environment ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} ExecStartPre=-/usr/bin/{{ container_binary }} stop ceph-rbd-mirror-{{ ansible_hostname }} -ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rbd-mirror-{{ ansible_hostname }} {% endif %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rbd-mirror-{{ ansible_hostname }} ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \ diff --git a/roles/ceph-rgw/templates/ceph-radosgw.service.j2 b/roles/ceph-rgw/templates/ceph-radosgw.service.j2 index 6e1b7b643..6dd4abe27 100644 --- a/roles/ceph-rgw/templates/ceph-radosgw.service.j2 +++ b/roles/ceph-rgw/templates/ceph-radosgw.service.j2 @@ -14,8 +14,8 @@ EnvironmentFile=/var/lib/ceph/radosgw/{{ cluster }}-%i/EnvironmentFile ExecStartPre=-/usr/bin/rm -f /%t/%n-pid /%t/%n-cid {% else %} 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 %} +ExecStartPre=-/usr/bin/{{ container_binary }} rm ceph-rgw-{{ ansible_hostname }}-${INST_NAME} ExecStart=/usr/bin/{{ container_binary }} run --rm --net=host \ {% if container_binary == 'podman' %} -d --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid \