You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Rajkumar Rajaratnam <ra...@wso2.com> on 2014/11/21 06:24:13 UTC

Stratos should not release(delete) predefined floating IPs?

Hi devs,

We have the following fields in Member Context;

// private ip  private String privateIpAddress;  // public ip  private
String publicIpAddress;  // manually allocated ip  private String
allocatedIpAddress;
I hope that the reason for having allocatedIpAddress is to release it when
terminating the instance. We are not releasing(deleting) all the public IPs.

Predefined IPs should not released when terminating the instances right? Is
this happening now? My predefined IP got released when I unsubscribed to
the cartridge.

Jclouds API doc;
   /**
    * destroy the node, given its id. If it is the only node in a tag set,
the dependent resources
    * will also be destroyed.
    */
   void destroyNode(String id);

So I guess all the floating IPs associated with the ports of this node will
also be released right?

Or can we set any property to prevent Jclouds from releasing floating IPs?

Thanks.

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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Nirmal Fernando <ni...@gmail.com>.
This is in Openstack, right?. From my view this is bug in Jclouds Openstack
module. Please check AWS-EC2 module code too.

On Fri, Nov 21, 2014 at 10:04 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> What is there in that method is;
>
>    @Override
>    public ZoneAndId apply(ZoneAndId id) {
>       FloatingIPApi floatingIpApi =
> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>          logger.debug(">> deallocating floatingIp(%s)", ip);
>          floatingIpApi.delete(ip.getId());
>       }
>       floatingIpCache.invalidate(id);
>       return id;
>    }
>
> As you can see, floatingIpApi.delete(ip.getId() will delete/release the IP.
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>> check in Openstack and do anything.
>>
>> I think what we currently do is, let destroyNode disassociate the IP from
>> the instance and then only we would release the IP.
>>
>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>> I went though Jclouds code base and found that destroyNode() will
>>> deallocate and release(delete) all floating IPs associated with the
>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>
>>>    @Override
>>>    public void destroyNode(String id) {
>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>       if
>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>          try {
>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>          } catch (RuntimeException e) {
>>>             logger.warn(e, "<< error removing and deallocating ip from
>>> node(%s): %s", id, e.getMessage());
>>>          }
>>>       }
>>>
>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>    }
>>>
>>>
>>>
>>> And what we are doing is,
>>>
>>> // destroy the node  iaasProvider.getComputeService().
>>> destroyNode(nodeId);
>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>> Calling release address after destroyNode() is not going to do anything.
>>> IPs are already released by destroyNode() method itself.
>>>
>>> Conclusion is, currently, when stratos terminates an instance it will
>>> release floating IPs allocated to this instance.
>>>
>>> We can improve it to not to release predefined floating IPs by
>>> disassociating the IP before calling destroyNode().
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I have commented out IP releasing code segment and unsubscribed from a
>>>>> cartridge. Floating IPs allocated to that instance were released(deleted).
>>>>> So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
>>>>> releasing the floating IPs too.
>>>>>
>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>> the code @ [1].
>>>>>
>>>>> We can remove/disassociate the predefined floating IPs before calling
>>>>> destroying the node. It will ensure that predefined floating IPs will not
>>>>> be released, rather these will be detached from the instance.
>>>>>
>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>
>>>>> 1.
>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>
>>>>> wdyt?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi Nirmal,
>>>>>>
>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>
>>>>>> This method either allocate an IP or using an available IP. So what
>>>>>> we setting to allocatedIPAddress can be either an allocated one or an
>>>>>> available one right? Am I missing something here?
>>>>>>
>>>>>> 1.
>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>
>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi Nirmal,
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi devs,
>>>>>>>>>>
>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>
>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>>>>>>> allocatedIpAddress;
>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>> all the public IPs.
>>>>>>>>>>
>>>>>>>>>> Predefined IPs should not released when terminating the instances
>>>>>>>>>> right? Is this happening now? My predefined IP got released when I
>>>>>>>>>> unsubscribed to the cartridge.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>
>>>>>>>>
>>>>>>>> We are not exactly doing it. So when we associate an floating IP to
>>>>>>>> an instance, we are retrieving all the available floating IPs, shuffle them
>>>>>>>> and associate the last floating IP to the instance. If there are no
>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>
>>>>>>>> My concern is that are we releasing predefined floating IPs too? If
>>>>>>>> so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>
>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>> predefined floating IPs?
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>    /**
>>>>>>>>>>     * destroy the node, given its id. If it is the only node in a
>>>>>>>>>> tag set, the dependent resources
>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>     */
>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>
>>>>>>>>>> So I guess all the floating IPs associated with the ports of this
>>>>>>>>>> node will also be released right?
>>>>>>>>>>
>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>> floating IPs?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Best Regards,
>>>>>>>>> Nirmal
>>>>>>>>>
>>>>>>>>> Nirmal Fernando.
>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>
>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best Regards,
>>>>>>> Nirmal
>>>>>>>
>>>>>>> Nirmal Fernando.
>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>
>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



-- 
Best Regards,
Nirmal

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

Blog: http://nirmalfdo.blogspot.com/

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
And what we have in VCloudIaas#releaseAddress() in stratos is;

  @Override
    public void releaseAddress(String ip) {
        // TODO
    }

:)

Thanks.

On Fri, Nov 21, 2014 at 2:38 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> What EC2DestroyNodeStrategy#destroyNode() will do is;
>
>    @Override
>    public NodeMetadata destroyNode(String id) {
>       String[] parts = AWSUtils.parseHandle(id);
>       String region = parts[0];
>       String instanceId = parts[1];
>
>       // TODO: can there be multiple?
>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>       destroyInstanceInRegion(instanceId, region);
>       return getNode.getNode(id);
>    }
>
> Here also, it is releasing the IP.
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> What is there in that method is;
>>
>>    @Override
>>    public ZoneAndId apply(ZoneAndId id) {
>>       FloatingIPApi floatingIpApi =
>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>          floatingIpApi.delete(ip.getId());
>>       }
>>       floatingIpCache.invalidate(id);
>>       return id;
>>    }
>>
>> As you can see, floatingIpApi.delete(ip.getId() will delete/release the
>> IP.
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <ni...@gmail.com>
>> wrote:
>>
>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>> check in Openstack and do anything.
>>>
>>> I think what we currently do is, let destroyNode disassociate the IP
>>> from the instance and then only we would release the IP.
>>>
>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> I went though Jclouds code base and found that destroyNode() will
>>>> deallocate and release(delete) all floating IPs associated with the
>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>
>>>>    @Override
>>>>    public void destroyNode(String id) {
>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>       if
>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>          try {
>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>          } catch (RuntimeException e) {
>>>>             logger.warn(e, "<< error removing and deallocating ip from
>>>> node(%s): %s", id, e.getMessage());
>>>>          }
>>>>       }
>>>>
>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>    }
>>>>
>>>>
>>>>
>>>> And what we are doing is,
>>>>
>>>> // destroy the node  iaasProvider.getComputeService().
>>>> destroyNode(nodeId);
>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>>>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>> Calling release address after destroyNode() is not going to do
>>>> anything. IPs are already released by destroyNode() method itself.
>>>>
>>>> Conclusion is, currently, when stratos terminates an instance it will
>>>> release floating IPs allocated to this instance.
>>>>
>>>> We can improve it to not to release predefined floating IPs by
>>>> disassociating the IP before calling destroyNode().
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have commented out IP releasing code segment and unsubscribed from
>>>>>> a cartridge. Floating IPs allocated to that instance were
>>>>>> released(deleted). So I guess, Jclouds'
>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>> too.
>>>>>>
>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>> the code @ [1].
>>>>>>
>>>>>> We can remove/disassociate the predefined floating IPs before calling
>>>>>> destroying the node. It will ensure that predefined floating IPs will not
>>>>>> be released, rather these will be detached from the instance.
>>>>>>
>>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>>
>>>>>> 1.
>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>
>>>>>> wdyt?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Hi Nirmal,
>>>>>>>
>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>
>>>>>>> This method either allocate an IP or using an available IP. So what
>>>>>>> we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>> available one right? Am I missing something here?
>>>>>>>
>>>>>>> 1.
>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>
>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Nirmal,
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi devs,
>>>>>>>>>>>
>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>
>>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private
>>>>>>>>>>> String allocatedIpAddress;
>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>
>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> We are not exactly doing it. So when we associate an floating IP
>>>>>>>>> to an instance, we are retrieving all the available floating IPs, shuffle
>>>>>>>>> them and associate the last floating IP to the instance. If there are no
>>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>
>>>>>>>>> My concern is that are we releasing predefined floating IPs too?
>>>>>>>>> If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>
>>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>>> predefined floating IPs?
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>    /**
>>>>>>>>>>>     * destroy the node, given its id. If it is the only node in
>>>>>>>>>>> a tag set, the dependent resources
>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>     */
>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>
>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>
>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>> floating IPs?
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Best Regards,
>>>>>>>>>> Nirmal
>>>>>>>>>>
>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>
>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Best Regards,
>>>>>>>> Nirmal
>>>>>>>>
>>>>>>>> Nirmal Fernando.
>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>
>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Hi Devs,

Created a JIRA to track this for FUTURE releases.

https://issues.apache.org/jira/browse/STRATOS-1054

Thanks.

On Fri, Nov 21, 2014 at 5:41 PM, Nirmal Fernando <ni...@wso2.com> wrote:

> Great! Please check on other IaaSes too.
>
> On Fri, Nov 21, 2014 at 12:03 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Proposed solution is working perfectly.
>>
>> I will do the changes when I have time.
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 3:07 PM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>>
>>>
>>> On Fri, Nov 21, 2014 at 3:02 PM, Nirmal Fernando <nirmal070125@gmail.com
>>> > wrote:
>>>
>>>>
>>>>
>>>> On Fri, Nov 21, 2014 at 10:27 AM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Yes Nirmal.
>>>>>
>>>>> There is a way.
>>>>>
>>>>> If we disassociate the floating IP before calling destroyNode(), it
>>>>> will not be released right?
>>>>>
>>>>
>>>> Can you try and see.. I am not sure whether it'll work or not.
>>>>
>>>
>>> It will work for sure. Once IP is disassociated from the instance, it
>>> not belonging to that instance. node.getPublicAddresses() will not contain
>>> this IP. So when terminating it will not delete the disassociated IP.
>>>
>>> I will try it. We need to include a new method in abstract class IaaS,
>>> say disassociateFloatingIP(String ip).
>>>
>>> Thanks.
>>>
>>>>
>>>>> So what I am suggesting is, for predefined floating IPs, we should
>>>>> disassociate the floating IPs before destroying the node.
>>>>>
>>>>> However, I might be wrong in going through the Jclouds code base.
>>>>> Please go through and verify it when you have time.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 2:51 PM, Nirmal Fernando <
>>>>> nirmal070125@gmail.com> wrote:
>>>>>
>>>>>> Ok, thanks.. so what are you suggesting to do? Is there anyway to
>>>>>> avoid this deletion inside destroyNode?
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 10:08 AM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> What EC2DestroyNodeStrategy#destroyNode() will do is;
>>>>>>>
>>>>>>>    @Override
>>>>>>>    public NodeMetadata destroyNode(String id) {
>>>>>>>       String[] parts = AWSUtils.parseHandle(id);
>>>>>>>       String region = parts[0];
>>>>>>>       String instanceId = parts[1];
>>>>>>>
>>>>>>>       // TODO: can there be multiple?
>>>>>>>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>>>>>>>       destroyInstanceInRegion(instanceId, region);
>>>>>>>       return getNode.getNode(id);
>>>>>>>    }
>>>>>>>
>>>>>>> Here also, it is releasing the IP.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> What is there in that method is;
>>>>>>>>
>>>>>>>>    @Override
>>>>>>>>    public ZoneAndId apply(ZoneAndId id) {
>>>>>>>>       FloatingIPApi floatingIpApi =
>>>>>>>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>>>>>>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>>>>>>>          logger.debug(">> removing floatingIp(%s) from node(%s)",
>>>>>>>> ip, id);
>>>>>>>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>>>>>>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>>>>>>>          floatingIpApi.delete(ip.getId());
>>>>>>>>       }
>>>>>>>>       floatingIpCache.invalidate(id);
>>>>>>>>       return id;
>>>>>>>>    }
>>>>>>>>
>>>>>>>> As you can see, floatingIpApi.delete(ip.getId() will delete/release
>>>>>>>> the IP.
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <
>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>>>>>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>>>>>>>> check in Openstack and do anything.
>>>>>>>>>
>>>>>>>>> I think what we currently do is, let destroyNode disassociate the
>>>>>>>>> IP from the instance and then only we would release the IP.
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <
>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> I went though Jclouds code base and found that destroyNode() will
>>>>>>>>>> deallocate and release(delete) all floating IPs associated with the
>>>>>>>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>>>>>>>
>>>>>>>>>>    @Override
>>>>>>>>>>    public void destroyNode(String id) {
>>>>>>>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>>>>>>>       if
>>>>>>>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>>>>>>>          try {
>>>>>>>>>>
>>>>>>>>>> removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>>>>>>>          } catch (RuntimeException e) {
>>>>>>>>>>             logger.warn(e, "<< error removing and deallocating ip
>>>>>>>>>> from node(%s): %s", id, e.getMessage());
>>>>>>>>>>          }
>>>>>>>>>>       }
>>>>>>>>>>
>>>>>>>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>>>>>>>    }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> And what we are doing is,
>>>>>>>>>>
>>>>>>>>>> // destroy the node  iaasProvider.getComputeService().
>>>>>>>>>> destroyNode(nodeId);
>>>>>>>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress()
>>>>>>>>>> != null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>>>>>>>> Calling release address after destroyNode() is not going to do
>>>>>>>>>> anything. IPs are already released by destroyNode() method itself.
>>>>>>>>>>
>>>>>>>>>> Conclusion is, currently, when stratos terminates an instance it
>>>>>>>>>> will release floating IPs allocated to this instance.
>>>>>>>>>>
>>>>>>>>>> We can improve it to not to release predefined floating IPs by
>>>>>>>>>> disassociating the IP before calling destroyNode().
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Anyone tried with a predefined floating IP and got the floating
>>>>>>>>>>> IP disassociated (not released) when unsubscribing to the cartridge?
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>
>>>>>>>>>>>> I have commented out IP releasing code segment and unsubscribed
>>>>>>>>>>>> from a cartridge. Floating IPs allocated to that instance were
>>>>>>>>>>>> released(deleted). So I guess, Jclouds'
>>>>>>>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>>>>>>>> too.
>>>>>>>>>>>>
>>>>>>>>>>>> So predefined floating IPs will also be removed. The flow we
>>>>>>>>>>>> are having is to destroy the node first and release the IPs then. Please
>>>>>>>>>>>> refer the code @ [1].
>>>>>>>>>>>>
>>>>>>>>>>>> We can remove/disassociate the predefined floating IPs before
>>>>>>>>>>>> calling destroying the node. It will ensure that predefined floating IPs
>>>>>>>>>>>> will not be released, rather these will be detached from the instance.
>>>>>>>>>>>>
>>>>>>>>>>>> Or I guess we should be able to set a property to prevent
>>>>>>>>>>>> releasing IPs when terminating instances. I sent a mail to jclouds user
>>>>>>>>>>>> list.
>>>>>>>>>>>>
>>>>>>>>>>>> 1.
>>>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>>>>>>>
>>>>>>>>>>>> wdyt?
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Please have a look at associateAddress(NodeMetadata node) @
>>>>>>>>>>>>> [1].
>>>>>>>>>>>>>
>>>>>>>>>>>>> This method either allocate an IP or using an available IP. So
>>>>>>>>>>>>> what we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>>>>>>>> available one right? Am I missing something here?
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1.
>>>>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you
>>>>>>>>>>>>>> are claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hi devs,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> // private ip  private String privateIpAddress;  //
>>>>>>>>>>>>>>>>> public ip  private String publicIpAddress;  // manually
>>>>>>>>>>>>>>>>> allocated ip  private String allocatedIpAddress;
>>>>>>>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> AFAIK we have to release an IP, only if we allocate
>>>>>>>>>>>>>>>> manually.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> We are not exactly doing it. So when we associate an
>>>>>>>>>>>>>>> floating IP to an instance, we are retrieving all the available floating
>>>>>>>>>>>>>>> IPs, shuffle them and associate the last floating IP to the instance. If
>>>>>>>>>>>>>>> there are no available floating IPs, we are allocating one and associate to
>>>>>>>>>>>>>>> the instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> My concern is that are we releasing predefined floating IPs
>>>>>>>>>>>>>>> too? If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> What I wanted to know is, are we releasing or not releasing
>>>>>>>>>>>>>>> the predefined floating IPs?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>>>>>>>    /**
>>>>>>>>>>>>>>>>>     * destroy the node, given its id. If it is the only
>>>>>>>>>>>>>>>>> node in a tag set, the dependent resources
>>>>>>>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>>>>>>>     */
>>>>>>>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> So I guess all the floating IPs associated with the ports
>>>>>>>>>>>>>>>>> of this node will also be released right?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Or can we set any property to prevent Jclouds from
>>>>>>>>>>>>>>>>> releasing floating IPs?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> Best Regards,
>>>>>>>>>>>>>>>> Nirmal
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Best Regards,
>>>>>>>>>>>>>> Nirmal
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Best Regards,
>>>>>>>>> Nirmal
>>>>>>>>>
>>>>>>>>> Nirmal Fernando.
>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>
>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best Regards,
>>>>>> Nirmal
>>>>>>
>>>>>> Nirmal Fernando.
>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>
>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Nirmal
>>>>
>>>> Nirmal Fernando.
>>>> PPMC Member & Committer of Apache Stratos,
>>>> Senior Software Engineer, WSO2 Inc.
>>>>
>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
>
> Thanks & regards,
> Nirmal
>
> Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
> Mobile: +94715779733
> Blog: http://nirmalfdo.blogspot.com/
>
>
>


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

Mobile : +94777568639
Blog : rajkumarr.com

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Proposed solution is working perfectly.

I will do the changes when I have time.

Thanks.

On Fri, Nov 21, 2014 at 3:07 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

>
>
> On Fri, Nov 21, 2014 at 3:02 PM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>>
>>
>> On Fri, Nov 21, 2014 at 10:27 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>> > wrote:
>>
>>> Yes Nirmal.
>>>
>>> There is a way.
>>>
>>> If we disassociate the floating IP before calling destroyNode(), it will
>>> not be released right?
>>>
>>
>> Can you try and see.. I am not sure whether it'll work or not.
>>
>
> It will work for sure. Once IP is disassociated from the instance, it not
> belonging to that instance. node.getPublicAddresses() will not contain this
> IP. So when terminating it will not delete the disassociated IP.
>
> I will try it. We need to include a new method in abstract class IaaS, say
> disassociateFloatingIP(String ip).
>
> Thanks.
>
>>
>>> So what I am suggesting is, for predefined floating IPs, we should
>>> disassociate the floating IPs before destroying the node.
>>>
>>> However, I might be wrong in going through the Jclouds code base. Please
>>> go through and verify it when you have time.
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 2:51 PM, Nirmal Fernando <nirmal070125@gmail.com
>>> > wrote:
>>>
>>>> Ok, thanks.. so what are you suggesting to do? Is there anyway to avoid
>>>> this deletion inside destroyNode?
>>>>
>>>> On Fri, Nov 21, 2014 at 10:08 AM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> What EC2DestroyNodeStrategy#destroyNode() will do is;
>>>>>
>>>>>    @Override
>>>>>    public NodeMetadata destroyNode(String id) {
>>>>>       String[] parts = AWSUtils.parseHandle(id);
>>>>>       String region = parts[0];
>>>>>       String instanceId = parts[1];
>>>>>
>>>>>       // TODO: can there be multiple?
>>>>>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>>>>>       destroyInstanceInRegion(instanceId, region);
>>>>>       return getNode.getNode(id);
>>>>>    }
>>>>>
>>>>> Here also, it is releasing the IP.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> What is there in that method is;
>>>>>>
>>>>>>    @Override
>>>>>>    public ZoneAndId apply(ZoneAndId id) {
>>>>>>       FloatingIPApi floatingIpApi =
>>>>>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>>>>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>>>>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip,
>>>>>> id);
>>>>>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>>>>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>>>>>          floatingIpApi.delete(ip.getId());
>>>>>>       }
>>>>>>       floatingIpCache.invalidate(id);
>>>>>>       return id;
>>>>>>    }
>>>>>>
>>>>>> As you can see, floatingIpApi.delete(ip.getId() will delete/release
>>>>>> the IP.
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <
>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>
>>>>>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>>>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>>>>>> check in Openstack and do anything.
>>>>>>>
>>>>>>> I think what we currently do is, let destroyNode disassociate the IP
>>>>>>> from the instance and then only we would release the IP.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> I went though Jclouds code base and found that destroyNode() will
>>>>>>>> deallocate and release(delete) all floating IPs associated with the
>>>>>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>>>>>
>>>>>>>>    @Override
>>>>>>>>    public void destroyNode(String id) {
>>>>>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>>>>>       if
>>>>>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>>>>>          try {
>>>>>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>>>>>          } catch (RuntimeException e) {
>>>>>>>>             logger.warn(e, "<< error removing and deallocating ip
>>>>>>>> from node(%s): %s", id, e.getMessage());
>>>>>>>>          }
>>>>>>>>       }
>>>>>>>>
>>>>>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>>>>>    }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> And what we are doing is,
>>>>>>>>
>>>>>>>> // destroy the node  iaasProvider.getComputeService().
>>>>>>>> destroyNode(nodeId);
>>>>>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress()
>>>>>>>> != null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>>>>>> Calling release address after destroyNode() is not going to do
>>>>>>>> anything. IPs are already released by destroyNode() method itself.
>>>>>>>>
>>>>>>>> Conclusion is, currently, when stratos terminates an instance it
>>>>>>>> will release floating IPs allocated to this instance.
>>>>>>>>
>>>>>>>> We can improve it to not to release predefined floating IPs by
>>>>>>>> disassociating the IP before calling destroyNode().
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I have commented out IP releasing code segment and unsubscribed
>>>>>>>>>> from a cartridge. Floating IPs allocated to that instance were
>>>>>>>>>> released(deleted). So I guess, Jclouds'
>>>>>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>>>>>> too.
>>>>>>>>>>
>>>>>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>>>>>> the code @ [1].
>>>>>>>>>>
>>>>>>>>>> We can remove/disassociate the predefined floating IPs before
>>>>>>>>>> calling destroying the node. It will ensure that predefined floating IPs
>>>>>>>>>> will not be released, rather these will be detached from the instance.
>>>>>>>>>>
>>>>>>>>>> Or I guess we should be able to set a property to prevent
>>>>>>>>>> releasing IPs when terminating instances. I sent a mail to jclouds user
>>>>>>>>>> list.
>>>>>>>>>>
>>>>>>>>>> 1.
>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>>>>>
>>>>>>>>>> wdyt?
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>>
>>>>>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>>>>>
>>>>>>>>>>> This method either allocate an IP or using an available IP. So
>>>>>>>>>>> what we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>>>>>> available one right? Am I missing something here?
>>>>>>>>>>>
>>>>>>>>>>> 1.
>>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi devs,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> // private ip  private String privateIpAddress;  // public
>>>>>>>>>>>>>>> ip  private String publicIpAddress;  // manually allocated
>>>>>>>>>>>>>>> ip  private String allocatedIpAddress;
>>>>>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> We are not exactly doing it. So when we associate an floating
>>>>>>>>>>>>> IP to an instance, we are retrieving all the available floating IPs,
>>>>>>>>>>>>> shuffle them and associate the last floating IP to the instance. If there
>>>>>>>>>>>>> are no available floating IPs, we are allocating one and associate to the
>>>>>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>>>>>
>>>>>>>>>>>>> My concern is that are we releasing predefined floating IPs
>>>>>>>>>>>>> too? If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>>>>>
>>>>>>>>>>>>> What I wanted to know is, are we releasing or not releasing
>>>>>>>>>>>>> the predefined floating IPs?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>>>>>    /**
>>>>>>>>>>>>>>>     * destroy the node, given its id. If it is the only node
>>>>>>>>>>>>>>> in a tag set, the dependent resources
>>>>>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>>>>>     */
>>>>>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>>>>>> floating IPs?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Best Regards,
>>>>>>>>>>>>>> Nirmal
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Best Regards,
>>>>>>>>>>>> Nirmal
>>>>>>>>>>>>
>>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>>
>>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best Regards,
>>>>>>> Nirmal
>>>>>>>
>>>>>>> Nirmal Fernando.
>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>
>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Nirmal
>>>>
>>>> Nirmal Fernando.
>>>> PPMC Member & Committer of Apache Stratos,
>>>> Senior Software Engineer, WSO2 Inc.
>>>>
>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
On Fri, Nov 21, 2014 at 3:02 PM, Nirmal Fernando <ni...@gmail.com>
wrote:

>
>
> On Fri, Nov 21, 2014 at 10:27 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Yes Nirmal.
>>
>> There is a way.
>>
>> If we disassociate the floating IP before calling destroyNode(), it will
>> not be released right?
>>
>
> Can you try and see.. I am not sure whether it'll work or not.
>

It will work for sure. Once IP is disassociated from the instance, it not
belonging to that instance. node.getPublicAddresses() will not contain this
IP. So when terminating it will not delete the disassociated IP.

I will try it. We need to include a new method in abstract class IaaS, say
disassociateFloatingIP(String ip).

Thanks.

>
>> So what I am suggesting is, for predefined floating IPs, we should
>> disassociate the floating IPs before destroying the node.
>>
>> However, I might be wrong in going through the Jclouds code base. Please
>> go through and verify it when you have time.
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 2:51 PM, Nirmal Fernando <ni...@gmail.com>
>> wrote:
>>
>>> Ok, thanks.. so what are you suggesting to do? Is there anyway to avoid
>>> this deletion inside destroyNode?
>>>
>>> On Fri, Nov 21, 2014 at 10:08 AM, Rajkumar Rajaratnam <
>>> rajkumarr@wso2.com> wrote:
>>>
>>>> What EC2DestroyNodeStrategy#destroyNode() will do is;
>>>>
>>>>    @Override
>>>>    public NodeMetadata destroyNode(String id) {
>>>>       String[] parts = AWSUtils.parseHandle(id);
>>>>       String region = parts[0];
>>>>       String instanceId = parts[1];
>>>>
>>>>       // TODO: can there be multiple?
>>>>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>>>>       destroyInstanceInRegion(instanceId, region);
>>>>       return getNode.getNode(id);
>>>>    }
>>>>
>>>> Here also, it is releasing the IP.
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> What is there in that method is;
>>>>>
>>>>>    @Override
>>>>>    public ZoneAndId apply(ZoneAndId id) {
>>>>>       FloatingIPApi floatingIpApi =
>>>>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>>>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>>>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip,
>>>>> id);
>>>>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>>>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>>>>          floatingIpApi.delete(ip.getId());
>>>>>       }
>>>>>       floatingIpCache.invalidate(id);
>>>>>       return id;
>>>>>    }
>>>>>
>>>>> As you can see, floatingIpApi.delete(ip.getId() will delete/release
>>>>> the IP.
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <
>>>>> nirmal070125@gmail.com> wrote:
>>>>>
>>>>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>>>>> check in Openstack and do anything.
>>>>>>
>>>>>> I think what we currently do is, let destroyNode disassociate the IP
>>>>>> from the instance and then only we would release the IP.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> I went though Jclouds code base and found that destroyNode() will
>>>>>>> deallocate and release(delete) all floating IPs associated with the
>>>>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>>>>
>>>>>>>    @Override
>>>>>>>    public void destroyNode(String id) {
>>>>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>>>>       if
>>>>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>>>>          try {
>>>>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>>>>          } catch (RuntimeException e) {
>>>>>>>             logger.warn(e, "<< error removing and deallocating ip
>>>>>>> from node(%s): %s", id, e.getMessage());
>>>>>>>          }
>>>>>>>       }
>>>>>>>
>>>>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>>>>    }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> And what we are doing is,
>>>>>>>
>>>>>>> // destroy the node  iaasProvider.getComputeService().
>>>>>>> destroyNode(nodeId);
>>>>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress()
>>>>>>> != null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>>>>> Calling release address after destroyNode() is not going to do
>>>>>>> anything. IPs are already released by destroyNode() method itself.
>>>>>>>
>>>>>>> Conclusion is, currently, when stratos terminates an instance it
>>>>>>> will release floating IPs allocated to this instance.
>>>>>>>
>>>>>>> We can improve it to not to release predefined floating IPs by
>>>>>>> disassociating the IP before calling destroyNode().
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I have commented out IP releasing code segment and unsubscribed
>>>>>>>>> from a cartridge. Floating IPs allocated to that instance were
>>>>>>>>> released(deleted). So I guess, Jclouds'
>>>>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>>>>> too.
>>>>>>>>>
>>>>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>>>>> the code @ [1].
>>>>>>>>>
>>>>>>>>> We can remove/disassociate the predefined floating IPs before
>>>>>>>>> calling destroying the node. It will ensure that predefined floating IPs
>>>>>>>>> will not be released, rather these will be detached from the instance.
>>>>>>>>>
>>>>>>>>> Or I guess we should be able to set a property to prevent
>>>>>>>>> releasing IPs when terminating instances. I sent a mail to jclouds user
>>>>>>>>> list.
>>>>>>>>>
>>>>>>>>> 1.
>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>>>>
>>>>>>>>> wdyt?
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>
>>>>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>>>>
>>>>>>>>>> This method either allocate an IP or using an available IP. So
>>>>>>>>>> what we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>>>>> available one right? Am I missing something here?
>>>>>>>>>>
>>>>>>>>>> 1.
>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi devs,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private
>>>>>>>>>>>>>> String allocatedIpAddress;
>>>>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> We are not exactly doing it. So when we associate an floating
>>>>>>>>>>>> IP to an instance, we are retrieving all the available floating IPs,
>>>>>>>>>>>> shuffle them and associate the last floating IP to the instance. If there
>>>>>>>>>>>> are no available floating IPs, we are allocating one and associate to the
>>>>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>>>>
>>>>>>>>>>>> My concern is that are we releasing predefined floating IPs
>>>>>>>>>>>> too? If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>>>>
>>>>>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>>>>>> predefined floating IPs?
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>>>>    /**
>>>>>>>>>>>>>>     * destroy the node, given its id. If it is the only node
>>>>>>>>>>>>>> in a tag set, the dependent resources
>>>>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>>>>     */
>>>>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>>>>> floating IPs?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Best Regards,
>>>>>>>>>>>>> Nirmal
>>>>>>>>>>>>>
>>>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Best Regards,
>>>>>>>>>>> Nirmal
>>>>>>>>>>>
>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>
>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best Regards,
>>>>>> Nirmal
>>>>>>
>>>>>> Nirmal Fernando.
>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>
>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Nirmal Fernando <ni...@gmail.com>.
On Fri, Nov 21, 2014 at 10:27 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> Yes Nirmal.
>
> There is a way.
>
> If we disassociate the floating IP before calling destroyNode(), it will
> not be released right?
>

Can you try and see.. I am not sure whether it'll work or not.

>
> So what I am suggesting is, for predefined floating IPs, we should
> disassociate the floating IPs before destroying the node.
>
> However, I might be wrong in going through the Jclouds code base. Please
> go through and verify it when you have time.
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 2:51 PM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>> Ok, thanks.. so what are you suggesting to do? Is there anyway to avoid
>> this deletion inside destroyNode?
>>
>> On Fri, Nov 21, 2014 at 10:08 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>> > wrote:
>>
>>> What EC2DestroyNodeStrategy#destroyNode() will do is;
>>>
>>>    @Override
>>>    public NodeMetadata destroyNode(String id) {
>>>       String[] parts = AWSUtils.parseHandle(id);
>>>       String region = parts[0];
>>>       String instanceId = parts[1];
>>>
>>>       // TODO: can there be multiple?
>>>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>>>       destroyInstanceInRegion(instanceId, region);
>>>       return getNode.getNode(id);
>>>    }
>>>
>>> Here also, it is releasing the IP.
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> What is there in that method is;
>>>>
>>>>    @Override
>>>>    public ZoneAndId apply(ZoneAndId id) {
>>>>       FloatingIPApi floatingIpApi =
>>>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip,
>>>> id);
>>>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>>>          floatingIpApi.delete(ip.getId());
>>>>       }
>>>>       floatingIpCache.invalidate(id);
>>>>       return id;
>>>>    }
>>>>
>>>> As you can see, floatingIpApi.delete(ip.getId() will delete/release the
>>>> IP.
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <
>>>> nirmal070125@gmail.com> wrote:
>>>>
>>>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>>>> check in Openstack and do anything.
>>>>>
>>>>> I think what we currently do is, let destroyNode disassociate the IP
>>>>> from the instance and then only we would release the IP.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> I went though Jclouds code base and found that destroyNode() will
>>>>>> deallocate and release(delete) all floating IPs associated with the
>>>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>>>
>>>>>>    @Override
>>>>>>    public void destroyNode(String id) {
>>>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>>>       if
>>>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>>>          try {
>>>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>>>          } catch (RuntimeException e) {
>>>>>>             logger.warn(e, "<< error removing and deallocating ip
>>>>>> from node(%s): %s", id, e.getMessage());
>>>>>>          }
>>>>>>       }
>>>>>>
>>>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>>>    }
>>>>>>
>>>>>>
>>>>>>
>>>>>> And what we are doing is,
>>>>>>
>>>>>> // destroy the node  iaasProvider.getComputeService().
>>>>>> destroyNode(nodeId);
>>>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress()
>>>>>> != null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>>>> Calling release address after destroyNode() is not going to do
>>>>>> anything. IPs are already released by destroyNode() method itself.
>>>>>>
>>>>>> Conclusion is, currently, when stratos terminates an instance it will
>>>>>> release floating IPs allocated to this instance.
>>>>>>
>>>>>> We can improve it to not to release predefined floating IPs by
>>>>>> disassociating the IP before calling destroyNode().
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have commented out IP releasing code segment and unsubscribed
>>>>>>>> from a cartridge. Floating IPs allocated to that instance were
>>>>>>>> released(deleted). So I guess, Jclouds'
>>>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>>>> too.
>>>>>>>>
>>>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>>>> the code @ [1].
>>>>>>>>
>>>>>>>> We can remove/disassociate the predefined floating IPs before
>>>>>>>> calling destroying the node. It will ensure that predefined floating IPs
>>>>>>>> will not be released, rather these will be detached from the instance.
>>>>>>>>
>>>>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>>>>
>>>>>>>> 1.
>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>>>
>>>>>>>> wdyt?
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Nirmal,
>>>>>>>>>
>>>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>>>
>>>>>>>>> This method either allocate an IP or using an available IP. So
>>>>>>>>> what we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>>>> available one right? Am I missing something here?
>>>>>>>>>
>>>>>>>>> 1.
>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi devs,
>>>>>>>>>>>>>
>>>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>>>
>>>>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private
>>>>>>>>>>>>> String allocatedIpAddress;
>>>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> We are not exactly doing it. So when we associate an floating IP
>>>>>>>>>>> to an instance, we are retrieving all the available floating IPs, shuffle
>>>>>>>>>>> them and associate the last floating IP to the instance. If there are no
>>>>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>>>
>>>>>>>>>>> My concern is that are we releasing predefined floating IPs too?
>>>>>>>>>>> If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>>>
>>>>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>>>>> predefined floating IPs?
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>>>    /**
>>>>>>>>>>>>>     * destroy the node, given its id. If it is the only node
>>>>>>>>>>>>> in a tag set, the dependent resources
>>>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>>>     */
>>>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>>>
>>>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>>>> floating IPs?
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Best Regards,
>>>>>>>>>>>> Nirmal
>>>>>>>>>>>>
>>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>>
>>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Best Regards,
>>>>>>>>>> Nirmal
>>>>>>>>>>
>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>
>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best Regards,
>>>>> Nirmal
>>>>>
>>>>> Nirmal Fernando.
>>>>> PPMC Member & Committer of Apache Stratos,
>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>
>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



-- 
Best Regards,
Nirmal

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

Blog: http://nirmalfdo.blogspot.com/

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Yes Nirmal.

There is a way.

If we disassociate the floating IP before calling destroyNode(), it will
not be released right?

So what I am suggesting is, for predefined floating IPs, we should
disassociate the floating IPs before destroying the node.

However, I might be wrong in going through the Jclouds code base. Please go
through and verify it when you have time.

Thanks.

On Fri, Nov 21, 2014 at 2:51 PM, Nirmal Fernando <ni...@gmail.com>
wrote:

> Ok, thanks.. so what are you suggesting to do? Is there anyway to avoid
> this deletion inside destroyNode?
>
> On Fri, Nov 21, 2014 at 10:08 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> What EC2DestroyNodeStrategy#destroyNode() will do is;
>>
>>    @Override
>>    public NodeMetadata destroyNode(String id) {
>>       String[] parts = AWSUtils.parseHandle(id);
>>       String region = parts[0];
>>       String instanceId = parts[1];
>>
>>       // TODO: can there be multiple?
>>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>>       destroyInstanceInRegion(instanceId, region);
>>       return getNode.getNode(id);
>>    }
>>
>> Here also, it is releasing the IP.
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>> What is there in that method is;
>>>
>>>    @Override
>>>    public ZoneAndId apply(ZoneAndId id) {
>>>       FloatingIPApi floatingIpApi =
>>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip,
>>> id);
>>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>>          floatingIpApi.delete(ip.getId());
>>>       }
>>>       floatingIpCache.invalidate(id);
>>>       return id;
>>>    }
>>>
>>> As you can see, floatingIpApi.delete(ip.getId() will delete/release the
>>> IP.
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <nirmal070125@gmail.com
>>> > wrote:
>>>
>>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>>> check in Openstack and do anything.
>>>>
>>>> I think what we currently do is, let destroyNode disassociate the IP
>>>> from the instance and then only we would release the IP.
>>>>
>>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> I went though Jclouds code base and found that destroyNode() will
>>>>> deallocate and release(delete) all floating IPs associated with the
>>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>>
>>>>>    @Override
>>>>>    public void destroyNode(String id) {
>>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>>       if
>>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>>          try {
>>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>>          } catch (RuntimeException e) {
>>>>>             logger.warn(e, "<< error removing and deallocating ip from
>>>>> node(%s): %s", id, e.getMessage());
>>>>>          }
>>>>>       }
>>>>>
>>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>>    }
>>>>>
>>>>>
>>>>>
>>>>> And what we are doing is,
>>>>>
>>>>> // destroy the node  iaasProvider.getComputeService().
>>>>> destroyNode(nodeId);
>>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>>>>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>>> Calling release address after destroyNode() is not going to do
>>>>> anything. IPs are already released by destroyNode() method itself.
>>>>>
>>>>> Conclusion is, currently, when stratos terminates an instance it will
>>>>> release floating IPs allocated to this instance.
>>>>>
>>>>> We can improve it to not to release predefined floating IPs by
>>>>> disassociating the IP before calling destroyNode().
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have commented out IP releasing code segment and unsubscribed from
>>>>>>> a cartridge. Floating IPs allocated to that instance were
>>>>>>> released(deleted). So I guess, Jclouds'
>>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>>> too.
>>>>>>>
>>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>>> the code @ [1].
>>>>>>>
>>>>>>> We can remove/disassociate the predefined floating IPs before
>>>>>>> calling destroying the node. It will ensure that predefined floating IPs
>>>>>>> will not be released, rather these will be detached from the instance.
>>>>>>>
>>>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>>>
>>>>>>> 1.
>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>>
>>>>>>> wdyt?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi Nirmal,
>>>>>>>>
>>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>>
>>>>>>>> This method either allocate an IP or using an available IP. So what
>>>>>>>> we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>>> available one right? Am I missing something here?
>>>>>>>>
>>>>>>>> 1.
>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi Nirmal,
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi devs,
>>>>>>>>>>>>
>>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>>
>>>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private
>>>>>>>>>>>> String allocatedIpAddress;
>>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>>
>>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> We are not exactly doing it. So when we associate an floating IP
>>>>>>>>>> to an instance, we are retrieving all the available floating IPs, shuffle
>>>>>>>>>> them and associate the last floating IP to the instance. If there are no
>>>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>>
>>>>>>>>>> My concern is that are we releasing predefined floating IPs too?
>>>>>>>>>> If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>>
>>>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>>>> predefined floating IPs?
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>>    /**
>>>>>>>>>>>>     * destroy the node, given its id. If it is the only node in
>>>>>>>>>>>> a tag set, the dependent resources
>>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>>     */
>>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>>
>>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>>
>>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>>> floating IPs?
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks.
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Best Regards,
>>>>>>>>>>> Nirmal
>>>>>>>>>>>
>>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>>
>>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Best Regards,
>>>>>>>>> Nirmal
>>>>>>>>>
>>>>>>>>> Nirmal Fernando.
>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>
>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Nirmal
>>>>
>>>> Nirmal Fernando.
>>>> PPMC Member & Committer of Apache Stratos,
>>>> Senior Software Engineer, WSO2 Inc.
>>>>
>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Nirmal Fernando <ni...@gmail.com>.
Ok, thanks.. so what are you suggesting to do? Is there anyway to avoid
this deletion inside destroyNode?

On Fri, Nov 21, 2014 at 10:08 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> What EC2DestroyNodeStrategy#destroyNode() will do is;
>
>    @Override
>    public NodeMetadata destroyNode(String id) {
>       String[] parts = AWSUtils.parseHandle(id);
>       String region = parts[0];
>       String instanceId = parts[1];
>
>       // TODO: can there be multiple?
>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>       destroyInstanceInRegion(instanceId, region);
>       return getNode.getNode(id);
>    }
>
> Here also, it is releasing the IP.
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> What is there in that method is;
>>
>>    @Override
>>    public ZoneAndId apply(ZoneAndId id) {
>>       FloatingIPApi floatingIpApi =
>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>          floatingIpApi.delete(ip.getId());
>>       }
>>       floatingIpCache.invalidate(id);
>>       return id;
>>    }
>>
>> As you can see, floatingIpApi.delete(ip.getId() will delete/release the
>> IP.
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <ni...@gmail.com>
>> wrote:
>>
>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>> check in Openstack and do anything.
>>>
>>> I think what we currently do is, let destroyNode disassociate the IP
>>> from the instance and then only we would release the IP.
>>>
>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> I went though Jclouds code base and found that destroyNode() will
>>>> deallocate and release(delete) all floating IPs associated with the
>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>
>>>>    @Override
>>>>    public void destroyNode(String id) {
>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>       if
>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>          try {
>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>          } catch (RuntimeException e) {
>>>>             logger.warn(e, "<< error removing and deallocating ip from
>>>> node(%s): %s", id, e.getMessage());
>>>>          }
>>>>       }
>>>>
>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>    }
>>>>
>>>>
>>>>
>>>> And what we are doing is,
>>>>
>>>> // destroy the node  iaasProvider.getComputeService().
>>>> destroyNode(nodeId);
>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>>>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>> Calling release address after destroyNode() is not going to do
>>>> anything. IPs are already released by destroyNode() method itself.
>>>>
>>>> Conclusion is, currently, when stratos terminates an instance it will
>>>> release floating IPs allocated to this instance.
>>>>
>>>> We can improve it to not to release predefined floating IPs by
>>>> disassociating the IP before calling destroyNode().
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have commented out IP releasing code segment and unsubscribed from
>>>>>> a cartridge. Floating IPs allocated to that instance were
>>>>>> released(deleted). So I guess, Jclouds'
>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>> too.
>>>>>>
>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>> the code @ [1].
>>>>>>
>>>>>> We can remove/disassociate the predefined floating IPs before calling
>>>>>> destroying the node. It will ensure that predefined floating IPs will not
>>>>>> be released, rather these will be detached from the instance.
>>>>>>
>>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>>
>>>>>> 1.
>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>
>>>>>> wdyt?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Hi Nirmal,
>>>>>>>
>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>
>>>>>>> This method either allocate an IP or using an available IP. So what
>>>>>>> we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>> available one right? Am I missing something here?
>>>>>>>
>>>>>>> 1.
>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>
>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Nirmal,
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi devs,
>>>>>>>>>>>
>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>
>>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private
>>>>>>>>>>> String allocatedIpAddress;
>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>
>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> We are not exactly doing it. So when we associate an floating IP
>>>>>>>>> to an instance, we are retrieving all the available floating IPs, shuffle
>>>>>>>>> them and associate the last floating IP to the instance. If there are no
>>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>
>>>>>>>>> My concern is that are we releasing predefined floating IPs too?
>>>>>>>>> If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>
>>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>>> predefined floating IPs?
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>    /**
>>>>>>>>>>>     * destroy the node, given its id. If it is the only node in
>>>>>>>>>>> a tag set, the dependent resources
>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>     */
>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>
>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>
>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>> floating IPs?
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Best Regards,
>>>>>>>>>> Nirmal
>>>>>>>>>>
>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>
>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Best Regards,
>>>>>>>> Nirmal
>>>>>>>>
>>>>>>>> Nirmal Fernando.
>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>
>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



-- 
Best Regards,
Nirmal

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

Blog: http://nirmalfdo.blogspot.com/

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
On Fri, Nov 21, 2014 at 2:38 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> What EC2DestroyNodeStrategy#destroyNode() will do is;
>
>    @Override
>    public NodeMetadata destroyNode(String id) {
>       String[] parts = AWSUtils.parseHandle(id);
>       String region = parts[0];
>       String instanceId = parts[1];
>
>       // TODO: can there be multiple?
>       releaseAnyPublicIpForInstanceInRegion(instanceId, region);
>       destroyInstanceInRegion(instanceId, region);
>       return getNode.getNode(id);
>    }
>

This is EC2. Previous one is Openstack.

Thanks.

>
> Here also, it is releasing the IP.
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> What is there in that method is;
>>
>>    @Override
>>    public ZoneAndId apply(ZoneAndId id) {
>>       FloatingIPApi floatingIpApi =
>> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
>>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>>          logger.debug(">> deallocating floatingIp(%s)", ip);
>>          floatingIpApi.delete(ip.getId());
>>       }
>>       floatingIpCache.invalidate(id);
>>       return id;
>>    }
>>
>> As you can see, floatingIpApi.delete(ip.getId() will delete/release the
>> IP.
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <ni...@gmail.com>
>> wrote:
>>
>>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>>> check in Openstack and do anything.
>>>
>>> I think what we currently do is, let destroyNode disassociate the IP
>>> from the instance and then only we would release the IP.
>>>
>>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> I went though Jclouds code base and found that destroyNode() will
>>>> deallocate and release(delete) all floating IPs associated with the
>>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>>
>>>>    @Override
>>>>    public void destroyNode(String id) {
>>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>>       if
>>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>>          try {
>>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>>          } catch (RuntimeException e) {
>>>>             logger.warn(e, "<< error removing and deallocating ip from
>>>> node(%s): %s", id, e.getMessage());
>>>>          }
>>>>       }
>>>>
>>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>>    }
>>>>
>>>>
>>>>
>>>> And what we are doing is,
>>>>
>>>> // destroy the node  iaasProvider.getComputeService().
>>>> destroyNode(nodeId);
>>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>>>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>>> Calling release address after destroyNode() is not going to do
>>>> anything. IPs are already released by destroyNode() method itself.
>>>>
>>>> Conclusion is, currently, when stratos terminates an instance it will
>>>> release floating IPs allocated to this instance.
>>>>
>>>> We can improve it to not to release predefined floating IPs by
>>>> disassociating the IP before calling destroyNode().
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have commented out IP releasing code segment and unsubscribed from
>>>>>> a cartridge. Floating IPs allocated to that instance were
>>>>>> released(deleted). So I guess, Jclouds'
>>>>>> BasicComputeService#destroyNode(String id) is releasing the floating IPs
>>>>>> too.
>>>>>>
>>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>>> the code @ [1].
>>>>>>
>>>>>> We can remove/disassociate the predefined floating IPs before calling
>>>>>> destroying the node. It will ensure that predefined floating IPs will not
>>>>>> be released, rather these will be detached from the instance.
>>>>>>
>>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>>
>>>>>> 1.
>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>>
>>>>>> wdyt?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Hi Nirmal,
>>>>>>>
>>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>>
>>>>>>> This method either allocate an IP or using an available IP. So what
>>>>>>> we setting to allocatedIPAddress can be either an allocated one or an
>>>>>>> available one right? Am I missing something here?
>>>>>>>
>>>>>>> 1.
>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>
>>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Nirmal,
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi devs,
>>>>>>>>>>>
>>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>>
>>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private
>>>>>>>>>>> String allocatedIpAddress;
>>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>>> all the public IPs.
>>>>>>>>>>>
>>>>>>>>>>> Predefined IPs should not released when terminating the
>>>>>>>>>>> instances right? Is this happening now? My predefined IP got released when
>>>>>>>>>>> I unsubscribed to the cartridge.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> We are not exactly doing it. So when we associate an floating IP
>>>>>>>>> to an instance, we are retrieving all the available floating IPs, shuffle
>>>>>>>>> them and associate the last floating IP to the instance. If there are no
>>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>>
>>>>>>>>> My concern is that are we releasing predefined floating IPs too?
>>>>>>>>> If so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>>
>>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>>> predefined floating IPs?
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>>    /**
>>>>>>>>>>>     * destroy the node, given its id. If it is the only node in
>>>>>>>>>>> a tag set, the dependent resources
>>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>>     */
>>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>>
>>>>>>>>>>> So I guess all the floating IPs associated with the ports of
>>>>>>>>>>> this node will also be released right?
>>>>>>>>>>>
>>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>>> floating IPs?
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Thanks.
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Best Regards,
>>>>>>>>>> Nirmal
>>>>>>>>>>
>>>>>>>>>> Nirmal Fernando.
>>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>>
>>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Best Regards,
>>>>>>>> Nirmal
>>>>>>>>
>>>>>>>> Nirmal Fernando.
>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>
>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
What EC2DestroyNodeStrategy#destroyNode() will do is;

   @Override
   public NodeMetadata destroyNode(String id) {
      String[] parts = AWSUtils.parseHandle(id);
      String region = parts[0];
      String instanceId = parts[1];

      // TODO: can there be multiple?
      releaseAnyPublicIpForInstanceInRegion(instanceId, region);
      destroyInstanceInRegion(instanceId, region);
      return getNode.getNode(id);
   }

Here also, it is releasing the IP.

Thanks.

On Fri, Nov 21, 2014 at 2:34 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> What is there in that method is;
>
>    @Override
>    public ZoneAndId apply(ZoneAndId id) {
>       FloatingIPApi floatingIpApi =
> novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
>       for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
>          logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
>          floatingIpApi.removeFromServer(ip.getIp(), id.getId());
>          logger.debug(">> deallocating floatingIp(%s)", ip);
>          floatingIpApi.delete(ip.getId());
>       }
>       floatingIpCache.invalidate(id);
>       return id;
>    }
>
> As you can see, floatingIpApi.delete(ip.getId() will delete/release the IP.
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate
>>  method? Also, we need to make sure all the IaaSes do this, we can't only
>> check in Openstack and do anything.
>>
>> I think what we currently do is, let destroyNode disassociate the IP from
>> the instance and then only we would release the IP.
>>
>> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>> I went though Jclouds code base and found that destroyNode() will
>>> deallocate and release(delete) all floating IPs associated with the
>>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>>
>>>    @Override
>>>    public void destroyNode(String id) {
>>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>>       if
>>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>>          try {
>>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>>          } catch (RuntimeException e) {
>>>             logger.warn(e, "<< error removing and deallocating ip from
>>> node(%s): %s", id, e.getMessage());
>>>          }
>>>       }
>>>
>>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>>    }
>>>
>>>
>>>
>>> And what we are doing is,
>>>
>>> // destroy the node  iaasProvider.getComputeService().
>>> destroyNode(nodeId);
>>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>>> Calling release address after destroyNode() is not going to do anything.
>>> IPs are already released by destroyNode() method itself.
>>>
>>> Conclusion is, currently, when stratos terminates an instance it will
>>> release floating IPs allocated to this instance.
>>>
>>> We can improve it to not to release predefined floating IPs by
>>> disassociating the IP before calling destroyNode().
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> Anyone tried with a predefined floating IP and got the floating IP
>>>> disassociated (not released) when unsubscribing to the cartridge?
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I have commented out IP releasing code segment and unsubscribed from a
>>>>> cartridge. Floating IPs allocated to that instance were released(deleted).
>>>>> So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
>>>>> releasing the floating IPs too.
>>>>>
>>>>> So predefined floating IPs will also be removed. The flow we are
>>>>> having is to destroy the node first and release the IPs then. Please refer
>>>>> the code @ [1].
>>>>>
>>>>> We can remove/disassociate the predefined floating IPs before calling
>>>>> destroying the node. It will ensure that predefined floating IPs will not
>>>>> be released, rather these will be detached from the instance.
>>>>>
>>>>> Or I guess we should be able to set a property to prevent releasing
>>>>> IPs when terminating instances. I sent a mail to jclouds user list.
>>>>>
>>>>> 1.
>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>>
>>>>> wdyt?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi Nirmal,
>>>>>>
>>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>>
>>>>>> This method either allocate an IP or using an available IP. So what
>>>>>> we setting to allocatedIPAddress can be either an allocated one or an
>>>>>> available one right? Am I missing something here?
>>>>>>
>>>>>> 1.
>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>
>>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi Nirmal,
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi devs,
>>>>>>>>>>
>>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>>
>>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>>>>>>> allocatedIpAddress;
>>>>>>>>>> I hope that the reason for having allocatedIpAddress is to
>>>>>>>>>> release it when terminating the instance. We are not releasing(deleting)
>>>>>>>>>> all the public IPs.
>>>>>>>>>>
>>>>>>>>>> Predefined IPs should not released when terminating the instances
>>>>>>>>>> right? Is this happening now? My predefined IP got released when I
>>>>>>>>>> unsubscribed to the cartridge.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>>
>>>>>>>>
>>>>>>>> We are not exactly doing it. So when we associate an floating IP to
>>>>>>>> an instance, we are retrieving all the available floating IPs, shuffle them
>>>>>>>> and associate the last floating IP to the instance. If there are no
>>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>>
>>>>>>>> My concern is that are we releasing predefined floating IPs too? If
>>>>>>>> so, the user will not able to unsubscribe and subscribe it to this
>>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>>
>>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>>> predefined floating IPs?
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Jclouds API doc;
>>>>>>>>>>    /**
>>>>>>>>>>     * destroy the node, given its id. If it is the only node in a
>>>>>>>>>> tag set, the dependent resources
>>>>>>>>>>     * will also be destroyed.
>>>>>>>>>>     */
>>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>>
>>>>>>>>>> So I guess all the floating IPs associated with the ports of this
>>>>>>>>>> node will also be released right?
>>>>>>>>>>
>>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>>> floating IPs?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks.
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Best Regards,
>>>>>>>>> Nirmal
>>>>>>>>>
>>>>>>>>> Nirmal Fernando.
>>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>>
>>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best Regards,
>>>>>>> Nirmal
>>>>>>>
>>>>>>> Nirmal Fernando.
>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>
>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
What is there in that method is;

   @Override
   public ZoneAndId apply(ZoneAndId id) {
      FloatingIPApi floatingIpApi =
novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
      for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
         logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
         floatingIpApi.removeFromServer(ip.getIp(), id.getId());
         logger.debug(">> deallocating floatingIp(%s)", ip);
         floatingIpApi.delete(ip.getId());
      }
      floatingIpCache.invalidate(id);
      return id;
   }

As you can see, floatingIpApi.delete(ip.getId() will delete/release the IP.

Thanks.

On Fri, Nov 21, 2014 at 2:30 PM, Nirmal Fernando <ni...@gmail.com>
wrote:

> Do they delete IP from the removeFloatingIpFromNodeAndDeallocate  method?
> Also, we need to make sure all the IaaSes do this, we can't only check in
> Openstack and do anything.
>
> I think what we currently do is, let destroyNode disassociate the IP from
> the instance and then only we would release the IP.
>
> On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> I went though Jclouds code base and found that destroyNode() will
>> deallocate and release(delete) all floating IPs associated with the
>> instance. The following method is  in the NovaComputeServiceAdapter class.
>>
>>    @Override
>>    public void destroyNode(String id) {
>>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>>       if
>> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>>          try {
>>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>>          } catch (RuntimeException e) {
>>             logger.warn(e, "<< error removing and deallocating ip from
>> node(%s): %s", id, e.getMessage());
>>          }
>>       }
>>
>> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>>    }
>>
>>
>>
>> And what we are doing is,
>>
>> // destroy the node  iaasProvider.getComputeService().
>> destroyNode(nodeId);
>>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
>> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
>> Calling release address after destroyNode() is not going to do anything.
>> IPs are already released by destroyNode() method itself.
>>
>> Conclusion is, currently, when stratos terminates an instance it will
>> release floating IPs allocated to this instance.
>>
>> We can improve it to not to release predefined floating IPs by
>> disassociating the IP before calling destroyNode().
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>> Anyone tried with a predefined floating IP and got the floating IP
>>> disassociated (not released) when unsubscribing to the cartridge?
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <
>>> rajkumarr@wso2.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I have commented out IP releasing code segment and unsubscribed from a
>>>> cartridge. Floating IPs allocated to that instance were released(deleted).
>>>> So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
>>>> releasing the floating IPs too.
>>>>
>>>> So predefined floating IPs will also be removed. The flow we are having
>>>> is to destroy the node first and release the IPs then. Please refer the
>>>> code @ [1].
>>>>
>>>> We can remove/disassociate the predefined floating IPs before calling
>>>> destroying the node. It will ensure that predefined floating IPs will not
>>>> be released, rather these will be detached from the instance.
>>>>
>>>> Or I guess we should be able to set a property to prevent releasing IPs
>>>> when terminating instances. I sent a mail to jclouds user list.
>>>>
>>>> 1.
>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>>
>>>> wdyt?
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Hi Nirmal,
>>>>>
>>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>>
>>>>> This method either allocate an IP or using an available IP. So what we
>>>>> setting to allocatedIPAddress can be either an allocated one or an
>>>>> available one right? Am I missing something here?
>>>>>
>>>>> 1.
>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>>> nirmal070125@gmail.com> wrote:
>>>>>
>>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Hi Nirmal,
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>>
>>>>>>>>> Hi devs,
>>>>>>>>>
>>>>>>>>> We have the following fields in Member Context;
>>>>>>>>>
>>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>>>>>> allocatedIpAddress;
>>>>>>>>> I hope that the reason for having allocatedIpAddress is to release
>>>>>>>>> it when terminating the instance. We are not releasing(deleting) all the
>>>>>>>>> public IPs.
>>>>>>>>>
>>>>>>>>> Predefined IPs should not released when terminating the instances
>>>>>>>>> right? Is this happening now? My predefined IP got released when I
>>>>>>>>> unsubscribed to the cartridge.
>>>>>>>>>
>>>>>>>>
>>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>>
>>>>>>>
>>>>>>> We are not exactly doing it. So when we associate an floating IP to
>>>>>>> an instance, we are retrieving all the available floating IPs, shuffle them
>>>>>>> and associate the last floating IP to the instance. If there are no
>>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>>> them. But that is not a harm. That is another problem.
>>>>>>>
>>>>>>> My concern is that are we releasing predefined floating IPs too? If
>>>>>>> so, the user will not able to unsubscribe and subscribe it to this
>>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>>
>>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>>> predefined floating IPs?
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>>>
>>>>>>>>> Jclouds API doc;
>>>>>>>>>    /**
>>>>>>>>>     * destroy the node, given its id. If it is the only node in a
>>>>>>>>> tag set, the dependent resources
>>>>>>>>>     * will also be destroyed.
>>>>>>>>>     */
>>>>>>>>>    void destroyNode(String id);
>>>>>>>>>
>>>>>>>>> So I guess all the floating IPs associated with the ports of this
>>>>>>>>> node will also be released right?
>>>>>>>>>
>>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>>> floating IPs?
>>>>>>>>>
>>>>>>>>
>>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Rajkumar Rajaratnam
>>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>>> Software Engineer, WSO2
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Best Regards,
>>>>>>>> Nirmal
>>>>>>>>
>>>>>>>> Nirmal Fernando.
>>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>>
>>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best Regards,
>>>>>> Nirmal
>>>>>>
>>>>>> Nirmal Fernando.
>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>
>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Nirmal Fernando <ni...@gmail.com>.
Do they delete IP from the removeFloatingIpFromNodeAndDeallocate  method?
Also, we need to make sure all the IaaSes do this, we can't only check in
Openstack and do anything.

I think what we currently do is, let destroyNode disassociate the IP from
the instance and then only we would release the IP.

On Fri, Nov 21, 2014 at 9:49 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> I went though Jclouds code base and found that destroyNode() will
> deallocate and release(delete) all floating IPs associated with the
> instance. The following method is  in the NovaComputeServiceAdapter class.
>
>    @Override
>    public void destroyNode(String id) {
>       ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
>       if
> (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
>          try {
>             removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
>          } catch (RuntimeException e) {
>             logger.warn(e, "<< error removing and deallocating ip from
> node(%s): %s", id, e.getMessage());
>          }
>       }
>
> novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
>    }
>
>
>
> And what we are doing is,
>
> // destroy the node  iaasProvider.getComputeService().destroyNode(nodeId);
>   // release allocated IP address  if (ctxt.getAllocatedIpAddress() !=
> null) {  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
> Calling release address after destroyNode() is not going to do anything.
> IPs are already released by destroyNode() method itself.
>
> Conclusion is, currently, when stratos terminates an instance it will
> release floating IPs allocated to this instance.
>
> We can improve it to not to release predefined floating IPs by
> disassociating the IP before calling destroyNode().
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Anyone tried with a predefined floating IP and got the floating IP
>> disassociated (not released) when unsubscribing to the cartridge?
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>> > wrote:
>>
>>> Hi,
>>>
>>> I have commented out IP releasing code segment and unsubscribed from a
>>> cartridge. Floating IPs allocated to that instance were released(deleted).
>>> So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
>>> releasing the floating IPs too.
>>>
>>> So predefined floating IPs will also be removed. The flow we are having
>>> is to destroy the node first and release the IPs then. Please refer the
>>> code @ [1].
>>>
>>> We can remove/disassociate the predefined floating IPs before calling
>>> destroying the node. It will ensure that predefined floating IPs will not
>>> be released, rather these will be detached from the instance.
>>>
>>> Or I guess we should be able to set a property to prevent releasing IPs
>>> when terminating instances. I sent a mail to jclouds user list.
>>>
>>> 1.
>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>>
>>> wdyt?
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <
>>> rajkumarr@wso2.com> wrote:
>>>
>>>> Hi Nirmal,
>>>>
>>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>>
>>>> This method either allocate an IP or using an available IP. So what we
>>>> setting to allocatedIPAddress can be either an allocated one or an
>>>> available one right? Am I missing something here?
>>>>
>>>> 1.
>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>>
>>>> Thanks.
>>>>
>>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>>> nirmal070125@gmail.com> wrote:
>>>>
>>>>> We shouldn't be releasing the non-allocated IPs. Since you are
>>>>> claiming that we are doing so, I had a look at the code, but I see only
>>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>>> where we set allocated IP to member context. So, only that IP should have
>>>>> been released. Isn't it the case? Please point to code segments.
>>>>>
>>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi Nirmal,
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>> nirmal070125@gmail.com> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi devs,
>>>>>>>>
>>>>>>>> We have the following fields in Member Context;
>>>>>>>>
>>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>>>>> allocatedIpAddress;
>>>>>>>> I hope that the reason for having allocatedIpAddress is to release
>>>>>>>> it when terminating the instance. We are not releasing(deleting) all the
>>>>>>>> public IPs.
>>>>>>>>
>>>>>>>> Predefined IPs should not released when terminating the instances
>>>>>>>> right? Is this happening now? My predefined IP got released when I
>>>>>>>> unsubscribed to the cartridge.
>>>>>>>>
>>>>>>>
>>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>>
>>>>>>
>>>>>> We are not exactly doing it. So when we associate an floating IP to
>>>>>> an instance, we are retrieving all the available floating IPs, shuffle them
>>>>>> and associate the last floating IP to the instance. If there are no
>>>>>> available floating IPs, we are allocating one and associate to the
>>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>>> them. But that is not a harm. That is another problem.
>>>>>>
>>>>>> My concern is that are we releasing predefined floating IPs too? If
>>>>>> so, the user will not able to unsubscribe and subscribe it to this
>>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>>> that IP in cartridge json. I feel this is not good .
>>>>>>
>>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>>> predefined floating IPs?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>>>
>>>>>>>> Jclouds API doc;
>>>>>>>>    /**
>>>>>>>>     * destroy the node, given its id. If it is the only node in a
>>>>>>>> tag set, the dependent resources
>>>>>>>>     * will also be destroyed.
>>>>>>>>     */
>>>>>>>>    void destroyNode(String id);
>>>>>>>>
>>>>>>>> So I guess all the floating IPs associated with the ports of this
>>>>>>>> node will also be released right?
>>>>>>>>
>>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>>> floating IPs?
>>>>>>>>
>>>>>>>
>>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>>
>>>>>>>>
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> --
>>>>>>>> Rajkumar Rajaratnam
>>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>>> Software Engineer, WSO2
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best Regards,
>>>>>>> Nirmal
>>>>>>>
>>>>>>> Nirmal Fernando.
>>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>>
>>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best Regards,
>>>>> Nirmal
>>>>>
>>>>> Nirmal Fernando.
>>>>> PPMC Member & Committer of Apache Stratos,
>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>
>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



-- 
Best Regards,
Nirmal

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

Blog: http://nirmalfdo.blogspot.com/

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
I went though Jclouds code base and found that destroyNode() will
deallocate and release(delete) all floating IPs associated with the
instance. The following method is  in the NovaComputeServiceAdapter class.

   @Override
   public void destroyNode(String id) {
      ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
      if
(novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
         try {
            removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
         } catch (RuntimeException e) {
            logger.warn(e, "<< error removing and deallocating ip from
node(%s): %s", id, e.getMessage());
         }
      }

novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
   }



And what we are doing is,

// destroy the node  iaasProvider.getComputeService().destroyNode(nodeId);
  // release allocated IP address  if (ctxt.getAllocatedIpAddress() != null)
{  iaas.releaseAddress(ctxt.getAllocatedIpAddress());  }
Calling release address after destroyNode() is not going to do anything.
IPs are already released by destroyNode() method itself.

Conclusion is, currently, when stratos terminates an instance it will
release floating IPs allocated to this instance.

We can improve it to not to release predefined floating IPs by
disassociating the IP before calling destroyNode().

Thanks.

On Fri, Nov 21, 2014 at 1:26 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> Anyone tried with a predefined floating IP and got the floating IP
> disassociated (not released) when unsubscribing to the cartridge?
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Hi,
>>
>> I have commented out IP releasing code segment and unsubscribed from a
>> cartridge. Floating IPs allocated to that instance were released(deleted).
>> So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
>> releasing the floating IPs too.
>>
>> So predefined floating IPs will also be removed. The flow we are having
>> is to destroy the node first and release the IPs then. Please refer the
>> code @ [1].
>>
>> We can remove/disassociate the predefined floating IPs before calling
>> destroying the node. It will ensure that predefined floating IPs will not
>> be released, rather these will be detached from the instance.
>>
>> Or I guess we should be able to set a property to prevent releasing IPs
>> when terminating instances. I sent a mail to jclouds user list.
>>
>> 1.
>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>>
>> wdyt?
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>> > wrote:
>>
>>> Hi Nirmal,
>>>
>>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>>
>>> This method either allocate an IP or using an available IP. So what we
>>> setting to allocatedIPAddress can be either an allocated one or an
>>> available one right? Am I missing something here?
>>>
>>> 1.
>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>>
>>> Thanks.
>>>
>>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <
>>> nirmal070125@gmail.com> wrote:
>>>
>>>> We shouldn't be releasing the non-allocated IPs. Since you are claiming
>>>> that we are doing so, I had a look at the code, but I see only
>>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>>> where we set allocated IP to member context. So, only that IP should have
>>>> been released. Isn't it the case? Please point to code segments.
>>>>
>>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Hi Nirmal,
>>>>>
>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>> nirmal070125@gmail.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>> rajkumarr@wso2.com> wrote:
>>>>>>
>>>>>>> Hi devs,
>>>>>>>
>>>>>>> We have the following fields in Member Context;
>>>>>>>
>>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>>>> allocatedIpAddress;
>>>>>>> I hope that the reason for having allocatedIpAddress is to release
>>>>>>> it when terminating the instance. We are not releasing(deleting) all the
>>>>>>> public IPs.
>>>>>>>
>>>>>>> Predefined IPs should not released when terminating the instances
>>>>>>> right? Is this happening now? My predefined IP got released when I
>>>>>>> unsubscribed to the cartridge.
>>>>>>>
>>>>>>
>>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>>
>>>>>
>>>>> We are not exactly doing it. So when we associate an floating IP to an
>>>>> instance, we are retrieving all the available floating IPs, shuffle them
>>>>> and associate the last floating IP to the instance. If there are no
>>>>> available floating IPs, we are allocating one and associate to the
>>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>>> them. But that is not a harm. That is another problem.
>>>>>
>>>>> My concern is that are we releasing predefined floating IPs too? If
>>>>> so, the user will not able to unsubscribe and subscribe it to this
>>>>> cartridge again. Since the IP is not there, stratos will raise an error.
>>>>> Then he has to manually allocate a floating IP in openstack and then use
>>>>> that IP in cartridge json. I feel this is not good .
>>>>>
>>>>> What I wanted to know is, are we releasing or not releasing the
>>>>> predefined floating IPs?
>>>>>
>>>>> Thanks.
>>>>>
>>>>>>
>>>>>>> Jclouds API doc;
>>>>>>>    /**
>>>>>>>     * destroy the node, given its id. If it is the only node in a
>>>>>>> tag set, the dependent resources
>>>>>>>     * will also be destroyed.
>>>>>>>     */
>>>>>>>    void destroyNode(String id);
>>>>>>>
>>>>>>> So I guess all the floating IPs associated with the ports of this
>>>>>>> node will also be released right?
>>>>>>>
>>>>>>> Or can we set any property to prevent Jclouds from releasing
>>>>>>> floating IPs?
>>>>>>>
>>>>>>
>>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>>
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> --
>>>>>>> Rajkumar Rajaratnam
>>>>>>> Committer & PMC Member, Apache Stratos
>>>>>>> Software Engineer, WSO2
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Best Regards,
>>>>>> Nirmal
>>>>>>
>>>>>> Nirmal Fernando.
>>>>>> PPMC Member & Committer of Apache Stratos,
>>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>>
>>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Nirmal
>>>>
>>>> Nirmal Fernando.
>>>> PPMC Member & Committer of Apache Stratos,
>>>> Senior Software Engineer, WSO2 Inc.
>>>>
>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Anyone tried with a predefined floating IP and got the floating IP
disassociated (not released) when unsubscribing to the cartridge?

Thanks.

On Fri, Nov 21, 2014 at 12:44 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> Hi,
>
> I have commented out IP releasing code segment and unsubscribed from a
> cartridge. Floating IPs allocated to that instance were released(deleted).
> So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
> releasing the floating IPs too.
>
> So predefined floating IPs will also be removed. The flow we are having is
> to destroy the node first and release the IPs then. Please refer the code @
> [1].
>
> We can remove/disassociate the predefined floating IPs before calling
> destroying the node. It will ensure that predefined floating IPs will not
> be released, rather these will be detached from the instance.
>
> Or I guess we should be able to set a property to prevent releasing IPs
> when terminating instances. I sent a mail to jclouds user list.
>
> 1.
> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996
>
> wdyt?
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Hi Nirmal,
>>
>> Please have a look at associateAddress(NodeMetadata node) @ [1].
>>
>> This method either allocate an IP or using an available IP. So what we
>> setting to allocatedIPAddress can be either an allocated one or an
>> available one right? Am I missing something here?
>>
>> 1.
>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>>
>> Thanks.
>>
>> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <nirmal070125@gmail.com
>> > wrote:
>>
>>> We shouldn't be releasing the non-allocated IPs. Since you are claiming
>>> that we are doing so, I had a look at the code, but I see only
>>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>>> where we set allocated IP to member context. So, only that IP should have
>>> been released. Isn't it the case? Please point to code segments.
>>>
>>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> Hi Nirmal,
>>>>
>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>> nirmal070125@gmail.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>> rajkumarr@wso2.com> wrote:
>>>>>
>>>>>> Hi devs,
>>>>>>
>>>>>> We have the following fields in Member Context;
>>>>>>
>>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>>> allocatedIpAddress;
>>>>>> I hope that the reason for having allocatedIpAddress is to release it
>>>>>> when terminating the instance. We are not releasing(deleting) all the
>>>>>> public IPs.
>>>>>>
>>>>>> Predefined IPs should not released when terminating the instances
>>>>>> right? Is this happening now? My predefined IP got released when I
>>>>>> unsubscribed to the cartridge.
>>>>>>
>>>>>
>>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>>
>>>>
>>>> We are not exactly doing it. So when we associate an floating IP to an
>>>> instance, we are retrieving all the available floating IPs, shuffle them
>>>> and associate the last floating IP to the instance. If there are no
>>>> available floating IPs, we are allocating one and associate to the
>>>> instance. These two scenario is considered as allocated IPs in stratos.
>>>> What I meant here is that, we are putting IPs from these two scenario into
>>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>>> It means we are sometimes releasing IPs even though we didn't allocate
>>>> them. But that is not a harm. That is another problem.
>>>>
>>>> My concern is that are we releasing predefined floating IPs too? If so,
>>>> the user will not able to unsubscribe and subscribe it to this cartridge
>>>> again. Since the IP is not there, stratos will raise an error. Then he has
>>>> to manually allocate a floating IP in openstack and then use that IP in
>>>> cartridge json. I feel this is not good .
>>>>
>>>> What I wanted to know is, are we releasing or not releasing the
>>>> predefined floating IPs?
>>>>
>>>> Thanks.
>>>>
>>>>>
>>>>>> Jclouds API doc;
>>>>>>    /**
>>>>>>     * destroy the node, given its id. If it is the only node in a tag
>>>>>> set, the dependent resources
>>>>>>     * will also be destroyed.
>>>>>>     */
>>>>>>    void destroyNode(String id);
>>>>>>
>>>>>> So I guess all the floating IPs associated with the ports of this
>>>>>> node will also be released right?
>>>>>>
>>>>>> Or can we set any property to prevent Jclouds from releasing floating
>>>>>> IPs?
>>>>>>
>>>>>
>>>>> Please raise this in Jclouds user list and get clarified.
>>>>>
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Committer & PMC Member, Apache Stratos
>>>>>> Software Engineer, WSO2
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best Regards,
>>>>> Nirmal
>>>>>
>>>>> Nirmal Fernando.
>>>>> PPMC Member & Committer of Apache Stratos,
>>>>> Senior Software Engineer, WSO2 Inc.
>>>>>
>>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Hi,

I have commented out IP releasing code segment and unsubscribed from a
cartridge. Floating IPs allocated to that instance were released(deleted).
So I guess, Jclouds' BasicComputeService#destroyNode(String id) is
releasing the floating IPs too.

So predefined floating IPs will also be removed. The flow we are having is
to destroy the node first and release the IPs then. Please refer the code @
[1].

We can remove/disassociate the predefined floating IPs before calling
destroying the node. It will ensure that predefined floating IPs will not
be released, rather these will be detached from the instance.

Or I guess we should be able to set a property to prevent releasing IPs
when terminating instances. I sent a mail to jclouds user list.

1.
https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L986-996

wdyt?

Thanks.

On Fri, Nov 21, 2014 at 12:21 PM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> Hi Nirmal,
>
> Please have a look at associateAddress(NodeMetadata node) @ [1].
>
> This method either allocate an IP or using an available IP. So what we
> setting to allocatedIPAddress can be either an allocated one or an
> available one right? Am I missing something here?
>
> 1.
> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298
>
> Thanks.
>
> On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>> We shouldn't be releasing the non-allocated IPs. Since you are claiming
>> that we are doing so, I had a look at the code, but I see only
>> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
>> where we set allocated IP to member context. So, only that IP should have
>> been released. Isn't it the case? Please point to code segments.
>>
>> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>> Hi Nirmal,
>>>
>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>> nirmal070125@gmail.com> wrote:
>>>
>>>>
>>>>
>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>> rajkumarr@wso2.com> wrote:
>>>>
>>>>> Hi devs,
>>>>>
>>>>> We have the following fields in Member Context;
>>>>>
>>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>>> String publicIpAddress;  // manually allocated ip  private String
>>>>> allocatedIpAddress;
>>>>> I hope that the reason for having allocatedIpAddress is to release it
>>>>> when terminating the instance. We are not releasing(deleting) all the
>>>>> public IPs.
>>>>>
>>>>> Predefined IPs should not released when terminating the instances
>>>>> right? Is this happening now? My predefined IP got released when I
>>>>> unsubscribed to the cartridge.
>>>>>
>>>>
>>>> AFAIK we have to release an IP, only if we allocate manually.
>>>>
>>>
>>> We are not exactly doing it. So when we associate an floating IP to an
>>> instance, we are retrieving all the available floating IPs, shuffle them
>>> and associate the last floating IP to the instance. If there are no
>>> available floating IPs, we are allocating one and associate to the
>>> instance. These two scenario is considered as allocated IPs in stratos.
>>> What I meant here is that, we are putting IPs from these two scenario into
>>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>>> It means we are sometimes releasing IPs even though we didn't allocate
>>> them. But that is not a harm. That is another problem.
>>>
>>> My concern is that are we releasing predefined floating IPs too? If so,
>>> the user will not able to unsubscribe and subscribe it to this cartridge
>>> again. Since the IP is not there, stratos will raise an error. Then he has
>>> to manually allocate a floating IP in openstack and then use that IP in
>>> cartridge json. I feel this is not good .
>>>
>>> What I wanted to know is, are we releasing or not releasing the
>>> predefined floating IPs?
>>>
>>> Thanks.
>>>
>>>>
>>>>> Jclouds API doc;
>>>>>    /**
>>>>>     * destroy the node, given its id. If it is the only node in a tag
>>>>> set, the dependent resources
>>>>>     * will also be destroyed.
>>>>>     */
>>>>>    void destroyNode(String id);
>>>>>
>>>>> So I guess all the floating IPs associated with the ports of this node
>>>>> will also be released right?
>>>>>
>>>>> Or can we set any property to prevent Jclouds from releasing floating
>>>>> IPs?
>>>>>
>>>>
>>>> Please raise this in Jclouds user list and get clarified.
>>>>
>>>>>
>>>>> Thanks.
>>>>>
>>>>> --
>>>>> Rajkumar Rajaratnam
>>>>> Committer & PMC Member, Apache Stratos
>>>>> Software Engineer, WSO2
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Nirmal
>>>>
>>>> Nirmal Fernando.
>>>> PPMC Member & Committer of Apache Stratos,
>>>> Senior Software Engineer, WSO2 Inc.
>>>>
>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Hi Nirmal,

Please have a look at associateAddress(NodeMetadata node) @ [1].

This method either allocate an IP or using an available IP. So what we
setting to allocatedIPAddress can be either an allocated one or an
available one right? Am I missing something here?

1.
https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java#L219-298

Thanks.

On Fri, Nov 21, 2014 at 12:14 PM, Nirmal Fernando <ni...@gmail.com>
wrote:

> We shouldn't be releasing the non-allocated IPs. Since you are claiming
> that we are doing so, I had a look at the code, but I see only
> https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
> where we set allocated IP to member context. So, only that IP should have
> been released. Isn't it the case? Please point to code segments.
>
> On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Hi Nirmal,
>>
>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <nirmal070125@gmail.com
>> > wrote:
>>
>>>
>>>
>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <rajkumarr@wso2.com
>>> > wrote:
>>>
>>>> Hi devs,
>>>>
>>>> We have the following fields in Member Context;
>>>>
>>>> // private ip  private String privateIpAddress;  // public ip  private
>>>> String publicIpAddress;  // manually allocated ip  private String
>>>> allocatedIpAddress;
>>>> I hope that the reason for having allocatedIpAddress is to release it
>>>> when terminating the instance. We are not releasing(deleting) all the
>>>> public IPs.
>>>>
>>>> Predefined IPs should not released when terminating the instances
>>>> right? Is this happening now? My predefined IP got released when I
>>>> unsubscribed to the cartridge.
>>>>
>>>
>>> AFAIK we have to release an IP, only if we allocate manually.
>>>
>>
>> We are not exactly doing it. So when we associate an floating IP to an
>> instance, we are retrieving all the available floating IPs, shuffle them
>> and associate the last floating IP to the instance. If there are no
>> available floating IPs, we are allocating one and associate to the
>> instance. These two scenario is considered as allocated IPs in stratos.
>> What I meant here is that, we are putting IPs from these two scenario into
>> allocatedIpAddress. So when terminate the instance, we are releasing these.
>> It means we are sometimes releasing IPs even though we didn't allocate
>> them. But that is not a harm. That is another problem.
>>
>> My concern is that are we releasing predefined floating IPs too? If so,
>> the user will not able to unsubscribe and subscribe it to this cartridge
>> again. Since the IP is not there, stratos will raise an error. Then he has
>> to manually allocate a floating IP in openstack and then use that IP in
>> cartridge json. I feel this is not good .
>>
>> What I wanted to know is, are we releasing or not releasing the
>> predefined floating IPs?
>>
>> Thanks.
>>
>>>
>>>> Jclouds API doc;
>>>>    /**
>>>>     * destroy the node, given its id. If it is the only node in a tag
>>>> set, the dependent resources
>>>>     * will also be destroyed.
>>>>     */
>>>>    void destroyNode(String id);
>>>>
>>>> So I guess all the floating IPs associated with the ports of this node
>>>> will also be released right?
>>>>
>>>> Or can we set any property to prevent Jclouds from releasing floating
>>>> IPs?
>>>>
>>>
>>> Please raise this in Jclouds user list and get clarified.
>>>
>>>>
>>>> Thanks.
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Committer & PMC Member, Apache Stratos
>>>> Software Engineer, WSO2
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Nirmal Fernando <ni...@gmail.com>.
We shouldn't be releasing the non-allocated IPs. Since you are claiming
that we are doing so, I had a look at the code, but I see only
https://github.com/apache/stratos/blob/master/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java#L842
where we set allocated IP to member context. So, only that IP should have
been released. Isn't it the case? Please point to code segments.

On Fri, Nov 21, 2014 at 7:34 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> Hi Nirmal,
>
> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>>
>>
>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <ra...@wso2.com>
>> wrote:
>>
>>> Hi devs,
>>>
>>> We have the following fields in Member Context;
>>>
>>> // private ip  private String privateIpAddress;  // public ip  private
>>> String publicIpAddress;  // manually allocated ip  private String
>>> allocatedIpAddress;
>>> I hope that the reason for having allocatedIpAddress is to release it
>>> when terminating the instance. We are not releasing(deleting) all the
>>> public IPs.
>>>
>>> Predefined IPs should not released when terminating the instances right?
>>> Is this happening now? My predefined IP got released when I unsubscribed to
>>> the cartridge.
>>>
>>
>> AFAIK we have to release an IP, only if we allocate manually.
>>
>
> We are not exactly doing it. So when we associate an floating IP to an
> instance, we are retrieving all the available floating IPs, shuffle them
> and associate the last floating IP to the instance. If there are no
> available floating IPs, we are allocating one and associate to the
> instance. These two scenario is considered as allocated IPs in stratos.
> What I meant here is that, we are putting IPs from these two scenario into
> allocatedIpAddress. So when terminate the instance, we are releasing these.
> It means we are sometimes releasing IPs even though we didn't allocate
> them. But that is not a harm. That is another problem.
>
> My concern is that are we releasing predefined floating IPs too? If so,
> the user will not able to unsubscribe and subscribe it to this cartridge
> again. Since the IP is not there, stratos will raise an error. Then he has
> to manually allocate a floating IP in openstack and then use that IP in
> cartridge json. I feel this is not good .
>
> What I wanted to know is, are we releasing or not releasing the predefined
> floating IPs?
>
> Thanks.
>
>>
>>> Jclouds API doc;
>>>    /**
>>>     * destroy the node, given its id. If it is the only node in a tag
>>> set, the dependent resources
>>>     * will also be destroyed.
>>>     */
>>>    void destroyNode(String id);
>>>
>>> So I guess all the floating IPs associated with the ports of this node
>>> will also be released right?
>>>
>>> Or can we set any property to prevent Jclouds from releasing floating
>>> IPs?
>>>
>>
>> Please raise this in Jclouds user list and get clarified.
>>
>>>
>>> Thanks.
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Committer & PMC Member, Apache Stratos
>>> Software Engineer, WSO2
>>>
>>
>>
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> Rajkumar Rajaratnam
> Committer & PMC Member, Apache Stratos
> Software Engineer, WSO2
>



-- 
Best Regards,
Nirmal

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

Blog: http://nirmalfdo.blogspot.com/

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Rajkumar Rajaratnam <ra...@wso2.com>.
Hi Nirmal,

On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <ni...@gmail.com>
wrote:

>
>
> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <ra...@wso2.com>
> wrote:
>
>> Hi devs,
>>
>> We have the following fields in Member Context;
>>
>> // private ip  private String privateIpAddress;  // public ip  private
>> String publicIpAddress;  // manually allocated ip  private String
>> allocatedIpAddress;
>> I hope that the reason for having allocatedIpAddress is to release it
>> when terminating the instance. We are not releasing(deleting) all the
>> public IPs.
>>
>> Predefined IPs should not released when terminating the instances right?
>> Is this happening now? My predefined IP got released when I unsubscribed to
>> the cartridge.
>>
>
> AFAIK we have to release an IP, only if we allocate manually.
>

We are not exactly doing it. So when we associate an floating IP to an
instance, we are retrieving all the available floating IPs, shuffle them
and associate the last floating IP to the instance. If there are no
available floating IPs, we are allocating one and associate to the
instance. These two scenario is considered as allocated IPs in stratos.
What I meant here is that, we are putting IPs from these two scenario into
allocatedIpAddress. So when terminate the instance, we are releasing these.
It means we are sometimes releasing IPs even though we didn't allocate
them. But that is not a harm. That is another problem.

My concern is that are we releasing predefined floating IPs too? If so, the
user will not able to unsubscribe and subscribe it to this cartridge again.
Since the IP is not there, stratos will raise an error. Then he has to
manually allocate a floating IP in openstack and then use that IP in
cartridge json. I feel this is not good .

What I wanted to know is, are we releasing or not releasing the predefined
floating IPs?

Thanks.

>
>> Jclouds API doc;
>>    /**
>>     * destroy the node, given its id. If it is the only node in a tag
>> set, the dependent resources
>>     * will also be destroyed.
>>     */
>>    void destroyNode(String id);
>>
>> So I guess all the floating IPs associated with the ports of this node
>> will also be released right?
>>
>> Or can we set any property to prevent Jclouds from releasing floating IPs?
>>
>
> Please raise this in Jclouds user list and get clarified.
>
>>
>> Thanks.
>>
>> --
>> Rajkumar Rajaratnam
>> Committer & PMC Member, Apache Stratos
>> Software Engineer, WSO2
>>
>
>
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



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

Re: Stratos should not release(delete) predefined floating IPs?

Posted by Nirmal Fernando <ni...@gmail.com>.
On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <ra...@wso2.com>
wrote:

> Hi devs,
>
> We have the following fields in Member Context;
>
> // private ip  private String privateIpAddress;  // public ip  private
> String publicIpAddress;  // manually allocated ip  private String
> allocatedIpAddress;
> I hope that the reason for having allocatedIpAddress is to release it when
> terminating the instance. We are not releasing(deleting) all the public IPs.
>
> Predefined IPs should not released when terminating the instances right?
> Is this happening now? My predefined IP got released when I unsubscribed to
> the cartridge.
>

AFAIK we have to release an IP, only if we allocate manually.

>
> Jclouds API doc;
>    /**
>     * destroy the node, given its id. If it is the only node in a tag set,
> the dependent resources
>     * will also be destroyed.
>     */
>    void destroyNode(String id);
>
> So I guess all the floating IPs associated with the ports of this node
> will also be released right?
>
> Or can we set any property to prevent Jclouds from releasing floating IPs?
>

Please raise this in Jclouds user list and get clarified.

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



-- 
Best Regards,
Nirmal

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

Blog: http://nirmalfdo.blogspot.com/