
Adapt wrapper containers for podman, which has no a socket available. Add container_cli parameter for base neutron class, default to docker. Possible values: podman/docker (default). It is used by the wrappers tooling to issue CLI commands to the host containers system. Deprecate bind_socket so it does nothing for podman CLI. Additionally, add debug triggers for the wrapper scripts messages to become captured to the wrapper containers' stdout. Do not stop and remove the existing container before launching a new one. Allow the neutron parent process to control the process life cycle. Although make the wraper containers cleaning up any exited containers after its main process terminated by the neutron parent process. Additionally, If a name is already taken by a container, give it an unique name and assume all the smooth transitioning work to be done by the parent neutron process and that clean up logic in the wrapper. Closes-Bug: #1799484 Change-Id: Ib3c41a8bee349856d21f360595e41a9eafd79323 Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
49 lines
1.4 KiB
Plaintext
49 lines
1.4 KiB
Plaintext
<%- | String $bind_socket = '',
|
|
Boolean $debug,
|
|
String $container_cli = ''
|
|
| -%>
|
|
#!/bin/bash
|
|
<%- if $debug { -%>set -x<%- } -%>
|
|
|
|
<%- if $bind_socket { -%>
|
|
export DOCKER_HOST="<%=$bind_socket%>"
|
|
<%- } -%>
|
|
ARGS="$@"
|
|
|
|
# Extract the network namespace UUID from the command line args provided by
|
|
# neutron. Typically of the form (with dnsmasq as an example):
|
|
#
|
|
# dnsmasq --no-hosts --no-resolv --except-interface=lo \
|
|
# --pid-file=/var/lib/neutron/dhcp/317716b8-919a-4a6f-8db1-78128ec3b100/pid \
|
|
# --dhcp-hostsfile=/var/lib/neutron/dhcp/317716b8-919a-4a6f-8db1-78128ec3b100/host ...
|
|
NETNS=$(ip netns identify)
|
|
NAME=neutron-keepalived-${NETNS}
|
|
<%- if $container_cli == 'docker' { -%>
|
|
CLI='docker'
|
|
CMD="ip netns exec ${NETNS} /usr/bin/neutron-keepalived-state-change"
|
|
<%- } elsif $container_cli == 'podman' { -%>
|
|
CLI="nsenter --net=/run/netns/${NETNS} --preserve-credentials -m -t 1 podman"
|
|
CMD='/usr/bin/neutron-keepalived-state-change'
|
|
<%- } else { -%>
|
|
CLI='echo noop'
|
|
CMD='echo noop'
|
|
<%- } -%>
|
|
|
|
# The state change daemon only runs as a daemon for the moment so we need to
|
|
# run it within an existing container with a sensibly matching lifetime. The
|
|
# related keepalived container seems an obvious choice.
|
|
|
|
container_id=$($CLI ps --filter name=$NAME --format "{{.ID}}")
|
|
|
|
if [[ -z $container_id ]];
|
|
then
|
|
echo "WARNING: keepalived container is not running."
|
|
exit 0
|
|
fi
|
|
|
|
$CLI exec --detach \
|
|
-u root \
|
|
--privileged \
|
|
$NAME \
|
|
$CMD $ARGS
|