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 <rajkum...@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 <nirmal070...@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 <rajkum...@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 <rajkum...@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 <
>>>> rajkum...@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 <
>>>>> rajkum...@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 <
>>>>>> nirmal070...@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 <
>>>>>>> rajkum...@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi Nirmal,
>>>>>>>>
>>>>>>>> On Fri, Nov 21, 2014 at 11:46 AM, Nirmal Fernando <
>>>>>>>> nirmal070...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Nov 21, 2014 at 6:24 AM, Rajkumar Rajaratnam <
>>>>>>>>> rajkum...@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

Reply via email to