summaryrefslogtreecommitdiffstats
path: root/roles/ands_monitor/templates/scripts/clean_sdn_ips.sh.j2
blob: c938121a3e68374b102d38598ebd932e1e018396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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"