MohanDV commented on a change in pull request #1566: METRON-2322 Add Ambari
connection check to upgrade_helper script
URL: https://github.com/apache/metron/pull/1566#discussion_r348478032
##########
File path: 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 -i -u "$username":"$password" -H "X-Requested-By:
ambari" -X GET http://$ambari_address/api/v1/clusters/$cluster_name | head -n
1)
Review comment:
@mmiklavc I get `curl: (23) Failed writing body (3631 != 15905)` error
constantly. Looks like the piped program head is closing the read pipe before
the curl completely writes .
`[root@xxx-2 bin]# ./upgrade_helper.sh backup
ctr-e141-1563959304486-90868-01-000002.hwx.site:8080 admin admin
hcp201-solr4-build6
Backing up Ambari config...
Checking connection...
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left Speed
100 32297 0 32297 0 0 131k 0 --:--:-- --:--:-- --:--:--
131k
curl: (23) Failed writing body (3631 != 15905)
Unable to get cluster detail from Ambari. Check your username, password, and
cluster name. Skipping.
Skipping Metron config backup - Metron not found on this host`
I ran the curl command with `-s, --silent Silent mode. Don't output
anything` it works fine
`[root@xxx-2 bin]# curl -s -i -u "admin":"admin" -H "X-Requested-By: ambari"
-X GET
http://ctr-e141-1563959304486-90868-01-000002.hwx.site:8080/api/v1/clusters/hcp201-solr4-build6
| head -n 1
HTTP/1.1 200 OK`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services