Hi,

When the instance is manually killed, CEP sends the member fault event. Then CC tries to terminate the instance. Before termination it call detachVolume() which I guess a async call. Then termination fails if the volume detachment is not finished yet.
I tried this manually. Though the detachment was return, EC2 console stills shows the volume as IN USE. Isn't it better to check the status before terminationg


On Wed, Feb 19, 2014 at 5:26 AM, Udara Liyanage <udara@wso2.com> wrote:
Volume is started on zone : ap-southeast-1a
Instance  ins tarded on zone   :ap-southeast-1b

Successfully created a new volume [id]: vol-ee5d20e6 in [region] : ap-southeast-1, [zone] : ap-southeast-1a of Iaas : IaasProvider [type=ec2, name=ec2 specific details, image=ap-southeast-1/ami-16d78044, provider=aws-ec2] {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas}
TID: [0] [CC] [2014-02-19 10:12:02,248]  INFO {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas} -  Successfully created a new volume [id]: vol-d85d20d0 in [region] : ap-southeast-1, [zone] : ap-southeast-1a of Iaas : IaasProvider [type=ec2, name=ec2 specific details, image=ap-southeast-1/ami-16d78044, provider=aws-ec2] {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas}



On Wed, Feb 19, 2014 at 4:18 AM, Udara Liyanage <udara@wso2.com> wrote:
Hi Nirmal,

This is the partition I have used. It has specified the zone.
{
"partition":{
        "id": "P1",
        "provider": "ec2",
        "property": [
        {
                "name": "region",
                "value": "ap-southeast-1"
        },    
      {
                "name": "zone",                                                                                                                                                                                                              
                "value": "ap-southeast-1a"
        }
        ]
   }
}



On Wed, Feb 19, 2014 at 4:10 AM, Nirmal Fernando <nirmal070125@gmail.com> wrote:
If you want persistence volume support you need to have an availability zone defined in your EC2 partitions. Also, in Openstack you need to set autoAssignIp to true (and make a blocking start instance call), since in Openstack you cannot attach volumes before the instance is started up.


On Wed, Feb 19, 2014 at 2:16 PM, Udara Liyanage <udara@wso2.com> wrote:
Hi,

I encountered a problem while CC attaching volumes to the instances. The issue was instance and volume is started in different availability zones. Then the volume can not be attached. It is a limitation in EC2.



TID: [0] [CC] [2014-02-19 08:32:47,776]  INFO {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas} -  Successfully created a new volume [id]: vol-98611c90 in [region] : ap-southeast-1, [zone] : ap-southeast-1a of Iaas : IaasProvider [type=ec2, name=ec2 specific details, image=ap-southeast-1/ami-16d78044, provider=aws-ec2] {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas}
TID: [0] [CC] [2014-02-19 08:32:47,946]  INFO {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas} -  Successfully created a new volume [id]: vol-b1611cb9 in [region] : ap-southeast-1, [zone] : ap-southeast-1a of Iaas : IaasProvider [type=ec2, name=ec2 specific details, image=ap-southeast-1/ami-16d78044, provider=aws-ec2] {org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas}
TID: [0] [CC] [2014-02-19 08:33:10,977]  INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} -  Retrieving Public IP Address : MemberContext [memberId=udaraalias.phpnew.domainefb7441b-1828-4601-90e5-61ab21be7810, nodeId=ap-southeast-1/i-3823c710, clusterId=udaraalias.phpnew.domain, cartridgeType=phpnew, privateIpAddress=null, publicIpAddress=54.254.45.183, allocatedIpAddress=null, initTime=1392798757867, lbClusterId=lb1090620467.lb.domain, networkPartitionId=ec2] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl}
TID: [0] [CC] [2014-02-19 08:33:10,979]  INFO {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} -  Retrieving Private IP Address. MemberContext [memberId=udaraalias.phpnew.domainefb7441b-1828-4601-90e5-61ab21be7810, nodeId=ap-southeast-1/i-3823c710, clusterId=udaraalias.phpnew.domain, cartridgeType=phpnew, privateIpAddress=10.145.162.214, publicIpAddress=54.254.45.183, allocatedIpAddress=null, initTime=1392798757867, lbClusterId=lb1090620467.lb.domain, networkPartitionId=ec2] {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl}
TID: [0] [CC] [2014-02-19 08:33:11,096]  INFO {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher} -  Publishing instance spawned event: [service] phpnew [cluster] udaraalias.phpnew.domain [network-partition] ec2 [partition] P1 [member] udaraalias.phpnew.domainefb7441b-1828-4601-90e5-61ab21be7810 [lb-cluster-id] lb1090620467.lb.domain {org.apache.stratos.cloud.controller.topology.TopologyEventPublisher}
TID: [0] [CC] [2014-02-19 08:33:11,110] ERROR {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} -  Attaching Volume to Instance [ i-3823c710 ] failed! {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl}
org.jclouds.aws.AWSResponseException: request POST https://ec2.ap-southeast-1.amazonaws.com/ HTTP/1.1 failed with code 400, error: AWSError{requestId='a99e351f-c4a3-4236-81ff-0187ba79c14a', requestToken='null', code='InvalidVolume.ZoneMismatch', message='The volume 'vol-98611c90' is not in the same availability zone as instance 'i-3823c710'', context='{Response=, Errors=}'}
at org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent.handleError(ParseAWSErrorFromXmlContent.java:77)
at org.jclouds.http.handlers.DelegatingErrorHandler.handleError(DelegatingErrorHandler.java:67)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.shouldContinue(BaseHttpCommandExecutorService.java:180)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:150)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:93)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:76)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:47)
at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:79)
at sun.proxy.$Proxy85.attachVolumeInRegion(Unknown Source)
at org.apache.stratos.cloud.controller.iaases.AWSEC2Iaas.attachVolume(AWSEC2Iaas.java:447)
at org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl.startInstance(CloudControllerServiceImpl.java:348)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:231)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
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.TomcatValveContainer.invokeValves(TomcatValveContainer.java:49)
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$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
TID: [0] [CC] [2014-02-19 08:33:11,276] ERROR {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl} -  Attaching Volume to Instance [ i-3823c710 ] failed! {org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl}
org.jclouds.aws.AWSResponseException: request POST https://ec2.ap-southeast-1.amazonaws.com/ HTTP/1.1 failed with code 400, error: AWSError{requestId='116503fb-f486-4bf6-833c-58fe225fbdc7', requestToken='null', code='InvalidVolume.ZoneMismatch', message='The volume 'vol-b1611cb9' is not in the same availability zone as instance 'i-3823c710''


On Fri, Feb 14, 2014 at 7:59 AM, Udara Liyanage <udara@wso2.com> wrote:
Currently I tried with CURL command.  

Please note the bold arguments to the json I added. This feature needed to be added to the CLI and UI.

curl -X POST -H "Content-Type: application/json" -d '{"cartridgeInfoBean":{"cartridgeType":"php","alias":"phpa111","repoURL":"https://github.com/lakwarus/testphp.git","privateRepo":"true","repoUsername":"lakwarus@gmail.com","repoPassword":"wso2123","autoscalePolicy":"economyPolicy","deploymentPolicy":"isuruh-ec2","persistanceRequired":"true","size":10,"device":"/dev/sdc","removeOnTermination":"false"}}' -k -v -u admin:admin https://ec2-54-254-43-232.ap-southeast-1.compute.amazonaws.com:9445/stratos/admin/cartridge/subscribe


On Fri, Feb 14, 2014 at 7:44 AM, Imesh Gunaratne <imesh@apache.org> wrote:
Great work Udara! 
How do we expose this functionality to the end user? Did we finalize the design?

Thanks


On Fri, Feb 14, 2014 at 7:23 AM, Udara Liyanage <udara@wso2.com> wrote:
Hi,

Was able to attach an volume to the instance in EC2. However I think we need to create a file system manually as in [1]. I create the file system as in [1] and able to mount the volume to the instance.

 We can send the device name via payload, then agent create the file system at the startup.


--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

phone: +94 71 443 6897




--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

phone: +94 71 443 6897



--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

phone: +94 71 443 6897



--
Best Regards,
Nirmal

Nirmal Fernando.
PPMC Member & Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.




--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

phone: +94 71 443 6897



--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

phone: +94 71 443 6897



--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897