Last active
August 29, 2015 14:14
-
-
Save ianblenke/038c6540cd37d776664b to your computer and use it in GitHub Desktop.
Add an X-Fleet Conflicts to all deis deployed units
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
fleetctl list-units -fields=unit -no-legend | grep -v -e '@\|deis' | cut -d. -f1-2 | sort | uniq | while read name ; do | |
max=$(fleetctl list-machines -no-legend | wc -l) | |
count=$(fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | wc -l) | |
if [ $count -gt $max ]; then | |
echo "Skipping $name, there are $count deployed units on $max fleet machines" | |
else | |
echo "Processing $name" | |
fleetctl list-units -fields=unit -no-legend | grep -e "^$name" | while read service; do | |
others=$(echo $service | cut -d. -f1-2) | |
tmpfile=/tmp/$service | |
fleetctl cat $service > $tmpfile | |
if ! grep X-Fleet $tmpfile > /dev/null; then | |
echo "" >> $tmpfile | |
echo "[X-Fleet]" >> $tmpfile | |
echo "Conflicts=$others*" >> $tmpfile | |
fleetctl destroy $tmpfile | |
fleetctl start $tmpfile | |
else | |
echo "Skipping $service, it already has an X-Fleet" | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment