arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
120 stars 98 forks source link

Problems with Private Registry #632

Closed mgparada closed 7 years ago

mgparada commented 7 years ago
Issue Overview

I have an Arquillian Cube working building my own images, but some days ago I just config a private Registry (under ssl and with user&pass) and trying to pull the images from it, fails always.

PS: I can pull images from Registry manually ;-) So it's not a Registry misconfiguration or something like this.

Expected Behaviour

I expect that Arquillian downloads (pull) images from my own Registry, in order to use always a pre-build image.

Current Behaviour

When I execute the gradle task and the Arquillian Runner starts, configured to find the image from the Registry, it fails with some NullPointerExceptions.

Additional Information

The arquillian cube config:

<extension qualifier="docker">
        <property name="serverVersion">1.12</property>
        <property name="dockerInsideDockerResolution">false</property>
        <property name="serverUri">https://127.0.0.1:2376</property>
        <property name="tlsVerify">DOCKER_CERT_PATH</property>
        <property name="definitionFormat">CUBE</property>
        <property name="dockerRegistry">xx.yy.com:1234</property>
        <property name="username">xx</property>
        <property name="password">xxxxxx</property>
        <property name="email">mauro@yy.com</property>
        <property name="dockerContainers">
            my-arquillian-service:
                image: aaa/bbb/ccc/my-image-name
        </property>
    </extension>

I tried changing some parameters.. <property name="dockerRegistry">https://xx.yy.com:1234/v2</property>,

<property name="dockerContainers">
            my-arquillian-service:
                image: xx.yy.com:1234/aaa/bbb/ccc/my-image-name
        </property>

So, i've tried with some differents options but i cannot make it works.. The error is as follows:

Arquillian has previously been attempted initialized, but failed. See cause for previous exception
java.lang.RuntimeException: Arquillian has previously been attempted initialized, but failed. See cause for previous exception
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:107)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy3.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
    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.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:166)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:103)
    at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:114)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:27)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    ... 26 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:162)
    ... 37 more
Caused by: java.lang.NullPointerException
    at org.arquillian.cube.docker.impl.util.ConfigUtil.load(ConfigUtil.java:97)
    at org.arquillian.cube.docker.impl.util.ConfigUtil.load(ConfigUtil.java:86)
    at org.arquillian.cube.docker.impl.docker.cube.CubeConverter.<init>(CubeConverter.java:22)
    at org.arquillian.cube.docker.impl.docker.cube.CubeConverter.create(CubeConverter.java:34)
    at org.arquillian.cube.docker.impl.client.DockerContainerDefinitionParser.convert(DockerContainerDefinitionParser.java:89)
    at org.arquillian.cube.docker.impl.client.CubeDockerConfiguration.fromMap(CubeDockerConfiguration.java:225)
    at org.arquillian.cube.docker.impl.client.CubeDockerConfigurator.configure(CubeDockerConfigurator.java:88)
    at org.arquillian.cube.docker.impl.client.CubeDockerConfigurator.configure(CubeDockerConfigurator.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:265)
    at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)
    at org.arquillian.cube.impl.client.CubeConfigurator.configure(CubeConfigurator.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:265)
    at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:74)
    at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:96)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
    at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
    at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:290)
    at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:63)
    ... 42 more

Any kind of help would be appreciated! I didn't find many docs about it so I followed some examples to figure out how i should configure.

Thanks!

dipak-pawar commented 7 years ago

Thank you for reporting this issue @mgparada. I'll take a look into this today.

mgparada commented 7 years ago

Update:

As @lordofthejars said, I tried to Docker-Compose file but still failing. The error is a bit different, but seems that is ignoring the dockerRegistry property. My arquillian.xml:

<extension qualifier="docker">
        <property name="serverVersion">1.12</property>
        <property name="dockerInsideDockerResolution">false</property>
        <property name="serverUri">https://127.0.0.1:2376</property>
        <property name="tlsVerify">DOCKER_CERT_PATH</property>
        <property name="dockerRegistry">xx.yy.com:1234</property>
        <property name="username">xx</property>
        <property name="password">xx</property>
        <property name="email">mauro@xx.com</property>
        <property name="dockerContainersFile">src/test/resources/docker-compose.yml</property>
    </extension>

and the error is like that:

Caused by: com.github.dockerjava.api.exception.UnauthorizedException: Get https://registry-1.docker.io/v2/library/null/manifests/latest: unauthorized: incorrect username or password

    at com.github.dockerjava.jaxrs.filter.ResponseStatusExceptionFilter.filter(ResponseStatusExceptionFilter.java:45)
    at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:140)
    at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:128)
    at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:257)
    at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:701)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:697)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)
    at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
    at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
    at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
    ... 4 more

Starting with docker-compose works like a charm. I cannot figure out which could be the problem..

lordofthejars commented 7 years ago

Dipak can you check if in DockerClientExecutor class in its constructor if this property is set?

El 15 mar. 2017 11:35 a. m., "Mauro Gómez Parada" notifications@github.com escribió:

Update:

As @lordofthejars https://github.com/lordofthejars said, I tried to Docker-Compose file but still failing. The error is a bit different, but seems that is ignoring the dockerRegistry property. My arquillian.xml:

1.12 false https://127.0.0.1:2376 DOCKER_CERT_PATH xx.yy.com:1234 xx xx mauro@xx.com src/test/resources/docker-compose.yml

and the error is like that:

Caused by: com.github.dockerjava.api.exception.UnauthorizedException: Get https://registry-1.docker.io/v2/library/null/manifests/latest: unauthorized: incorrect username or password

at com.github.dockerjava.jaxrs.filter.ResponseStatusExceptionFilter.filter(ResponseStatusExceptionFilter.java:45) at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:140) at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:128) at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:257) at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:701) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:697) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448) at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349) at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29) at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50) at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24) ... 4 more

Starting with docker-compose works like a charm. I cannot figure out which could be the problem..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/632#issuecomment-286703479, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYVZTRH0RBttMaN4el1CsPbZRm5UPks5rl78NgaJpZM4MdpvR .

dipak-pawar commented 7 years ago

@lordofthejars We are setting it inside DcokerClientExecutor class in it's constructor.

lordofthejars commented 7 years ago

Ok, then maybe it is an error in docker-java library.

El 15 mar. 2017 11:50 a. m., "Dipak Pawar" notifications@github.com escribió:

@lordofthejars https://github.com/lordofthejars We are setting it inside DcokerClientExecutor class in it's constructor.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/632#issuecomment-286706714, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYaquQwdsOlke2xmgLYu4jMdqJQwvks5rl8JtgaJpZM4MdpvR .

lordofthejars commented 7 years ago

I have found the bug. It is in our code. As a workaround you can do this https://github.com/docker-java/docker-java#properties-docker-javaproperties

mgparada commented 7 years ago

wops, thanks @lordofthejars. Tomorrow I'll check it out.

lordofthejars commented 7 years ago

Tomorrow I will also try to provide a PR with the fix.

@bartoszmajsak We should release alpha21 when this fixed since it is an important bug.

bartoszmajsak commented 7 years ago

Any time you feel like it @lordofthejars

lordofthejars commented 7 years ago

@mgparada I have pushed a new version of cube at https://github.com/lordofthejars/arquillian-cube/tree/issue-632 But the funny thing is that I have created an example of using another docker registry https://bintray.com/lordofthejars/continuous_delivery/lordofthejars%3Acomposer And I have not configured anything. I have not set the dockerRegistry property and my docker-compose file just contained lordofthejars-docker-continuous_delivery.bintray.io/lordofthejars/composer:1.0.0-alpine as the image to be used, and docker host automatically resolved to the other host and not docker.io.

Obviously your case is different since you are using a private repository. So what I would do is:

Clone https://github.com/lordofthejars/arquillian-cube Checkout the branch that is named issue-632. Run mvn install -DskipTests and use this snapshot and setting dockerRegistry, username and password of your private registry and of course using in docker compose the full path definition (host/namespace/container:version) form.

mgparada commented 7 years ago

Thanks @lordofthejars! I'll check it out and i'll use this snapshot while the new release not coming out.

lordofthejars commented 7 years ago

Basically before merging PR to upstream I want to validate that this fixes your problem since I have not been able to test exactly the same as your case

El 17 mar. 2017 9:55 a. m., "Mauro Gómez Parada" notifications@github.com escribió:

Thanks @lordofthejars https://github.com/lordofthejars! I'll check it out and i'll use this snapshot while the new release not coming out.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/arquillian/arquillian-cube/issues/632#issuecomment-287300331, or mute the thread https://github.com/notifications/unsubscribe-auth/ABcmYYwrF8iJoiDHccsJoZ2ly68Ynk55ks5rmkqBgaJpZM4MdpvR .

mgparada commented 7 years ago

Hi @lordofthejars, sorry for the delay! I'm trying this new version but still fails. I just find a problem parsing the image key, retrieved from the docker-compose file, and creating the Image object.

In Image.java class, inside the valueOf function, you're setting the image properties (nam & tag), but the switch does not contemplate some options.. in my case: my image url is something like: registry.mauro.com:1234/my/custom/repo/myimage:latest so as you are splitting by '/' this returns an array of 5 elements.. but there are no case for 5 elements. Watching the code I see that you're assuming that the <organization_namespace> is one word or something that does not contain /.. but i think that the common structure for the namespace is something like my/org/bucket. So, finally, the image, is creating with tag & name = null, the value which initializes these properties.

lordofthejars commented 7 years ago

I have not seen any example like you mention before :) watching public docker repositories I have always seen the same pattern. Anyway, if it works on docker-machine it means we need to add support as well. So from your previous example registry.mauro.com:1234 is the private host. my/custom/repo is the organization, myimage is the image name and latest the tag right?

mgparada commented 7 years ago

uhm.. yep, i'm watching and you're right! may be i should change my namespaces format... :)

Yes, in my case I using this format:

but i guess that version could be latest or something like 1.2.3, right?

lordofthejars commented 7 years ago

yes, this is not a problem. But this format works on docker-machine right?

mgparada commented 7 years ago

yep, it's working. I test it in docker > v1.12

lordofthejars commented 7 years ago

ok, then we need to add this specific use case as well. Thank you so much.

mgparada commented 7 years ago

Ok, perfect! Thank you so much for your work! ;-) If you need some test on it, just tell me something

lordofthejars commented 7 years ago

@mgparada At https://github.com/arquillian/arquillian-cube/pull/640 you've got a version that works with multiple levels in organization name. Can you give it a try please? Tests passes, but what I would like to see is working with private registry :)

mgparada commented 7 years ago

Yay! it's working now! Thx! ;)

lordofthejars commented 7 years ago

Thank you very much for your patience and reporting the bug. Now it is merged and shipped in next release.

lordofthejars commented 7 years ago

https://github.com/arquillian/arquillian-cube/pull/640