fixes for AWS VPC issues * give a detailed message if we hit the classic/vpc problem * treat `networkName` as `subnetId` in AWS * longer timeout for AWS security group creation * use `eu-central-1` in the default catalog as it gives a default VPC which works best
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b77ef941 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b77ef941 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b77ef941 Branch: refs/heads/master Commit: b77ef941a9d6ef8b57cc18e47adb259dc4f97c18 Parents: 4897470 Author: Alex Heneveld <[email protected]> Authored: Mon Jun 22 23:11:20 2015 -0700 Committer: Alex Heneveld <[email protected]> Committed: Wed Jun 24 00:40:34 2015 -0700 ---------------------------------------------------------------------- .../jclouds/ComputeServiceRegistryImpl.java | 7 +++++ .../location/jclouds/JcloudsLocation.java | 29 ++++++++++++++++++-- .../location/jclouds/JcloudsLocationConfig.java | 2 +- .../main/resources/brooklyn/default.catalog.bom | 12 ++++---- 4 files changed, 41 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b77ef941/locations/jclouds/src/main/java/brooklyn/location/jclouds/ComputeServiceRegistryImpl.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/ComputeServiceRegistryImpl.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/ComputeServiceRegistryImpl.java index b3da5a6..a1786ec 100644 --- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/ComputeServiceRegistryImpl.java +++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/ComputeServiceRegistryImpl.java @@ -31,6 +31,7 @@ import org.jclouds.Constants; import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.ec2.reference.EC2Constants; import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.sshj.config.SshjSshClientModule; @@ -40,6 +41,7 @@ import org.slf4j.LoggerFactory; import brooklyn.entity.basic.Sanitizer; import brooklyn.util.collections.MutableMap; import brooklyn.util.config.ConfigBag; +import brooklyn.util.time.Duration; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; @@ -96,6 +98,11 @@ public class ComputeServiceRegistryImpl implements ComputeServiceRegistry, Jclou * Filter.3.Name=image-type&Filter.3.Value.1=machine& */ } + + // occasionally can get com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: + // security group eu-central-1/jclouds#brooklyn-bxza-alex-eu-central-shoul-u2jy-nginx-ielm is not available after creating + // the default timeout was 500ms so let's raise it in case that helps + properties.setProperty(EC2Constants.PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT, ""+Duration.seconds(30).toMilliseconds()); } // FIXME Deprecated mechanism, should have a ConfigKey for overrides http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b77ef941/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java index a0d30d4..969d41d 100644 --- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java +++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java @@ -53,6 +53,7 @@ import java.util.regex.Pattern; import javax.annotation.Nullable; +import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.cloudstack.compute.options.CloudStackTemplateOptions; import org.jclouds.compute.ComputeService; import org.jclouds.compute.RunNodesException; @@ -979,10 +980,20 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im // sometimes AWS nodes come up busted (eg ssh not allowed); just throw it back (and maybe try for another one) boolean destroyNode = (node != null) && Boolean.TRUE.equals(setup.get(DESTROY_ON_FAILURE)); + if (e.toString().contains("VPCResourceNotSpecified")) { + LOG.error("Detected that your EC2 account is a legacy 'classic' account, but the recommended instance type requires VPC. " + + "You can specify the 'eu-central-1' region to avoid this problem, or you can specify a classic-compatible instance type, " + + "or you can specify a subnet to use with 'networkName' " + + "(taking care that the subnet auto-assigns public IP's and allows ingress on all ports, " + + "as Brooklyn does not currently configure security groups for non-default VPC's; " + + "or setting up Brooklyn to be in the subnet or have a jump host or other subnet access configuration). " + + "For more information on VPC vs classic see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-vpc.html."); + } + LOG.error("Failed to start VM for {}{}: {}", new Object[] {setup.getDescription(), (destroyNode ? " (destroying "+node+")" : ""), e.getMessage()}); LOG.debug(Throwables.getStackTraceAsString(e)); - + if (destroyNode) { if (machineLocation != null) { releaseSafely(machineLocation); @@ -1241,7 +1252,21 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im }}) .put(NETWORK_NAME, new CustomizeTemplateOptions() { public void apply(TemplateOptions t, ConfigBag props, Object v) { - t.networks((String)v); + if (t instanceof AWSEC2TemplateOptions) { + // subnet ID is the sensible interpretation of network name in EC2 + ((AWSEC2TemplateOptions)t).subnetId((String)v); + + } else { + if (t instanceof SoftLayerTemplateOptions) { + LOG.warn("networkName may not be supported in SoftLayer; use `templateOptions` with `primaryNetworkComponentNetworkVlanId` or `primaryNetworkBackendComponentNetworkVlanId`"); + } else if (!(t instanceof CloudStackTemplateOptions) && !(t instanceof NovaTemplateOptions)) { + LOG.warn("networkName may not be supported in this cloud; only known to work in CloudStack and OpenStack"); + } + + // looks like this is only supported in Cloudstack and Openstack + // should we log warning if using another cloud? + t.networks((String)v); + } }}) .put(DOMAIN_NAME, new CustomizeTemplateOptions() { public void apply(TemplateOptions t, ConfigBag props, Object v) { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b77ef941/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java index ab0007a..c37d915 100644 --- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java +++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java @@ -193,7 +193,7 @@ public interface JcloudsLocationConfig extends CloudLocationConfig { public static final ConfigKey<Integer> OVERRIDE_RAM = ConfigKeys.newIntegerConfigKey("overrideRam", "Custom ram value"); public static final ConfigKey<String> NETWORK_NAME = ConfigKeys.newStringConfigKey( - "networkName", "Network name to specify as template option (e.g. GCE)"); + "networkName", "Network name or ID where the instance should be created (e.g. the subnet ID in AWS"); /** * CUSTOM_MACHINE_SETUP_SCRIPT_URL accepts a URL location that points to a shell script. http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b77ef941/usage/cli/src/main/resources/brooklyn/default.catalog.bom ---------------------------------------------------------------------- diff --git a/usage/cli/src/main/resources/brooklyn/default.catalog.bom b/usage/cli/src/main/resources/brooklyn/default.catalog.bom index 4da8319..70c7d57 100644 --- a/usage/cli/src/main/resources/brooklyn/default.catalog.bom +++ b/usage/cli/src/main/resources/brooklyn/default.catalog.bom @@ -59,15 +59,15 @@ brooklyn.catalog: - type: server name: My VM - # location can be `softlayer` or `jclouds:openstack-nova:https://9.9.9.9:9999/v2.0/`, + # location can be e.g. `softlayer` or `jclouds:openstack-nova:https://9.9.9.9:9999/v2.0/`, # or `localhost` or `byon: { nodes: [ 10.0.0.1, 10.0.0.2, 10.0.1.{1,2} ] }` location: jclouds:aws-ec2: - # edit these to use your credential(or delete if credentials specified in brooklyn.properties) + # edit these to use your credential (or delete if credentials specified in brooklyn.properties) identity: <REPLACE> credential: <REPLACE> - region: eu-west-1 + region: eu-central-1 # we want Ubuntu, with a lot of RAM osFamily: ubuntu @@ -156,7 +156,7 @@ brooklyn.catalog: location: jclouds:aws-ec2: - region: eu-west-1 + region: eu-central-1 # edit these (or delete if credentials specified in brooklyn.properties) identity: <REPLACE> credential: <REPLACE> @@ -202,7 +202,7 @@ brooklyn.catalog: location: jclouds:aws-ec2: - region: eu-west-1 + region: eu-central-1 # edit these (or delete if credentials specified in brooklyn.properties) identity: <REPLACE> credential: <REPLACE> @@ -355,5 +355,5 @@ brooklyn.catalog: identity: <REPLACE> credential: <REPLACE> - region: eu-west-1 + region: eu-central-1 minRam: 2gb
