diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2020-01-22 03:16:06 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2020-01-22 03:16:06 +0100 |
commit | 1e8153c2af051ce48d5aa08d3dbdc0d0970ea532 (patch) | |
tree | 7bb1441a87521aa8c3c5524f95fa645850a6826e /roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2 | |
parent | e0b1b53f21095707af87a095934e971d788a90c7 (diff) | |
download | ands-1e8153c2af051ce48d5aa08d3dbdc0d0970ea532.tar.gz ands-1e8153c2af051ce48d5aa08d3dbdc0d0970ea532.tar.bz2 ands-1e8153c2af051ce48d5aa08d3dbdc0d0970ea532.tar.xz ands-1e8153c2af051ce48d5aa08d3dbdc0d0970ea532.zip |
Document another problem with lost IPs and exhausting of SDN IP range
Diffstat (limited to 'roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2')
-rwxr-xr-x | roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2 | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2 b/roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2 new file mode 100755 index 0000000..c938121 --- /dev/null +++ b/roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2 @@ -0,0 +1,17 @@ +#! /bin/bash + +host=$(uname -n) + +# Check node is in the cluster and we have permissions to access OpenShift +oc get node "$host" &> /dev/null +[ $? -ne 0 ] && { echo "Can't query node $host, check cluster configuration and permissions"; exit; } + +oc adm manage-node "$host" --schedulable=false &> /dev/null +[ $? -ne 0 ] && { echo "Failed to disable scheduling on the node $host"; exit; } + +for hash in $(find /var/lib/cni/networks/openshift-sdn/* -mmin +120 -print0 | xargs -0 tail -n +1 | grep '^[A-Za-z0-9]*$' | cut -c 1-8); do if [ -z $(docker ps -a | grep $hash | awk '{print $1}') ]; then grep -ilr $hash ./; fi; done | xargs rm + +systemctl restart origin-node + +oc adm manage-node "$host" --schedulable=true &> /dev/null +[ $? -ne 0 ] && echo "Failed to re-nablee scheduling on the node $host" |