Re: [jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
Would be nice to have it backported to the 1.7.x branch. That would make it easier to get it in the next release for jenkins-jclouds i think, but thats up to @abayer. I'm using this patch with a jclouds 1.7.x build at the moment. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328#issuecomment-38796156
Re: [jclouds] Implement a poor-mans rollback if static nat creation fails (#184)
Closed #184. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/184
Re: [jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
pushed a squashed and rebased patch --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328#issuecomment-38787615
Re: [jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
> +logger.trace("<< static NATed IPAddress(%s) to > virtualMachine(%s)", ip.getId(), vm.getId()); > +vm = > client.getVirtualMachineApi().getVirtualMachine(vm.getId()); > +List 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 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 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 virtualMachine(%s)", vm.getId()); Great :) The checkstyle fix and the exception handler are pushed. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328/files#r11016457
Re: [jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
> +logger.trace("<< static NATed IPAddress(%s) to > virtualMachine(%s)", ip.getId(), vm.getId()); > +vm = > client.getVirtualMachineApi().getVirtualMachine(vm.getId()); > +List 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 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 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 virtualMachine(%s)", vm.getId()); I didn't think that was necessary as the code rethrows the exception anyway, might be confusing for the guys looking at the logs to get the same exception twice in the logs? --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328/files#r11014882
Re: [jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
> +vm = > client.getVirtualMachineApi().getVirtualMachine(vm.getId()); > +List 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 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 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 virtualMachine(%s)", vm.getId()); > + destroyNode(vm.getId()); Ahh. that makes perfect sense :-). I make the change. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328/files#r11014695
Re: [jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
> +vm = > client.getVirtualMachineApi().getVirtualMachine(vm.getId()); > +List 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 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 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 virtualMachine(%s)", vm.getId()); > + destroyNode(vm.getId()); Hey @demobox . The point of this code is that destroyNode needs to be called before we rethrow the exception. Otherwise the code will have created an instance on the cloud, but will tell the higher level code that creating the instance failed. Please have a look at the discussion about this patch in https://github.com/jclouds/jclouds/issues/184 I think the last consensus was to merge this patch in. I know it's not the best solution, but next to implementing a transaction mechanism with rollbacks this does solve the problems we are having. The issue i'm facing is that due to ipv4 shortage allocating a static nat ip address sometimes fails. When this happens the jcloud-jenkins plugin thinks the creation of the instance fails (and rightfully so) but the instance was created on the cloud. Leaving a lot of unmanaged stale instances around. I've been running production with this "fix" for several months and have yet to see any issues with it. It would be really nice to have this in. Cheers, Hugo --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328/files#r11014225
[jclouds] JCLOUDS-347 Implement a poor-mans rollback if static nat creation fails (#328)
As discussed in https://github.com/jclouds/jclouds/pull/184 here is a new patch for master. Cheers, Hugo You can merge this Pull Request by running: git pull https://github.com/spark404/jclouds JCLOUDS-347-1.8.x Or you can view, comment on it, or merge it online at: https://github.com/jclouds/jclouds/pull/328 -- 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 (44) -- Patch Links -- https://github.com/jclouds/jclouds/pull/328.patch https://github.com/jclouds/jclouds/pull/328.diff --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds/pull/328
Re: [jclouds] Implement a poor-mans rollback if static nat creation fails (#184)
@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)
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