I have fixed it now and pushed to master.

Thanks.

On Fri, Mar 20, 2015 at 3:46 PM, Imesh Gunaratne <[email protected]> wrote:

> A good finding Raj! I think Shiro introduced this functionality some time
> back. There is no reason to keep this cache in SM. We could move it to
> AS/CC.
>
> Thanks
>
> On Fri, Mar 20, 2015 at 10:49 AM, Rajkumar Rajaratnam <[email protected]>
> wrote:
>
>> I had a look at the code. Nested groups are not considered when removing
>> removing application from the above map. It only considers the outer most
>> group. That's why It is working fine for groups without any nesting. I will
>> fix it.
>>
>> Thanks.
>>
>> On Fri, Mar 20, 2015 at 10:33 AM, Rajkumar Rajaratnam <[email protected]
>> > wrote:
>>
>>> Hi,
>>>
>>> It is a bug, I know the reason.
>>>
>>> SM keeps track of cartridge groups and the applications which are using
>>> them. Purpose is to prevent removing cartridge group if it is used in any
>>> applications. SM have a *cartridgeGroupToApplicationsMap*
>>> (Map<cartridgeGroupId, Set<appId>>). When an application is added, SM adds
>>> all the cartridge groups used in the application into this map. When an
>>> application is deleted, SM should remove this application from this map.
>>> But this latter part is not happening. Hence we are not able to remove the
>>> cartridge group after an application is deployed.
>>>
>>> Fix is to remove the application from the
>>> *cartridgeGroupToApplicationsMap* when we delete the application.
>>>
>>> PS - I don't know whether there is any specific reason to keep track of
>>> it at SM. IMO, we should keep track it at AS.
>>>
>>> Thanks.
>>>
>>> On Fri, Mar 20, 2015 at 10:17 AM, Imesh Gunaratne <[email protected]>
>>> wrote:
>>>
>>>> Hi Shaheed,
>>>>
>>>> The following error could be raised if there is any application or
>>>> cartridge group that refers the cartridge group we are trying to delete:
>>>>
>>>> TID: [0] [STRATOS] [2015-03-19 21:17:39,959] ERROR
>>>> {org.apache.stratos.rest.endpoint.api.StratosApiV41Utils} -  Cannot
>>>> remove cartridge group: [group-name] shaheed-1 since it is used in another
>>>> cartridge group or an application
>>>>
>>>> Will us be able to query all the applications and cartridge groups in
>>>> the system and verify whether this is not the case?
>>>>
>>>> Thanks
>>>>
>>>> On Fri, Mar 20, 2015 at 3:07 AM, Shaheedur Haque (shahhaqu) <
>>>> [email protected]> wrote:
>>>>
>>>>>  Hi,
>>>>>
>>>>>
>>>>>
>>>>> I am having trouble deleting **some** Cartridge Groups. For example
>>>>> in this sequence, notice how even after the referencing Application and
>>>>> deployment are deleted, the Cartridge Group cannot be deleted:
>>>>>
>>>>>
>>>>>
>>>>> $ ./bin/orchestration subscription setup --admin subscription/t.json
>>>>>
>>>>> INFO: Service Group added successfully: [service-group] shaheed-1
>>>>>
>>>>> INFO: Application added successfully: [application] shaheed-1
>>>>>
>>>>> INFO: Application deployed successfully: [application] shaheed-1
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> $ ./bin/orchestration subscription remove --admin shaheed-1
>>>>>
>>>>> INFO: Application undeployed successfully: [application] shaheed-1
>>>>>
>>>>> INFO: Application deleted successfully: [application] shaheed-1
>>>>>
>>>>> INFO: DELETE error from
>>>>> https://10.0.0.101:9443/api/cartridgeGroups/shaheed-1 using None:
>>>>> ('400 Client Error: Bad Request', u'Error while fulfilling the request')
>>>>>
>>>>>
>>>>>
>>>>> We confirm the application has gone, and that it cannot be deleted
>>>>> using the Stratos CLI:
>>>>>
>>>>>
>>>>>
>>>>> $ ./bin/orchestration stratos-login --admin
>>>>>
>>>>> Successfully authenticated
>>>>>
>>>>> stratos> list-cartridge-groups
>>>>>
>>>>> Cartridge Groups found:
>>>>>
>>>>> +-----------+-------------------+--------------+--------------------+
>>>>>
>>>>> | Name      | No. of cartridges | No of groups | Dependency scaling |
>>>>>
>>>>> +-----------+-------------------+--------------+--------------------+
>>>>>
>>>>> | shaheed-1 | 2                 | 1            | false              |
>>>>>
>>>>> +-----------+-------------------+--------------+--------------------+
>>>>>
>>>>> stratos> list-applications
>>>>>
>>>>> Applications found:
>>>>>
>>>>> +-----------------+-----------------+----------+
>>>>>
>>>>> | Application ID  | Alias           | Status   |
>>>>>
>>>>> +-----------------+-----------------+----------+
>>>>>
>>>>> | cartridge-proxy | cartridge-proxy | Deployed |
>>>>>
>>>>> +-----------------+-----------------+----------+
>>>>>
>>>>> | cisco-sample-vm | cisco-sample-vm | Deployed |
>>>>>
>>>>> +-----------------+-----------------+----------+
>>>>>
>>>>> stratos> remove-cartridge-group shaheed-1
>>>>>
>>>>> HTTP/1.1 400 Bad Request
>>>>>
>>>>> stratos>
>>>>>
>>>>>
>>>>>
>>>>> The exception in the wso2carbon.log suggests some reference count
>>>>> problem:
>>>>>
>>>>>
>>>>>
>>>>> TID: [0] [STRATOS] [2015-03-19 21:17:39,959] ERROR
>>>>> {org.apache.stratos.rest.endpoint.api.StratosApiV41Utils} -  Cannot remove
>>>>> cartridge group: [group-name] shaheed-1 since it is used in another
>>>>> cartridge group or an application
>>>>>
>>>>> TID: [0] [STRATOS] [2015-03-19 21:17:39,959] ERROR
>>>>> {org.apache.stratos.rest.endpoint.handlers.CustomExceptionMapper} -  Error
>>>>> while fulfilling the request
>>>>>
>>>>> org.apache.stratos.rest.endpoint.exception.RestAPIException
>>>>>
>>>>>         at
>>>>> org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.removeServiceGroup(StratosApiV41Utils.java:992)
>>>>>
>>>>>         at
>>>>> org.apache.stratos.rest.endpoint.api.StratosApiV41.removeServiceGroup(StratosApiV41.java:485)
>>>>>
>>>>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>
>>>>>         at
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>
>>>>>         at
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>
>>>>>         at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:194)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:100)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:57)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:93)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:159)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:286)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doDelete(AbstractHTTPServlet.java:217)
>>>>>
>>>>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:761)
>>>>>
>>>>>         at
>>>>> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:262)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:56)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
>>>>>
>>>>>         at
>>>>> org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>>>>
>>>>>         at
>>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
>>>>>
>>>>>         at
>>>>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
>>>>>
>>>>>         at
>>>>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
>>>>>
>>>>>         at
>>>>> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
>>>>>
>>>>>         at
>>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>>>>>
>>>>>         at
>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>>>>
>>>>>         at java.lang.Thread.run(Thread.java:745)
>>>>>
>>>>> Caused by:
>>>>> org.apache.stratos.rest.endpoint.exception.RestAPIException: Cannot remove
>>>>> cartridge group: [group-name] shaheed-1 since it is used in another
>>>>> cartridge group or an application
>>>>>
>>>>>         at
>>>>> org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.removeServiceGroup(StratosApiV41Utils.java:962)
>>>>>
>>>>>         ... 45 more
>>>>>
>>>>>
>>>>>
>>>>> Curiously, if I use a Cartridge Group with no additional levels of
>>>>> nesting, it all works fine:
>>>>>
>>>>>
>>>>>
>>>>> $ ./bin/orchestration subscription setup --admin subscription/u.json
>>>>>
>>>>> INFO: Service Group added successfully: [service-group] shaheed-2
>>>>>
>>>>> INFO: Application added successfully: [application] shaheed-2
>>>>>
>>>>> INFO: Application deployed successfully: [application] shaheed-2
>>>>>
>>>>>
>>>>>
>>>>> $ ./bin/orchestration subscription remove --admin shaheed-2
>>>>>
>>>>> INFO: Application undeployed successfully: [application] shaheed-2
>>>>>
>>>>> INFO: Application deleted successfully: [application] shaheed-2
>>>>>
>>>>> INFO: Service Group deleted successfully: [service-group] shaheed-2
>>>>>
>>>>>
>>>>>
>>>>> For reference, this is what the two groups look like:
>>>>>
>>>>>
>>>>>
>>>>> stratos> describe-cartridge-group shaheed-1
>>>>>
>>>>> Service Group : shaheed-1
>>>>>
>>>>>
>>>>> {"name":"shaheed-1","groups":[{"name":"slice","cartridges":["cartridge-proxy","cisco-sample-vm"],"groupScalingEnabled":false,"dependencies":{"startupOrders":["cartridge.cartridge-proxy-1x0,cartridge.cisco-sample-vm-1x0"],"terminationBehaviour":"terminate-none"}}],"cartridges":["cartridge-proxy","cisco-sample-vm"],"groupScalingEnabled":false,"dependencies":{"terminationBehaviour":"terminate-none"}}
>>>>>
>>>>>
>>>>>
>>>>> stratos> describe-cartridge-group shaheed-2
>>>>>
>>>>> Service Group : shaheed-2
>>>>>
>>>>>
>>>>> {"name":"shaheed-2","cartridges":["cartridge-proxy","cisco-sample-vm"],"groupScalingEnabled":false,"dependencies":{"startupOrders":["cartridge.cartridge-proxy-0x0,cartridge.cisco-sample-vm-0x0"],"terminationBehaviour":"terminate-none"}}
>>>>>
>>>>>
>>>>>
>>>>> This seems like a beta-showstopper to me.
>>>>>
>>>>>
>>>>>
>>>>> Thanks, Shaheed
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Imesh Gunaratne
>>>>
>>>> Technical Lead, WSO2
>>>> Committer & PMC Member, Apache Stratos
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>> Mobile : +94777568639
>>> Blog : rajkumarr.com
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>> Mobile : +94777568639
>> Blog : rajkumarr.com
>>
>
>
>
> --
> Imesh Gunaratne
>
> Technical Lead, WSO2
> Committer & PMC Member, Apache Stratos
>



-- 
Rajkumar Rajaratnam
Committer & PMC Member, Apache Stratos
Software Engineer, WSO2

Mobile : +94777568639
Blog : rajkumarr.com

Reply via email to