You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by mm...@apache.org on 2019/12/06 19:05:26 UTC

[metron] branch master updated: METRON-2322 Add Ambari connection check to upgrade_helper script (mmiklavc) closes apache/metron#1566

This is an automated email from the ASF dual-hosted git repository.

mmiklavcic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron.git


The following commit(s) were added to refs/heads/master by this push:
     new b8ea1e2  METRON-2322 Add Ambari connection check to upgrade_helper script (mmiklavc) closes apache/metron#1566
b8ea1e2 is described below

commit b8ea1e22aebdd4e228f4c278c3171c18af664de4
Author: mmiklavc <mi...@gmail.com>
AuthorDate: Fri Dec 6 12:04:50 2019 -0700

    METRON-2322 Add Ambari connection check to upgrade_helper script (mmiklavc) closes apache/metron#1566
---
 Upgrading.md                                         |  3 +++
 metron-platform/metron-common/README.md              |  4 ++++
 .../metron-common/src/main/scripts/upgrade_helper.sh | 20 +++++++++++++-------
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Upgrading.md b/Upgrading.md
index d5a848b..e6bf612 100644
--- a/Upgrading.md
+++ b/Upgrading.md
@@ -22,6 +22,9 @@ configuration which are non-backwards compatible.
 
 ## 0.7.2 to 0.7.3
 
+### [METRON-2239: Metron Automated backup and restore](https://issues.apache.org/jira/browse/METRON-2239)
+An upgrade helper script has been added to `$METRON_HOME/bin/upgrade_helper.sh`. This script will assist in backing up and restoring Ambari configuration and Metron configuration stored in Zookeeper. You can see more details at [Metron Upgrade Helper](metron-platform/metron-common#metron-upgrade-helper) and [Upgrade Steps](Upgrade_steps.md).
+
 ### [METRON-2321: Remove Legacy AWS Deployment Path](https://issues.apache.org/jira/browse/METRON-2321)
 The automated Amazon AWS deployment mechanism (previously located at `metron-deployment/amazon-ec2`) has been removed.  It is not the preferred installation path for deploying to AWS. Using Ambari and the Metron MPack is the preferred installation path. To deploy Metron to AWS, provision EC2 nodes, install Ambari, install the Metron MPack, then use Ambari to deploy Metron.
 
diff --git a/metron-platform/metron-common/README.md b/metron-platform/metron-common/README.md
index 2cee5dd..f0874eb 100644
--- a/metron-platform/metron-common/README.md
+++ b/metron-platform/metron-common/README.md
@@ -501,3 +501,7 @@ $METRON_HOME/bin/upgrade_helper.sh backup node1:8080 admin admin metron_cluster
 $METRON_HOME/bin/upgrade_helper.sh restore node1:8080 admin admin metron_cluster
 ```
 
+Note: Before issuing a restore, you should verify that the backup completed successfully. If there is an issue connecting to the Ambari server, the following message will appear in the script output.
+```
+**ERROR:** Unable to get cluster detail from Ambari. Check your username, password, and cluster name. Skipping.
+```
diff --git a/metron-platform/metron-common/src/main/scripts/upgrade_helper.sh b/metron-platform/metron-common/src/main/scripts/upgrade_helper.sh
index e272756..0f079d5 100755
--- a/metron-platform/metron-common/src/main/scripts/upgrade_helper.sh
+++ b/metron-platform/metron-common/src/main/scripts/upgrade_helper.sh
@@ -57,12 +57,18 @@ if [ "$mode" == "backup" ]; then
     fi
     if [ -f "/var/lib/ambari-server/resources/scripts/configs.py" ]; then
         echo Backing up Ambari config...
-        for config_type in $(curl -u $username:$password -H "X-Requested-By: ambari" -X GET  http://$ambari_address/api/v1/clusters/$cluster_name?fields=Clusters/desired_configs | grep '" : {' | grep -v Clusters | grep -v desired_configs | cut -d'"' -f2 | grep metron); 
-        do 
-            echo Saving $config_type
-            /var/lib/ambari-server/resources/scripts/configs.py -u $username -p $password -a get -l ${ambari_address%:*} -n $cluster_name -c $config_type -f $AMBARI_CONFIG_DIR/${config_type}.json
-        done
-        echo Done backing up Ambari config...
+        echo Checking connection...
+        ret_status=$(curl -s -i -u "$username":"$password" -H "X-Requested-By: ambari" -X GET  http://$ambari_address/api/v1/clusters/$cluster_name | head -n 1 | sed -e 's/[[:space:]]*$//')
+        if [ "HTTP/1.1 200 OK" == "$ret_status" ]; then
+            for config_type in $(curl -s -u "$username":"$password" -H "X-Requested-By: ambari" -X GET  http://$ambari_address/api/v1/clusters/$cluster_name?fields=Clusters/desired_configs | grep '" : {' | grep -v Clusters | grep -v desired_configs | cut -d'"' -f2 | grep metron); 
+            do 
+                echo Saving $config_type
+                /var/lib/ambari-server/resources/scripts/configs.py -u "$username" -p "$password" -a get -l ${ambari_address%:*} -n $cluster_name -c $config_type -f $AMBARI_CONFIG_DIR/${config_type}.json
+            done
+            echo Done backing up Ambari config...
+        else
+            echo '** ERROR **: Unable to get cluster detail from Ambari. Check your username, password, and cluster name. Skipping.'
+        fi
     else
         echo Skipping Ambari config backup - Ambari not found on this host
     fi
@@ -91,7 +97,7 @@ elif [ "$mode" == "restore" ]; then
                 echo $i. Found config: $filename
                 config_type=${filename%.json}
                 echo "   Setting config_type to $config_type"
-                /var/lib/ambari-server/resources/scripts/configs.py -u $username -p $password -a set -l ${ambari_address%:*} -n $cluster_name -c $config_type -f $AMBARI_CONFIG_DIR/${config_type}.json
+                /var/lib/ambari-server/resources/scripts/configs.py -u "$username" -p "$password" -a set -l ${ambari_address%:*} -n $cluster_name -c $config_type -f $AMBARI_CONFIG_DIR/${config_type}.json
                 echo "   Done restoring $config_type"
             done
             echo Done restoring $i metron config files from $OUT_DIR