Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
baremetal: keepalived/coredns pods remove before create
Browse files Browse the repository at this point in the history
If the container exists unexpectedly for any reason, then
ExecStop not called, and sometimes there are "storage for container removed"
errors trying to re-start it, presumably because podman cleanup
removes resources for exited containers.
  • Loading branch information
Steven Hardy committed Jul 18, 2019
1 parent 839d40f commit 7c7d13d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
25 changes: 14 additions & 11 deletions data/data/bootstrap/baremetal/files/usr/local/bin/coredns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ if ! podman inspect "$COREDNS_IMAGE" &>/dev/null; then
podman pull "$COREDNS_IMAGE"
fi
MATCHES="$(sudo podman ps -a --format "{{.Names}}" | awk '/coredns$/ {print $0}')"
if [[ -z "$MATCHES" ]]; then
/usr/bin/podman create \
--name coredns \
--volume /etc/coredns:/etc/coredns:z \
--network host \
--env CLUSTER_DOMAIN="$CLUSTER_DOMAIN" \
--env CLUSTER_NAME="$CLUSTER_NAME" \
--env NUM_DNS_MEMBERS="$NUM_DNS_MEMBERS" \
--env API_VIP="$API_VIP" \
"${COREDNS_IMAGE}" \
--conf /etc/coredns/Corefile
if [[ ! -z "$MATCHES" ]]; then
# Remove old pod, or you can get storage for container removed
# errors on restart if the container exits unexpectedly
podman rm -f coredns
fi
/usr/bin/podman create \
--name coredns \
--volume /etc/coredns:/etc/coredns:z \
--network host \
--env CLUSTER_DOMAIN="$CLUSTER_DOMAIN" \
--env CLUSTER_NAME="$CLUSTER_NAME" \
--env NUM_DNS_MEMBERS="$NUM_DNS_MEMBERS" \
--env API_VIP="$API_VIP" \
"${COREDNS_IMAGE}" \
--conf /etc/coredns/Corefile
27 changes: 15 additions & 12 deletions data/data/bootstrap/baremetal/files/usr/local/bin/keepalived.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,19 @@ export DNS_VRID
export NET_MASK
envsubst < /etc/keepalived/keepalived.conf.tmpl | sudo tee /etc/keepalived/keepalived.conf

MATCHES="$(sudo podman ps -a --format "{{.Names}}" | awk '/keepalived$/ {print $0}')"
if [[ -z "$MATCHES" ]]; then
# TODO(bnemec): Figure out how to run with less perms
podman create \
--name keepalived \
--volume /etc/keepalived:/etc/keepalived:z \
--network=host \
--privileged \
--cap-add=ALL \
"${KEEPALIVED_IMAGE}" \
/usr/sbin/keepalived -f /etc/keepalived/keepalived.conf \
--dont-fork -D -l -P
MATCHES="$(podman ps -a --format "{{.Names}}" | awk '/keepalived$/ {print $0}')"
if [[ ! -z "$MATCHES" ]]; then
# Remove old pod, or you can get storage for container removed
# errors on restart if the container exits unexpectedly
podman rm -f keepalived
fi
# TODO(bnemec): Figure out how to run with less perms
podman create \
--name keepalived \
--volume /etc/keepalived:/etc/keepalived:z \
--network=host \
--privileged \
--cap-add=ALL \
"${KEEPALIVED_IMAGE}" \
/usr/sbin/keepalived -f /etc/keepalived/keepalived.conf \
--dont-fork -D -l -P

0 comments on commit 7c7d13d

Please sign in to comment.