It would need to  either create an instance from a snapshot and then call 
listNodes, or call DiskUriToImage.load(URI_TO_SNAPSHOT) directly.
I have submitted a pull request with a fix and a mock test.
Please take a look @ https://github.com/jclouds/jclouds/pull/1075

Cheers,
Tomek

From: Ignasi Barrera <n...@apache.org>
Reply-To: "user@jclouds.apache.org" <user@jclouds.apache.org>
Date: Monday, 13 March 2017 at 09:43
To: "user@jclouds.apache.org" <user@jclouds.apache.org>
Subject: Re: diskURIToImage.getUnchecked() fails on instance created from 
snapshot (GCE)

Absolutely. A live test would be perfect.

I'd add a test method to the compute service adapter live test that takes an 
snapshot of one of the created test nodes and then calls getNode.

I'm not very familiar with the GCE API though, and I only see there methods to 
create snapshots of a given Disk. Would that be enough to replicate the failure 
scenario for the test?


On Mar 9, 2017 22:03, "Fritz Elfert" 
<fr...@fritz-elfert.de<mailto:fr...@fritz-elfert.de>> wrote:
Hi,

I'm the maintainer of the jenkins jclouds-plugin and just wanted to
chime in here...

I'd suggest designing that little test program as a LiveTest (fetching
account-specifics and credentials from a local maven settings.xml). If
you like, I can help with that but not before the end of next week
(extremely busy at work right now).

Cheers
 -Fritz

On 09.03.2017 13:03, Ignasi Barrera wrote:
> I'd say you could just create a snapshot in your account and write a
> small main program that calls `listNodes` . Something like this:
>
> try {
>    String identity = "<client email>";  // Something like
> "project...@developer.gserviceaccount.com<mailto:project...@developer.gserviceaccount.com>"
>    String credential = Files.toString(new File("<path to the GCE
> account private key>"), Charsets.UTF_8);
>
>    ComputeServiceContext ctx =
> ContextBuilder.newBuilder("google-compute-engine")
>       .credentials(identity, credential)
>       .modules(ImmutableSet.of(new SshjSshClientModule()))
>       .buildView(ComputeServiceContext.class);
>
>    ComputeService compute = ctx.getComputeService();
>
>    compute.listNodes();   // This will fail if there are snapshots
> until the issue is fixed.
> finally {
>    ctx.close();
> }
>
> You'll just need to add the
> "org.apache.jclouds.provider/google-compute-engine" and
> "org.apache.jclouds.driver/jclouds-sshj" dependencies to run that
> small program.
>
>
> You can have a look at the README for more info on how to get the credentials:
> https://github.com/jclouds/jclouds/tree/master/providers/google-compute-engine
>
>
> HTH!
>
> I.
>
> On 8 March 2017 at 17:57, Tomasz Wojtun 
> <tomasz.woj...@stepstone.com<mailto:tomasz.woj...@stepstone.com>> wrote:
>> Hi Ignasi.
>>
>> I will be glad to make a pull request. Can you tell me if there is an easy 
>> way to test the fix in IDE?
>>
>> Regards,
>> Tomasz
>>
>> On 07/03/2017, 14:32, "Ignasi Barrera" 
>> <n...@apache.org<mailto:n...@apache.org>> wrote:
>>
>>     Hi Tomasz,
>>
>>     You're right. jclouds should not fail in that case, The
>>     "diskuRIToImage" in the InstanceToNodeMetadata class is a cache, and
>>     it makes no sense to try to load a "null" key. I'd say the right way
>>     to fix it is just to execute this [1] only if the input disk's source
>>     is not null. Do you want to try opening a pull request with a patch?
>>     I'd be happy to help!
>>
>>
>>     I.
>>
>>     [1] 
>> https://github.com/jclouds/jclouds/blob/master/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/InstanceToNodeMetadata.java#L77
>>
>>
>>     On 7 March 2017 at 13:31, Tomasz Wojtun 
>> <tomasz.woj...@stepstone.com<mailto:tomasz.woj...@stepstone.com>> wrote:
>>     > Hi Jclouds users.
>>     >
>>     >
>>     >
>>     > I want to use  jclouds-plugin on Jenkins to provide jenkina slave 
>> machines
>>     > on Google Compute.
>>     >
>>     > The plugin fails to count nodes with specific images, when it comes up 
>> on
>>     > instance created from snapshot.
>>     >
>>     > The cause seems to be in jclouds code.
>>     >
>>     > Shouldn’t diskURIToImage.getUnchecked() in InstanceToNodeMetadata 
>> return
>>     > null and not throw an error in this case?
>>     >
>>     >
>>     >
>>     > Best regards,
>>     >
>>     > Tomasz
>>     >
>>     >
>>     >
>>     > StackTrace:
>>     >
>>     > Timer task 
>> hudson.slaves.NodeProvisioner$NodeProvisionerInvoker@79b4d01d
>>     > failed
>>     > shaded.com.google.common.util.concurrent.UncheckedExecutionException:
>>     > java.util.concurrent.ExecutionException: could not find image for disk
>>     > 
>> https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/disks/INSTANCE_NAME:
>>     > endpoint for [0] not configured for
>>     > org.jclouds.googlecomputeengine.compute.functions.Resources.public 
>> abstract
>>     > org.jclouds.googlecomputeengine.domain.Image
>>     > 
>> org.jclouds.googlecomputeengine.compute.functions.Resources.image(java.net.URI)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4829)
>>     > at
>>     > 
>> org.jclouds.googlecomputeengine.compute.functions.InstanceToNodeMetadata.apply(InstanceToNodeMetadata.java:77)
>>     > at
>>     > 
>> org.jclouds.googlecomputeengine.compute.functions.InstanceToNodeMetadata.apply(InstanceToNodeMetadata.java:43)
>>     > at
>>     > 
>> shaded.com.google.common.base.Functions$FunctionComposition.apply(Functions.java:211)
>>     > at
>>     > 
>> shaded.com.google.common.collect.Iterators$8.transform(Iterators.java:794)
>>     > at
>>     > 
>> shaded.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
>>     > at
>>     > 
>> shaded.com.google.common.collect.Iterators$7.computeNext(Iterators.java:646)
>>     > at
>>     > 
>> shaded.com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
>>     > at
>>     > 
>> shaded.com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
>>     > at 
>> shaded.com.google.common.collect.Iterators.addAll(Iterators.java:356)
>>     > at 
>> shaded.com.google.common.collect.Iterables.addAll(Iterables.java:350)
>>     > at 
>> shaded.com.google.common.collect.Sets.newLinkedHashSet(Sets.java:328)
>>     > at
>>     > 
>> org.jclouds.compute.internal.BaseComputeService.listNodes(BaseComputeService.java:342)
>>     > at
>>     > 
>> jenkins.plugins.jclouds.compute.JCloudsCloud.getRunningNodesCount(JCloudsCloud.java:482)
>>     > at
>>     > 
>> jenkins.plugins.jclouds.compute.JCloudsCloud.provision(JCloudsCloud.java:365)
>>     > at
>>     > 
>> hudson.slaves.NodeProvisioner$StandardStrategyImpl.apply(NodeProvisioner.java:701)
>>     > at hudson.slaves.NodeProvisioner.update(NodeProvisioner.java:307)
>>     > at hudson.slaves.NodeProvisioner.access$000(NodeProvisioner.java:60)
>>     > at
>>     > 
>> hudson.slaves.NodeProvisioner$NodeProvisionerInvoker.doRun(NodeProvisioner.java:798)
>>     > at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:50)
>>     > at 
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>>     > at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
>>     > at
>>     > 
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
>>     > at
>>     > 
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
>>     > 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.util.concurrent.ExecutionException: could not find 
>> image for
>>     > disk
>>     > 
>> https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/disks/INSTANCE_NAME:
>>     > endpoint for [0] not configured for
>>     > org.jclouds.googlecomputeengine.compute.functions.Resources.public 
>> abstract
>>     > org.jclouds.googlecomputeengine.domain.Image
>>     > 
>> org.jclouds.googlecomputeengine.compute.functions.Resources.image(java.net.URI)
>>     > at
>>     > 
>> org.jclouds.googlecomputeengine.compute.loaders.DiskURIToImage.load(DiskURIToImage.java:50)
>>     > at
>>     > 
>> org.jclouds.googlecomputeengine.compute.loaders.DiskURIToImage.load(DiskURIToImage.java:32)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
>>     > at shaded.com.google.common.cache.LocalCache.get(LocalCache.java:3934)
>>     > at 
>> shaded.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
>>     > at
>>     > 
>> shaded.com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827)
>>     > ... 26 more
>>     > Caused by: java.lang.IllegalArgumentException: endpoint for [0] not
>>     > configured for
>>     > org.jclouds.googlecomputeengine.compute.functions.Resources.public 
>> abstract
>>     > org.jclouds.googlecomputeengine.domain.Image
>>     > 
>> org.jclouds.googlecomputeengine.compute.functions.Resources.image(java.net.URI)
>>     > at
>>     > 
>> shaded.com.google.common.base.Preconditions.checkArgument(Preconditions.java:148)
>>     > at
>>     > 
>> org.jclouds.rest.internal.RestAnnotationProcessor.getEndpointInParametersOrNull(RestAnnotationProcessor.java:526)
>>     > at
>>     > 
>> org.jclouds.rest.internal.RestAnnotationProcessor.getEndpointFor(RestAnnotationProcessor.java:548)
>>     > at
>>     > 
>> org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:204)
>>     > at
>>     > 
>> org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:137)
>>     > at
>>     > 
>> org.jclouds.rest.internal.InvokeHttpMethod.toCommand(InvokeHttpMethod.java:188)
>>     > at
>>     > 
>> org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:84)
>>     > at
>>     > 
>> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:73)
>>     > at
>>     > 
>> org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:44)
>>     > at
>>     > 
>> org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(DelegatesToInvocationFunction.java:156)
>>     > at
>>     > 
>> org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(DelegatesToInvocationFunction.java:123)
>>     > at com.sun.proxy.$Proxy109.image(Unknown Source)
>>     > at
>>     > 
>> org.jclouds.googlecomputeengine.compute.loaders.DiskURIToImage.load(DiskURIToImage.java:48)
>>     > ... 35 more
>>     >
>>     >
>>
>>

Reply via email to