Can you try the delete at the level of "components" - 
http://localhost:8080/api/v1/clusters/c1/services/STORM/components/STORM_REST_API

This is what succeeded for me after getting STORM_REST_API to INSTALLED.

[root@c6403 vagrant]# curl -i -uadmin:admin -H "X-Requested-By: ambari" -X GET 
http://localhost:8080/api/v1/clusters/c1/services/STORM/components/STORM_REST_API
HTTP/1.1 200 OK
Set-Cookie: AMBARISESSIONID=1ok5l711vxq3f9h27i1be8l63;Path=/
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 673
Server: Jetty(7.6.7.v20120910)

{
  "href" : 
"http://localhost:8080/api/v1/clusters/c1/services/STORM/components/STORM_REST_API";,
  "ServiceComponentInfo" : {
    "category" : "MASTER",
    "cluster_name" : "c1",
    "component_name" : "STORM_REST_API",
    "installed_count" : 1,
    "service_name" : "STORM",
    "started_count" : 0,
    "state" : "INSTALLED",
    "total_count" : 1
  },
  "host_components" : [
    {
      "href" : 
"http://localhost:8080/api/v1/clusters/c1/hosts/c6403.ambari.apache.org/host_components/STORM_REST_API";,
      "HostRoles" : {
        "cluster_name" : "c1",
        "component_name" : "STORM_REST_API",
        "host_name" : "c6403.ambari.apache.org"
      }
    }
  ]
}

[root@c6403 vagrant]#
[root@c6403 vagrant]# curl -i -uadmin:admin -H "X-Requested-By: ambari" -X 
DELETE 
http://localhost:8080/api/v1/clusters/c1/services/STORM/components/STORM_REST_API
HTTP/1.1 200 OK
Set-Cookie: AMBARISESSIONID=1ant3i1sk3s715va5ha573cyl;Path=/
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 0
Server: Jetty(7.6.7.v20120910)

[root@c6403 vagrant]# ambari-server --version
2.0.0
________________________________________
From: Eirik Thorsnes <[email protected]>
Sent: Saturday, May 16, 2015 2:40 AM
To: [email protected]
Subject: Re: Ambari 2.0, stack: HDP-2.2.4: Unable to remove STORM 
service/components by using API

On 14.05.15 19:43, Artem Ervits wrote:
 > Hello Eirik,
 > I also struggled with this, eventually I figured it out by poking
around in the Ambari database. In essence, you need to make sure the
state is installed before you can delete it. Once you put it in the
correct state, you should be able to delete all components by first
listing which are still available. I apologize that I cannot give you
the steps I've taken but since it was a lot of trial and error, I don't
have a conclusive procedure.


Hello,

I've now checked that the state/desiredstate in the ambari-db is set to
INSTALLED for both component and service.
I'm able to delete all other Storm host-components, except
STORM_REST_API. For this I get:

curl -u admin:admin -X DELETE -H 'X-Requested-By: ambari'
http://localhost:8080/api/v1/clusters/helm/hosts/service-10-0.local/host_components/STORM_REST_API
{
   "status" : 500,
   "message" : "org.apache.ambari.server.controller.spi.SystemException:
An internal system exception occurred: Could not find service for
component, componentName=STORM_REST_API, clusterName=helm,
stackInfo=HDP-2.2"

The db shows that it is still there:

ambari=> select * from servicecomponentdesiredstate where service_name =
'STORM';
  component_name | cluster_id |          desired_stack_version
  | desired_state | service_name
----------------+------------+------------------------------------------+---------------+--------------
  STORM_REST_API |          2 | {"stackName":"HDP","stackVersion":"2.2"}
| INSTALLED     | STORM
(1 row)

ambari=> SELECT * from hostcomponentstate where service_name = 'STORM';
  cluster_id | component_name |          current_stack_version
  | current_state |     host_name      | service_name | upgrade_state |
  version  | s
ecurity_state
------------+----------------+------------------------------------------+---------------+--------------------+--------------+---------------+-----------+--
--------------
           2 | STORM_REST_API | {"stackName":"HDP","stackVersion":"2.2"}
| INSTALLED     | service-10-0.local | STORM        | NONE          |
2.2.4.2-2 | U
NSECURED
(1 row)

ambari=> SELECT * from hostcomponentdesiredstate where service_name =
'STORM';
  cluster_id | component_name |          desired_stack_version
  | desired_state |     host_name      | service_name | admin_state |
maintenance_sta
te | restart_required | security_state
------------+----------------+------------------------------------------+---------------+--------------------+--------------+-------------+----------------
---+------------------+----------------
           2 | STORM_REST_API | {"stackName":"HDP","stackVersion":"2.2"}
| INSTALLED     | service-10-0.local | STORM        | INSERVICE   | OFF

    |                0 | UNSECURED
(1 row)

ambari=> select * from servicedesiredstate where service_name = 'STORM';
  cluster_id | desired_host_role_mapping |
desired_stack_version           | desired_state | service_name |
maintenance_state | security_state
------------+---------------------------+------------------------------------------+---------------+--------------+-------------------+----------------
           2 |                         0 |
{"stackName":"HDP","stackVersion":"2.2"} | INSTALLED     | STORM
| OFF               | UNSECURED
(1 row)

ambari=> select * from clusterservices where service_name = 'STORM';
  service_name | cluster_id | service_enabled
--------------+------------+-----------------
  STORM        |          2 |               0
(1 row)

This db info is not shown if I do a GET on the Storm service:

curl -u admin:admin -X DELETE -H 'X-Requested-By: ambari'
http://localhost:8080/api/v1/clusters/helm/services/STORM
{
   "href" : "http://localhost:8080/api/v1/clusters/helm/services/STORM";,
   "ServiceInfo" : {
     "cluster_name" : "helm",
     "maintenance_state" : "OFF",
     "service_name" : "STORM",
     "state" : "UNKNOWN"
   },
   "alerts_summary" : {
     "CRITICAL" : 1,
     "MAINTENANCE" : 0,
     "OK" : 0,
     "UNKNOWN" : 0,
     "WARNING" : 0
   },
   "alerts" : [
     {
       "href" :
"http://localhost:8080/api/v1/clusters/helm/services/STORM/alerts/8";,
       "Alert" : {
         "cluster_name" : "helm",
         "definition_id" : 24,
         "definition_name" : "storm_supervisor_process_percent",
         "host_name" : null,
         "id" : 8,
         "service_name" : "STORM"
       }
     }
   ],
   "components" : [ ],
   "artifacts" : [ ]

I also see much more Storm alerts in the alerts_definition table (though
they are all disabled, includung the one above).


Thanks,
Eirik Thorsnes

Reply via email to