mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-04-18 16:16:45 +00:00
Backport error reporting fixes
This commit is contained in:
@@ -92,6 +92,8 @@ aws_kill_instances_by_tag() {
|
||||
|
||||
aws ec2 terminate-instances --instance-ids $IDS \
|
||||
| grep ^TERMINATINGINSTANCES
|
||||
|
||||
info "Deleted instances with tag $TAG."
|
||||
}
|
||||
|
||||
aws_tag_instances() {
|
||||
|
||||
@@ -13,15 +13,15 @@ die() {
|
||||
}
|
||||
|
||||
error() {
|
||||
echo "[$(red ERROR)] $1"
|
||||
>/dev/stderr echo "[$(red ERROR)] $1"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo "[$(yellow WARNING)] $1"
|
||||
>/dev/stderr echo "[$(yellow WARNING)] $1"
|
||||
}
|
||||
|
||||
info() {
|
||||
echo "[$(green INFO)] $1"
|
||||
>/dev/stderr echo "[$(green INFO)] $1"
|
||||
}
|
||||
|
||||
# Print a full-width separator.
|
||||
@@ -33,17 +33,19 @@ sep() {
|
||||
fi
|
||||
SEP=$(yes = | tr -d "\n" | head -c $[$COLUMNS - 1])
|
||||
if [ -z "$1" ]; then
|
||||
echo $SEP
|
||||
>/dev/stderr echo $SEP
|
||||
else
|
||||
MSGLEN=$(echo "$1" | wc -c)
|
||||
if [ $[ $MSGLEN +4 ] -gt $COLUMNS ]; then
|
||||
echo "$SEP"
|
||||
echo "$1"
|
||||
echo "$SEP"
|
||||
>/dev/stderr echo "$SEP"
|
||||
>/dev/stderr echo "$1"
|
||||
>/dev/stderr echo "$SEP"
|
||||
else
|
||||
LEFTLEN=$[ ($COLUMNS - $MSGLEN - 2) / 2 ]
|
||||
RIGHTLEN=$[ $COLUMNS - $MSGLEN - 2 - $LEFTLEN ]
|
||||
echo "$(echo $SEP | head -c $LEFTLEN) $1 $(echo $SEP | head -c $RIGHTLEN)"
|
||||
LEFTSEP=$(echo $SEP | head -c $LEFTLEN)
|
||||
RIGHTSEP=$(echo $SEP | head -c $RIGHTLEN)
|
||||
>/dev/stderr echo "$LEFTSEP $1 $RIGHTSEP"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -65,12 +67,10 @@ need_settings() {
|
||||
need_ips_file() {
|
||||
IPS_FILE=$1
|
||||
if [ -z "$IPS_FILE" ]; then
|
||||
echo "IPS_FILE not set."
|
||||
die
|
||||
die "IPS_FILE not set."
|
||||
fi
|
||||
|
||||
if [ ! -s "$IPS_FILE" ]; then
|
||||
echo "IPS_FILE $IPS_FILE not found. Please run: $0 ips <TAG>"
|
||||
die
|
||||
die "IPS_FILE $IPS_FILE not found. Please run: $0 ips <TAG>"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ _cmd_deploy() {
|
||||
# wait until all hosts are reachable before trying to deploy
|
||||
info "Trying to reach $TAG instances..."
|
||||
while ! tag_is_reachable $TAG; do
|
||||
echo -n "."
|
||||
>/dev/stderr echo -n "."
|
||||
sleep 2
|
||||
done
|
||||
echo ""
|
||||
>/dev/stderr echo ""
|
||||
|
||||
sep "Deploying tag $TAG"
|
||||
pssh -I tee /tmp/settings.yaml < $SETTINGS
|
||||
@@ -105,6 +105,7 @@ _cmd_deploy() {
|
||||
sudo -u docker tee -a /home/docker/.ssh/authorized_keys"
|
||||
|
||||
# On node1, create and deploy TLS certs using Docker Machine
|
||||
# (Currently disabled.)
|
||||
true || pssh "
|
||||
if grep -q node1 /tmp/node; then
|
||||
grep ' node' /etc/hosts |
|
||||
@@ -130,7 +131,8 @@ _cmd_kube() {
|
||||
sudo tee /etc/apt/sources.list.d/kubernetes.list"
|
||||
pssh "
|
||||
sudo apt-get update -q &&
|
||||
sudo apt-get install -qy kubelet kubeadm kubectl"
|
||||
sudo apt-get install -qy kubelet kubeadm kubectl
|
||||
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl"
|
||||
|
||||
# Work around https://github.com/kubernetes/kubernetes/issues/53356
|
||||
pssh "
|
||||
@@ -216,9 +218,9 @@ _cmd_status() {
|
||||
need_tag $TAG
|
||||
describe_tag $TAG
|
||||
tag_is_reachable $TAG
|
||||
echo "You may be interested in running one of the following commands:"
|
||||
echo "$0 ips $TAG"
|
||||
echo "$0 deploy $TAG <settings/somefile.yaml>"
|
||||
info "You may be interested in running one of the following commands:"
|
||||
info "$0 ips $TAG"
|
||||
info "$0 deploy $TAG <settings/somefile.yaml>"
|
||||
}
|
||||
|
||||
_cmd opensg "Open the default security group to ALL ingress traffic"
|
||||
@@ -320,9 +322,9 @@ _cmd_start() {
|
||||
if [ -n "$SETTINGS" ]; then
|
||||
_cmd_deploy $TAG $SETTINGS
|
||||
else
|
||||
echo "To deploy or kill these instances, run one of the following:"
|
||||
echo "$0 deploy $TAG <settings/somefile.yaml>"
|
||||
echo "$0 stop $TAG"
|
||||
info "To deploy or kill these instances, run one of the following:"
|
||||
info "$0 deploy $TAG <settings/somefile.yaml>"
|
||||
info "$0 stop $TAG"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -376,7 +378,7 @@ pull_tag(){
|
||||
need_tag $TAG
|
||||
link_tag $TAG
|
||||
if [ ! -s $IPS_FILE ]; then
|
||||
echo "Nonexistent or empty IPs file $IPS_FILE"
|
||||
die "Nonexistent or empty IPs file $IPS_FILE."
|
||||
fi
|
||||
|
||||
# Pre-pull a bunch of images
|
||||
|
||||
@@ -60,7 +60,7 @@ system("echo docker:training | sudo chpasswd")
|
||||
|
||||
# Fancy prompt courtesy of @soulshake.
|
||||
system("""sudo -u docker tee -a /home/docker/.bashrc <<SQRL
|
||||
export PS1='\e[1m\e[31m[\h] \e[32m(\\\$(docker-prompt)) \e[34m\u@{}\e[35m \w\e[0m\n$ '
|
||||
export PS1='\e[1m\e[31m[\h] \e[32m(\\$(docker-prompt)) \e[34m\u@{}\e[35m \w\e[0m\n$ '
|
||||
SQRL""".format(ipv4))
|
||||
|
||||
# Custom .vimrc
|
||||
|
||||
@@ -6,7 +6,7 @@ pssh () {
|
||||
HOSTFILE="ips.txt"
|
||||
|
||||
[ -f $HOSTFILE ] || {
|
||||
echo "No hostfile found at $HOSTFILE"
|
||||
>/dev/stderr echo "No hostfile found at $HOSTFILE"
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user