Skip to content

Commit

Permalink
Add a script to remove all failover configurations.
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamed Mahmoud <mmahmoud@redhat.com>
  • Loading branch information
msherif1234 committed Jul 8, 2021
1 parent 4202141 commit 1ecb85a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ipfailover/keepalived/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
FROM registry.ci.openshift.org/ocp/4.8:base

RUN INSTALL_PKGS="kmod keepalived iproute psmisc nmap-ncat net-tools ipset ipset-libs" && \
RUN INSTALL_PKGS="kmod keepalived iproute psmisc nmap-ncat net-tools ipset ipset-libs procps-ng" && \
yum install -y $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
yum clean all
Expand Down
14 changes: 14 additions & 0 deletions ipfailover/keepalived/lib/failover-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ function cleanup() {
exit 0
}

function unconfigure_failover() {
echo " - Removing ip_vs module ..."
modprobe -r ip_vs

chain="${HA_IPTABLES_CHAIN:-""}"
if [[ -n ${chain} ]]; then
if iptables -C ${chain} 1 -d 224.0.0.18/32 -j ACCEPT ; then
echo " - Removing keepalived multicast iptables rule ..."
iptables -D ${chain} 1 -d 224.0.0.18/32 -j ACCEPT
fi
fi

cleanup $(pidof /usr/sbin/keepalived)
}

function setup_failover() {
echo " - Loading ip_vs module ..."
Expand Down
3 changes: 3 additions & 0 deletions ipfailover/keepalived/makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ test: image

image:
docker build -t $(IMAGE_NAME) .

clean:
docker run -it --net=host --privileged=true --entrypoint "/var/lib/ipfailover/keepalived/remove-failover.sh" $(IMAGE_NAME)
7 changes: 7 additions & 0 deletions ipfailover/keepalived/remove-failover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Includes.
source "$(dirname "${BASH_SOURCE[0]}")/lib/failover-functions.sh"

echo "`basename $0`: OpenShift IP Failover service terminating."
unconfigure_failover

0 comments on commit 1ecb85a

Please sign in to comment.