From ba38e611d52be0fad53cf95d9da916ea9298438e Mon Sep 17 00:00:00 2001 From: Dale Date: Wed, 13 Nov 2019 17:26:51 +1100 Subject: [PATCH 1/2] METRON-2312 - Added additional error checking in scripts --- .../src/main/scripts/create_collection.sh | 11 +++++++++-- .../src/main/scripts/delete_collection.sh | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh index 7693646e25..ae2e94a8a2 100755 --- a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh +++ b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh @@ -16,8 +16,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -METRON_VERSION=${project.version} -METRON_HOME=/usr/metron/$METRON_VERSION ZOOKEEPER=${ZOOKEEPER:-localhost:2181} ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/hdp/current/zookeeper-client} SECURITY_ENABLED=${SECURITY_ENABLED:-false} @@ -26,6 +24,15 @@ if [ ${SECURITY_ENABLED,,} == 'true' ]; then NEGOTIATE=' --negotiate -u : ' fi +# test for errors +if [[ ${SOLR_NODE} =~ .*:null ]]; then + echo "Error occurred while attempting to read SOLR Cloud configuration data from Zookeeper."; + if ! [[ ${ZOOKEEPER} =~ .*/solr ]]; then + echo "Warning! Environment variable ZOOKEEPER=$ZOOKEEPER does not contain a chrooted zookeeper ensemble address - are you sure you do not mean ZOOKEEPER=$ZOOKEEPER/solr?"; + fi + exit 1; +fi + # Get the first Solr node from the list of live nodes in Zookeeper SOLR_NODE=`$ZOOKEEPER_HOME/bin/zkCli.sh -server $ZOOKEEPER ls /live_nodes | tail -n 1 | sed 's/\[\([^,]*\).*\]/\1/' | sed 's/_solr//'` diff --git a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh index c8b45e7e1b..bf91648f3e 100755 --- a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh +++ b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh @@ -18,7 +18,7 @@ # METRON_VERSION=${project.version} METRON_HOME=/usr/metron/$METRON_VERSION -ZOOKEEPER=${ZOOKEEPER:-localhost:2181} +ZOOKEEPER=${ZOOKEEPER:-localhost:2181}/solr ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/hdp/current/zookeeper-client} SECURITY_ENABLED=${SECURITY_ENABLED:-false} NEGOTIATE='' @@ -29,5 +29,14 @@ fi # Get the first Solr node from the list of live nodes in Zookeeper SOLR_NODE=`$ZOOKEEPER_HOME/bin/zkCli.sh -server $ZOOKEEPER ls /live_nodes | tail -n 1 | sed 's/\[\([^,]*\).*\]/\1/' | sed 's/_solr//'` +# test for errors +if [[ ${SOLR_NODE} =~ .*:null ]]; then + echo "Error occurred while attempting to read SOLR Cloud configuration data from Zookeeper."; + if ! [[ ${ZOOKEEPER} =~ .*/solr ]]; then + echo "Warning! Environment variable ZOOKEEPER=$ZOOKEEPER does not contain a chrooted zookeeper ensemble address - are you sure you do not mean ZOOKEEPER=$ZOOKEEPER/solr?"; + fi + exit 1; +fi + # Delete the collection curl -X GET $NEGOTIATE "http://$SOLR_NODE/solr/admin/collections?action=DELETE&name=$1" From d3f426c7f436076fb2add38c58ccf03639de7308 Mon Sep 17 00:00:00 2001 From: Dale Date: Wed, 13 Nov 2019 17:32:46 +1100 Subject: [PATCH 2/2] METRON-2312 - Fixup typos --- .../metron-solr-common/src/main/scripts/delete_collection.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh index bf91648f3e..8279aa83b4 100755 --- a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh +++ b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh @@ -16,9 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -METRON_VERSION=${project.version} -METRON_HOME=/usr/metron/$METRON_VERSION -ZOOKEEPER=${ZOOKEEPER:-localhost:2181}/solr +ZOOKEEPER=${ZOOKEEPER:-localhost:2181} ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/hdp/current/zookeeper-client} SECURITY_ENABLED=${SECURITY_ENABLED:-false} NEGOTIATE=''