summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-10-06 04:43:13 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-10-06 04:43:13 +0200
commitacd54ba601e34dafac063f94054bb80348e73dcd (patch)
treebb904bbf2d58e2a97d2649193c29d31f174ef8e1
parent55ae94fdb6a6508f30c0eb0f5dfe95a11ac9682f (diff)
downloadands-acd54ba601e34dafac063f94054bb80348e73dcd.tar.gz
ands-acd54ba601e34dafac063f94054bb80348e73dcd.tar.bz2
ands-acd54ba601e34dafac063f94054bb80348e73dcd.tar.xz
ands-acd54ba601e34dafac063f94054bb80348e73dcd.zip
Script to fullhy clean-up outdated rc
-rwxr-xr-xscripts/maintain/gluster/gluster.sh (renamed from scripts/gluster.sh)0
-rw-r--r--scripts/maintain/gluster/opts.sh (renamed from scripts/opts.sh)0
-rw-r--r--scripts/maintain/prunerc.sh60
-rwxr-xr-xscripts/provision/hawakular.sh (renamed from scripts/hawakular.sh)0
-rwxr-xr-xscripts/provision/kube-ops-view.sh (renamed from scripts/kube-ops-view.sh)0
5 files changed, 60 insertions, 0 deletions
diff --git a/scripts/gluster.sh b/scripts/maintain/gluster/gluster.sh
index a3ff186..a3ff186 100755
--- a/scripts/gluster.sh
+++ b/scripts/maintain/gluster/gluster.sh
diff --git a/scripts/opts.sh b/scripts/maintain/gluster/opts.sh
index 2f76d8e..2f76d8e 100644
--- a/scripts/opts.sh
+++ b/scripts/maintain/gluster/opts.sh
diff --git a/scripts/maintain/prunerc.sh b/scripts/maintain/prunerc.sh
new file mode 100644
index 0000000..166ede6
--- /dev/null
+++ b/scripts/maintain/prunerc.sh
@@ -0,0 +1,60 @@
+#! /bin/bash
+
+setup=""
+commit=0
+prune_stopped=0
+
+while [ -n "$1" ]; do
+ case "$1" in
+ -c | --commit ) commit=1; shift ;;
+ -s | --stopped ) prune_stopped=1; shift ;;
+ -n | --setup ) setup="-n $2"; shift 2;;
+ * ) echo "$0 [-n project] [--commit] [--stopped]"; break ;;
+ esac
+done
+
+
+dcs="$(oc $setup get dc | grep -v NAME)"
+
+while read -r dc; do
+ name=$(echo "$dc" | awk '{ print $1 }')
+ revision=$(echo "$dc" | awk '{ print $2 }')
+ dc_desired=$(echo "$dc" | awk '{ print $3 }')
+ dc_current=$(echo "$dc" | awk '{ print $4 }')
+
+ rcname="$name-$revision"
+ rc="$(oc $setup get rc $rcname | grep -v NAME)"
+ desired=$(echo "$rc" | awk '{ print $2 }')
+ current=$(echo "$rc" | awk '{ print $3 }')
+ ready=$(echo "$rc" | awk '{ print $4 }')
+
+ if [ $dc_desired -ne $dc_current ]; then
+ [ $commit -eq 1 ] && echo "Skipping faulty dc/$name"
+ continue
+ elif [ $desired -ne $current -o $desired -ne $ready ]; then
+ [ $commit -eq 1 ] && echo "Skipping not completely ready dc/$name"
+ continue
+ elif [ $desired -eq 0 -a $prune_stopped -ne 1 ]; then
+ [ $commit -eq 1 ] && echo "Skipping stopped dc/$name (last one could be faulty)"
+ continue
+ fi
+
+
+ rcs="$(oc $setup get rc -l openshift.io/deployment-config.name=$name | grep -v NAME)"
+
+ while read -r oldrc; do
+ oldname=$(echo "$oldrc" | awk '{ print $1 }')
+ desired=$(echo "$oldrc" | awk '{ print $2 }')
+
+ [ $oldname = $rcname ] && continue
+ [ $desired -ne 0 ] && continue
+
+ if [ $commit -eq 1 ]; then
+ echo "Removing: $oldname (keeping $rcname[$ready])"
+ oc $setup delete rc "$oldname"
+ else
+ echo "Will remove: $oldname (keeping $rcname[$ready])"
+ fi
+ done <<< "$rcs"
+
+done <<< "$dcs"
diff --git a/scripts/hawakular.sh b/scripts/provision/hawakular.sh
index 73e3a87..73e3a87 100755
--- a/scripts/hawakular.sh
+++ b/scripts/provision/hawakular.sh
diff --git a/scripts/kube-ops-view.sh b/scripts/provision/kube-ops-view.sh
index ca1389e..ca1389e 100755
--- a/scripts/kube-ops-view.sh
+++ b/scripts/provision/kube-ops-view.sh