You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Hugo Trippaers <no...@github.com> on 2013/10/15 21:12:19 UTC
[jclouds] Implement a poor-mans rollback if static nat creation fails
(#184)
Catch exceptions while implementing static nat, destroy the already created vm and rethrow the exception. This will keep the concept of a failed operation clear for the api users, they would expect that the vm is not created when the builder throws an exception.
You can merge this Pull Request by running:
git pull https://github.com/spark404/jclouds JCLOUDS-347
Or you can view, comment on it, or merge it online at:
https://github.com/jclouds/jclouds/pull/184
-- Commit Summary --
* Implement a poor-mans rollback if static nat creation fails
-- File Changes --
M apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java (45)
-- Patch Links --
https://github.com/jclouds/jclouds/pull/184.patch
https://github.com/jclouds/jclouds/pull/184.diff
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Ignasi Barrera <no...@github.com>.
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to destroy the created VM");
> + destroyVirtualMachine(vm.getId());
Having a quick look at the code (I'm not the cloudstack expert here :)) it seems that it will list the rules and only try to delete the ones that really exist. The same procedure is applied in the other cleanup methods, so if this is true and I haven't misunderstood how it works, it should be safe to call the destroyNode as it should not fail during rollback. Worth a try?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6995644
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Andrew Phillips <no...@github.com>.
Thanks for the prod, @spark404. I'd still like to see some input from somebody else before making any decisions here.
It might be worth hopping on #jclouds at Freenode to see if someone can have a look - good time, too, since the next couple of releases are coming up.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-28089686
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
Closed #184.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #775](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/775/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26364956
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #779](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/779/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26403692
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> - logger.debug(">> creating static NAT for virtualMachine(%s) in network(%s)", vm.getId(), networkId);
> - PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> - logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> - vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> - List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> - if (capabilities.getCloudStackVersion().startsWith("2")) {
> - logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> - Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> - logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> - } else {
> - logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> - Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> - logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> - }
> - }
> + try {
Basically the same answer as the first question. Catch a much as possible to at least try to remove the already created stuff before we exit the method with an exception.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r7003443
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
@demobox @nacx Been a while, but it works fine with current master.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-38692063
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Andrew Phillips <no...@github.com>.
> - logger.debug(">> creating static NAT for virtualMachine(%s) in network(%s)", vm.getId(), networkId);
> - PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> - logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> - vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> - List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> - if (capabilities.getCloudStackVersion().startsWith("2")) {
> - logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> - Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> - logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> - } else {
> - logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> - Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> - logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> - }
> - }
> + try {
Where in this block are exceptions thrown? Could we narrow the scope of the `try`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6996419
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Ignasi Barrera <no...@github.com>.
Just a ping... @abayer, any thoughts on this?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-30183536
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Andrew Phillips <no...@github.com>.
> + PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
Is there any way to reduce the scope of the exception to catch here to something that's more application-specific? Or is the intention indeed that this also applies to bugs such as `ArrayIndexOutOfBoundsException`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6996406
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Ignasi Barrera <no...@github.com>.
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to destroy the created VM");
> + destroyVirtualMachine(vm.getId());
Since the try/catch block covers several statements, would it make sense to call `destroyNode` instead, so the applied nat configuration and allocated ups are properly rolled back too?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6985054
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Ignasi Barrera <no...@github.com>.
It's been a while now... Is it worth reopening this PR against master, as there is no 1.6 release scheduled?
Implementing a generic and proper rolback for the compute operations can be quite complex as providers do very different things as part of the node provisioning procedure (network creation, ip allocation, storage provisioning, etc). Having a generic rollback mechanism that only considers the operations that got materialized in the provider before the failure happened can be complex and we could spend as many time as we wanted to properly implement it in all the existing providers.
I'm personally in favor of merging this, but I'd push the changes to master. WDYT?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-34922048
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.error("-- exception after node has been created, trying to destroy the created VM");
Thanks, good point.. Fixed with commit fddf42c
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r7003570
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to destroy the created VM");
Good point, fixed. :)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6995490
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
@abayer, @adriancole, @demobox Hey guys, what do we do with this pull request. While i agree there should be a better solution in the future, it does solve the problem and it has been running without issues for some time on a production system.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-27970165
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> + PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
I'm not disagreeing with you on that. The expected behaviour should be transparent to the end user. If a call that creates a vm throws an exception the vm shouldn't be created. That means implementing some form of rollback or state keeping to ensure that when multiple tasks are needed to make it happen those tasks are rollback when it fails. (Either that or give the api user fair warning that an exception could indicate that the job is partially completed, but i wouldn't be in favor of this).
There is probably a better way of doing this, but it would require a deeper understanding of jclouds than what i currently have.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r7004105
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Andrew Phillips <no...@github.com>.
> I'll give it a go and test this with the master branch.
Thanks, @spark404!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-34985369
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #328](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/328/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26422408
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #317](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/317/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26403668
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
I'll give it a go and test this with the master branch.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-34954032
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Ignasi Barrera <no...@github.com>.
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to destroy the created VM");
Worth changing the log level to error?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6985018
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to destroy the created VM");
> + destroyVirtualMachine(vm.getId());
The trouble with destroyNode is that it will rollback all actions at the moment, without checking if it is needed. Say the static nat configuration get implemented and the firewallrules fail. Then destroyNode should return an error because the removal of the firewall rules fails (they are not there).
CloudStack will (should) clean the static nat bound to a VM when a virtual machine is destroyed. The firewall rules might remain, will check that.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6995427
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #313](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/313/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26364962
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #793](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/793/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26426365
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #791](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/791/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26422471
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Andrew Phillips <no...@github.com>.
> + PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
Personally, I think that scope is a little too broad, then - if we're trying to be smart not just on failures in provider calls, but arbitrary programming problems or even programming bugs in jclouds such as NPEs, we should think about that differently and not patch one single call to one single provider.
Would be curious to hear what others think about this. @abayer, @adriancole ...any thoughts?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r7003820
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> + PublicIPAddress ip = staticNATVMInNetwork.create(networks.get(networkId)).apply(vm);
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
Yeah, the intention is that anything that would cause the method to throw an exception will be caught. The expected behaviour of the method is that a vm instance will be created. If the method throws an exception api users would (should) assume that vm creation failed. To ensure this actually also happens on the cloudstack cloud i'm catching anything that happens after the vm spins up and roll it back.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r7003371
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Hugo Trippaers <no...@github.com>.
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.debug("-- exception after node has been created, trying to destroy the created VM");
> + destroyVirtualMachine(vm.getId());
Sure, i'll give it a try :) Would be nice if that works
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6995758
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by Andrew Phillips <no...@github.com>.
> + logger.trace("<< static NATed IPAddress(%s) to virtualMachine(%s)", ip.getId(), vm.getId());
> + vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
> + List<Integer> ports = Ints.asList(templateOptions.getInboundPorts());
> + if (capabilities.getCloudStackVersion().startsWith("2")) {
> + logger.debug(">> setting up IP forwarding for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<IPForwardingRule> rules = setupPortForwardingRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d IP forwarding rules on IPAddress(%s)", rules.size(), ip.getId());
> + } else {
> + logger.debug(">> setting up firewall rules for IPAddress(%s) rules(%s)", ip.getId(), ports);
> + Set<FirewallRule> rules = setupFirewallRulesForIP.apply(ip, ports);
> + logger.trace("<< setup %d firewall rules on IPAddress(%s)", rules.size(), ip.getId());
> + }
> + }
> + }
> + } catch (RuntimeException re) {
> + logger.error("-- exception after node has been created, trying to destroy the created VM");
Add `vm.getId()` to the log message?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184/files#r6996413
Re: [jclouds] Implement a poor-mans rollback if static nat creation
fails (#184)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #330](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/330/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/184#issuecomment-26426359