[
https://issues.apache.org/jira/browse/JCLOUDS-1202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15681559#comment-15681559
]
Aled Sage commented on JCLOUDS-1202:
------------------------------------
[~svet] did I describe it right: that this exception caused provisioning to
fail? (I can't see any try-catch block around it).
[~svet] Do you have the debug log available?
A few lines higher up (in
{{AWSEC2CreateSecurityGroupIfNeeded.createSecurityGroupInRegion}}) it first
creates the security group, then waits for eventual-consistency for the
security group to be visible, and then calls
{{Iterables.get(securityApi.describeSecurityGroupsInRegion(region, name), 0)}}.
It is this last call that throws the {{IndexOutOfBoundsException}}.
That suggests to me one of the following is happening:
1. The eventual consistency guarantees are worse than we thought. For example,
you might query for the security group and see it, but then query again
immediately afterwards and it not be listed.
2. The security group was deleted by some other thread/process in between our
calls.
3. The security group creation failed in some strange way, which meant the
{{securityGroupEventualConsistencyDelay}} check passed but the
{{securityApi.describeSecurityGroupsInRegion}} did not find it.
My guess would be (1) above.
---
One way the code could be fixed is to change what
{{securityGroupEventualConsistencyDelay}} does. It could return the actual
security group, rather than just {{true}} if the security group is eventually
found. This would remove the need to subsequently call
{{securityApi.describeSecurityGroupsInRegion(region, name)}}.
I haven't looked into how {{@Named("SECURITY") Predicate<RegionAndName>
securityGroupEventualConsistencyDelay}} is defined/used to see if that really
is a good idea.
> Provisioning in EC2 failed: IndexOutOfBoundsException when calling
> addSecurityGroups
> ------------------------------------------------------------------------------------
>
> Key: JCLOUDS-1202
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1202
> Project: jclouds
> Issue Type: Bug
> Components: jclouds-compute
> Affects Versions: 1.9.2
> Reporter: Aled Sage
>
> With jclouds 1.9.2, when provisioning a VM in aws-ec2, it failed with the
> following error:
> {noformat}
> Failed after 1.26s: UncheckedExecutionException:
> java.lang.IndexOutOfBoundsException: position (0) must be less than the
> number of elements that remained (0)
> com.google.common.util.concurrent.UncheckedExecutionException:
> java.lang.IndexOutOfBoundsException: position (0) must be less than the
> number of elements that remained (0)
> at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
> at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
> at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
> at
> com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
> at
> com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827)
> at
> org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.getSecurityGroupsForTagAndOptions(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java:183)
> at
> org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.addSecurityGroups(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java:109)
> at
> org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.addSecurityGroups(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java:185)
> at
> org.jclouds.ec2.compute.strategy.CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.execute(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java:80)
> at
> org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.execute(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java:79)
> at
> org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.execute(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java:50)
> at
> org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet.createKeyPairAndSecurityGroupsAsNeededThenRunInstances(EC2CreateNodesInGroupThenAddToSet.java:213)
> at
> org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet.runInstancesAndWarnOnInvisible(EC2CreateNodesInGroupThenAddToSet.java:151)
> at
> org.jclouds.ec2.compute.strategy.EC2CreateNodesInGroupThenAddToSet.execute(EC2CreateNodesInGroupThenAddToSet.java:132)
> at
> org.jclouds.compute.internal.BaseComputeService.createNodesInGroup(BaseComputeService.java:210)
> at
> org.jclouds.ec2.compute.EC2ComputeService.createNodesInGroup(EC2ComputeService.java:149)
> at
> org.apache.brooklyn.location.jclouds.JcloudsLocation.obtainOnce(JcloudsLocation.java:735)
> at
> org.apache.brooklyn.location.jclouds.JcloudsLocation.obtain(JcloudsLocation.java:626)
> at
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ObtainLocationTask.call(MachineLifecycleEffectorTasks.java:459)
> at
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ObtainLocationTask.call(MachineLifecycleEffectorTasks.java:449)
> at
> org.apache.brooklyn.util.core.task.Tasks.withBlockingDetails(Tasks.java:106)
> at
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ProvisionMachineTask.call(MachineLifecycleEffectorTasks.java:431)
> at
> org.apache.brooklyn.entity.software.base.lifecycle.MachineLifecycleEffectorTasks$ProvisionMachineTask.call(MachineLifecycleEffectorTasks.java:407)
> at
> org.apache.brooklyn.util.core.task.DynamicSequentialTask$DstJob.call(DynamicSequentialTask.java:359)
> at
> org.apache.brooklyn.util.core.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:519)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.IndexOutOfBoundsException: position (0) must be less
> than the number of elements that remained (0)
> at com.google.common.collect.Iterators.get(Iterators.java:813)
> at com.google.common.collect.Iterables.get(Iterables.java:724)
> at
> org.jclouds.aws.ec2.compute.loaders.AWSEC2CreateSecurityGroupIfNeeded.createSecurityGroupInRegion(AWSEC2CreateSecurityGroupIfNeeded.java:107)
> at
> org.jclouds.aws.ec2.compute.loaders.AWSEC2CreateSecurityGroupIfNeeded.load(AWSEC2CreateSecurityGroupIfNeeded.java:72)
> at
> org.jclouds.aws.ec2.compute.loaders.AWSEC2CreateSecurityGroupIfNeeded.load(AWSEC2CreateSecurityGroupIfNeeded.java:45)
> at
> com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
> at
> com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
> at
> com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
> at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
> ... 28 more
> {noformat}
> This was reported by [~svet] in
> https://issues.apache.org/jira/browse/BROOKLYN-395
> Googling for this error, it looks like it's been a problem for quite a while:
> a very similar looking stacktrace is included in the jclouds 1.6.0 release
> notes (https://jclouds.apache.org/releasenotes/1.6.0/aws-ec2-failures.txt).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)