#! /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"