diff --git a/CHANGES.txt b/CHANGES.txt index 4478dba6f6..1b2827270d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -465,6 +465,8 @@ Trunk (unreleased changes) commands that do not complete within a certain amount of time. (Sreekanth Ramakrishnan via yhemanth) + HADOOP-5925. EC2 scripts should exit on error. (tomwhite) + OPTIMIZATIONS HADOOP-5595. NameNode does not need to run a replicator to choose a diff --git a/src/contrib/ec2/bin/cmd-hadoop-cluster b/src/contrib/ec2/bin/cmd-hadoop-cluster index a4570a2dc7..5678dee8f9 100644 --- a/src/contrib/ec2/bin/cmd-hadoop-cluster +++ b/src/contrib/ec2/bin/cmd-hadoop-cluster @@ -17,6 +17,8 @@ # Run commands on master or specified node of a running Hadoop EC2 cluster. +set -o errexit + # if no args specified, show usage if [ $# = 0 ]; then echo "Command required!" diff --git a/src/contrib/ec2/bin/create-hadoop-image b/src/contrib/ec2/bin/create-hadoop-image index 31b3048586..98064c2d31 100755 --- a/src/contrib/ec2/bin/create-hadoop-image +++ b/src/contrib/ec2/bin/create-hadoop-image @@ -18,6 +18,8 @@ # Create a Hadoop AMI. # Inspired by Jonathan Siegel's EC2 script (http://blogsiegel.blogspot.com/2006/08/sandboxing-amazon-ec2.html) +set -o errexit + # Import variables bin=`dirname "$0"` bin=`cd "$bin"; pwd` diff --git a/src/contrib/ec2/bin/delete-hadoop-cluster b/src/contrib/ec2/bin/delete-hadoop-cluster index a070d34e2b..96e8d5b4d7 100644 --- a/src/contrib/ec2/bin/delete-hadoop-cluster +++ b/src/contrib/ec2/bin/delete-hadoop-cluster @@ -15,7 +15,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Delete the groups an local files associated with a cluster. +# Delete the groups and local files associated with a cluster. + +set -o errexit if [ -z $1 ]; then echo "Cluster name required!" @@ -42,17 +44,17 @@ bin=`cd "$bin"; pwd` rm -f $MASTER_IP_PATH rm -f $MASTER_PRIVATE_IP_PATH -ec2-describe-group | egrep "[[:space:]]$CLUSTER_MASTER[[:space:]]" > /dev/null -if [ $? -eq 0 ]; then +if ec2-describe-group $CLUSTER_MASTER > /dev/null 2>&1; then + if ec2-describe-group $CLUSTER > /dev/null 2>&1; then + echo "Revoking authorization between $CLUSTER_MASTER and $CLUSTER" + ec2-revoke $CLUSTER_MASTER -o $CLUSTER -u $AWS_ACCOUNT_ID || true + ec2-revoke $CLUSTER -o $CLUSTER_MASTER -u $AWS_ACCOUNT_ID || true + fi echo "Deleting group $CLUSTER_MASTER" - ec2-revoke $CLUSTER_MASTER -o $CLUSTER -u $AWS_ACCOUNT_ID + ec2-delete-group $CLUSTER_MASTER fi -ec2-describe-group | egrep "[[:space:]]$CLUSTER[[:space:]]" > /dev/null -if [ $? -eq 0 ]; then +if ec2-describe-group $CLUSTER > /dev/null 2>&1; then echo "Deleting group $CLUSTER" - ec2-revoke $CLUSTER -o $CLUSTER_MASTER -u $AWS_ACCOUNT_ID + ec2-delete-group $CLUSTER fi - -ec2-delete-group $CLUSTER_MASTER -ec2-delete-group $CLUSTER diff --git a/src/contrib/ec2/bin/hadoop-ec2 b/src/contrib/ec2/bin/hadoop-ec2 index ca035a475a..be857f8118 100644 --- a/src/contrib/ec2/bin/hadoop-ec2 +++ b/src/contrib/ec2/bin/hadoop-ec2 @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -o errexit + bin=`dirname "$0"` bin=`cd "$bin"; pwd` diff --git a/src/contrib/ec2/bin/launch-hadoop-cluster b/src/contrib/ec2/bin/launch-hadoop-cluster index a69d53eba1..f1aefc4e8c 100644 --- a/src/contrib/ec2/bin/launch-hadoop-cluster +++ b/src/contrib/ec2/bin/launch-hadoop-cluster @@ -17,6 +17,8 @@ # Launch an EC2 cluster of Hadoop instances. +set -o errexit + # Import variables bin=`dirname "$0"` bin=`cd "$bin"; pwd` diff --git a/src/contrib/ec2/bin/launch-hadoop-master b/src/contrib/ec2/bin/launch-hadoop-master index c6621fbf58..01b9724f6e 100644 --- a/src/contrib/ec2/bin/launch-hadoop-master +++ b/src/contrib/ec2/bin/launch-hadoop-master @@ -17,6 +17,8 @@ # Launch an EC2 Hadoop master. +set -o errexit + if [ -z $1 ]; then echo "Cluster name required!" exit -1 @@ -46,8 +48,7 @@ if [ ! -z "$MASTER_EC2_HOST" ]; then exit 0 fi -ec2-describe-group | egrep "[[:space:]]$CLUSTER_MASTER[[:space:]]" > /dev/null -if [ ! $? -eq 0 ]; then +if ! ec2-describe-group $CLUSTER_MASTER > /dev/null 2>&1; then echo "Creating group $CLUSTER_MASTER" ec2-add-group $CLUSTER_MASTER -d "Group for Hadoop Master." ec2-authorize $CLUSTER_MASTER -o $CLUSTER_MASTER -u $AWS_ACCOUNT_ID @@ -61,8 +62,7 @@ if [ ! $? -eq 0 ]; then fi fi -ec2-describe-group | egrep "[[:space:]]$CLUSTER[[:space:]]" > /dev/null -if [ ! $? -eq 0 ]; then +if ! ec2-describe-group $CLUSTER > /dev/null 2>&1; then echo "Creating group $CLUSTER" ec2-add-group $CLUSTER -d "Group for Hadoop Slaves." ec2-authorize $CLUSTER -o $CLUSTER -u $AWS_ACCOUNT_ID @@ -105,8 +105,7 @@ MASTER_EC2_ZONE=`ec2-describe-instances $INSTANCE | grep INSTANCE | grep running echo $MASTER_EC2_ZONE > $MASTER_ZONE_PATH while true; do - REPLY=`ssh $SSH_OPTS "root@$MASTER_EC2_HOST" 'echo "hello"'` - if [ ! -z $REPLY ]; then + if ssh $SSH_OPTS "root@$MASTER_EC2_HOST" 'echo "hello"' > /dev/null 2>&1; then break; fi sleep 5 diff --git a/src/contrib/ec2/bin/launch-hadoop-slaves b/src/contrib/ec2/bin/launch-hadoop-slaves index b40c1d7996..503e57f94e 100644 --- a/src/contrib/ec2/bin/launch-hadoop-slaves +++ b/src/contrib/ec2/bin/launch-hadoop-slaves @@ -17,6 +17,8 @@ # Launch an EC2 Hadoop slaves. +set -o errexit + if [ -z $1 ]; then echo "Cluster name required!" exit -1 diff --git a/src/contrib/ec2/bin/list-hadoop-clusters b/src/contrib/ec2/bin/list-hadoop-clusters index 6163f9cca6..422e4d0c35 100644 --- a/src/contrib/ec2/bin/list-hadoop-clusters +++ b/src/contrib/ec2/bin/list-hadoop-clusters @@ -17,6 +17,8 @@ # List running clusters. +set -o errexit + # Import variables bin=`dirname "$0"` bin=`cd "$bin"; pwd` diff --git a/src/contrib/ec2/bin/terminate-hadoop-cluster b/src/contrib/ec2/bin/terminate-hadoop-cluster index 835269186d..ff20cfec01 100755 --- a/src/contrib/ec2/bin/terminate-hadoop-cluster +++ b/src/contrib/ec2/bin/terminate-hadoop-cluster @@ -17,6 +17,8 @@ # Terminate a cluster. +set -o errexit + if [ -z $1 ]; then echo "Cluster name required!" exit -1