Force container deletion if namespace does not exist in service_kill

When a service is stopped using "service_kill" script and the
namespace where the container is running does not exist, the
container processi should be forced to stop from the root namespace.

A namespace where a process is running, can be deleted whitout
stopping the mentioned process. "ip netns identify <PID>" then
returns an empty string (root namespace).

This patch will prevent an endless loop in Neutron DHCP agent. As
reported in the related bug, when a DHCP agent is resync, the DHCP
helper (metadata proxy) is stopped. In case this process stop raises
an exception (for example if the namespace does not exist), schedules
again a resync, creating an endless loop.

Change-Id: I9bac918fcde80e6a2336bc3cf1e6972512298118
Closes-Bug: #1868607
(cherry picked from commit c516df9e51)
This commit is contained in:
Rodolfo Alonso Hernandez 2020-03-23 18:36:38 +00:00
parent 64685f0412
commit 9d5ef54e1b
1 changed files with 6 additions and 6 deletions

View File

@ -17,13 +17,13 @@ SIG=$1
PID=$2
NETNS=$(ip netns identify ${PID})
if [ "x${NETNS}" == "x" ]; then
add_date "No network namespace detected, exiting"
exit 1
fi
{% if tripleo_systemd_wrapper_container_cli == 'podman' %}
CLI="nsenter --net=/run/netns/${NETNS} --preserve-credentials -m -t 1 podman"
if [ "x${NETNS}" == "x" ]; then
CLI="podman"
SIG=9
else
CLI="nsenter --net=/run/netns/${NETNS} --preserve-credentials -m -t 1 podman"
fi
{% elif tripleo_systemd_wrapper_container_cli == 'docker' %}
{% if tripleo_systemd_wrapper_docker_additional_sockets and tripleo_systemd_wrapper_docker_additional_sockets|length > 0-%}
export DOCKER_HOST=unix://{{ tripleo_systemd_wrapper_docker_additional_sockets[0] }}