Created 09-02-2018 05:24 PM
with the following API I restart all services in ambari that required restart
curl -sH "X-Requested-By: ambari" -u USER:$PASSWD -i http://$SERVER:8080/api/v1/clusters/$CLUSTER_NAME/requests?fields=Requests/request_status
how to know if API succeeded to restart all services ?
for example
we get true in case all services restart succsfuly
we get false when one or more services are failed
Created 09-03-2018 12:15 AM
You can make the following API call to check whether the "Restart all required services" got successfully COMPLETD or not? Or it got failed? By keep tracking the "request_status".
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests?fields=Requests/id,Requests... | grep -A2 -B3 "Restart all required services"
.
Output Example:
"Requests" : { "cluster_name" : "TestCluster", "id" : 789, "request_context" : "Restart all required services", "request_status" : "COMPLETED" }
.
If you want to know what got failed then you have the request id (789) to find out what went wrong:
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests/789
.
In order to get more fine grained output like which Task got failed on which Host during "Restart all required services" operation, you can make the following kind of API call once you know the request id from above calls.
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests/789/tasks?fields=Tasks/comm...
.
Created 09-03-2018 12:15 AM
You can make the following API call to check whether the "Restart all required services" got successfully COMPLETD or not? Or it got failed? By keep tracking the "request_status".
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests?fields=Requests/id,Requests... | grep -A2 -B3 "Restart all required services"
.
Output Example:
"Requests" : { "cluster_name" : "TestCluster", "id" : 789, "request_context" : "Restart all required services", "request_status" : "COMPLETED" }
.
If you want to know what got failed then you have the request id (789) to find out what went wrong:
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests/789
.
In order to get more fine grained output like which Task got failed on which Host during "Restart all required services" operation, you can make the following kind of API call once you know the request id from above calls.
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests/789/tasks?fields=Tasks/comm...
.
Created 09-03-2018 08:11 AM
@Jay I think the following syntax is more fit for my case
curl -sH "X-Requested-By: ambari" -u admin:admin -i http://$SERVER:8080/api/v1/clusters/$cluster_name/requests?fields=Requests/request_status | awk '/request_status/' | tail -1 | egrep -iq "FAILED|ABORTED"
it will capture the last status , and if this fail or abort then the status is fail
what you think?
Created 09-03-2018 08:22 AM
If you simply wants to know if the "Restart all required services" was successfully completed or not then you can simply make the same old API call as following:
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests?fields=Requests/id,Requests... | grep -A2 -B3 "Restart all required services" | grep 'request_status'
.
Either the operation will be COMPLETED or FAILED|ABORTED.
# curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/requests?fields=Requests/id,Requests... | grep -A2 -B3 "Restart all required services" | grep 'request_status' "request_status" : "COMPLETED"
Created 09-03-2018 09:00 AM
@Jay in my case we get the following
and the expected results should be only the last line ( last restart results )
curl -sH "X-Requested-By: ambari" -u admin:admin -X GET http://$server:8080/api/v1/clusters/$cluster/requests?fields=Requests/id,Requests/request_status,Req... | grep -A2 -B3 "Restart all required services" | grep 'request_status'
"request_status" : "COMPLETED" "request_status" : "COMPLETED" "request_status" : "COMPLETED" "request_status" : "FAILED" "request_status" : "COMPLETED"
Created 09-03-2018 09:42 AM
@Jay see also what are the real latest restart status
"href" : "http://master:8080/api/v1/clusters/HDP/requests/186", "Requests" : { "cluster_name" : "HDP", "id" : 186, "request_context" : "Restart all components for ZooKeeper", "request_status" : "ABORTED" } }, { "href" : "http://master:8080/api/v1/clusters/HDP/requests/187", "Requests" : { "cluster_name" : "HDP", "id" : 187, "request_context" : "Restart all components for Kafka", "request_status" : "COMPLETED" } }, { "href" : "http://master:8080/api/v1/clusters/HDP/requests/188", "Requests" : { "cluster_name" : "HDP", "id" : 188, "request_context" : "Restart all components for Kafka", "request_status" : "COMPLETED" } } ]
Created 09-03-2018 09:49 AM
By "latest restart status" do you mean a particular "Component" restart (like NameNode, DataNode..etc) Or a particular Service Restart ("HDFS" service / Yarn Service restart status?)
Created 09-03-2018 10:34 AM
@Jay,
as you know we run the API that restart all req services,
and what we mean is that we want to capture only the last status from restart action , ( so the req ID should be only the last ) ,
for example , if now the last req id is 187 , then on the next restart it will be 188 , so we want to capture only the status of req id - 188 ( fail / ok )
but as I mentioned my syntax is give this
curl -sH "X-Requested-By: ambari" -u admin:admin -i http://$SERVER:8080/api/v1/clusters/$cluster_name/requests?fields=Requests/request_status | awk '/request_status/' | tail -1 | egrep -iq "FAILED|ABORTED" [[ $? -eq 0 ]] && echo fail || echo ok
Created 06-12-2019 08:20 PM
Is there any way to restart an ABORTED or FAILED request?