Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to create docker test-containers in bitbucket pipelines using 1.15.0-rc2 #3296

Closed
meridsa opened this issue Oct 1, 2020 · 14 comments

Comments

@meridsa
Copy link

meridsa commented Oct 1, 2020

Recently updated to 1.15.0-rc2 from 1.14.3 due to #3166, however now our bitbucket pipelines we are getting the following errors:

Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.3, imagePullPolicy=DefaultPullPolicy()) Caused by: com.github.dockerjava.api.exception.DockerException: Status 403: {"message":"authorization denied by plugin pipelines: Invalid content length provided"}

Seems the issue is in the ElasticSearchContainer. Unsure what it is.

We have set
export TESTCONTAINERS_RYUK_DISABLED=true

Entire stack trace:

INFO  DockerMachineClientProviderStrategy:isApplicable - docker-machine executable was not found on PATH ([/usr/local/openjdk-11/bin, /usr/local/sbin, /usr/local/bin, /usr/sbin, /usr/bin, /sbin, /bin])
INFO  DockerClientProviderStrategy:lambda$getFirstValidStrategy$6 - Found Docker environment with Environment variables, system properties and defaults. Resolved dockerHost=tcp://localhost:2375
INFO  DockerClientFactory:client - Docker host IP address is localhost
INFO  DockerClientFactory:client - Connected to docker: 
  Server Version: 18.09.9
  API Version: 1.39
  Operating System: Alpine Linux v3.10 (containerized)
  Total Memory: 31703 MB
INFO  DockerClientFactory:client - Checking the system...
INFO  DockerClientFactory:check - ✔︎ Docker server version should be at least 1.6.0
INFO  DockerClientFactory:onStart - Starting to pull image
INFO  DockerClientFactory:onNext - Pulling image layers:  0 pending,  0 downloaded,  0 extracted, (0 bytes/0 bytes)
INFO  DockerClientFactory:onNext - Pulling image layers:  0 pending,  1 downloaded,  0 extracted, (1 MB/1 MB)
INFO  DockerClientFactory:onNext - Pulling image layers:  0 pending,  1 downloaded,  1 extracted, (1 MB/1 MB)
ERROR SpringApplication:reportFailure - Application run failed
java.lang.ExceptionInInitializerError: null
	at our.group.our.package.IntegrationTestBase$Initializer.initialize(IntegrationTestBase.kt:99) ~[test-classes/:?]
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:626) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:370) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:124) ~[spring-boot-test-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.junit.jupiter.SpringExtension.getApplicationContext(SpringExtension.java:202) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.junit.jupiter.SpringExtension.resolveParameter(SpringExtension.java:188) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:216) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:183) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:74) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestClassConstructor(ClassBasedTestDescriptor.java:329) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateTestClass(ClassBasedTestDescriptor.java:276) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:77) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:258) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:252) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at java.util.Optional.orElseGet(Optional.java:369) ~[?:?]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:251) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:29) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:106) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:105) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:69) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) [junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) [junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) [junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150) [surefire-junit-platform-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124) [surefire-junit-platform-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) [surefire-booter-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) [surefire-booter-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) [surefire-booter-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418) [surefire-booter-2.22.2.jar:2.22.2]
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.3, imagePullPolicy=DefaultPullPolicy())
	at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1282) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:616) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.elasticsearch.ElasticsearchContainer.<init>(ElasticsearchContainer.java:65) ~[elasticsearch-1.15.0-rc2.jar:?]
	at org.testcontainers.elasticsearch.ElasticsearchContainer.<init>(ElasticsearchContainer.java:53) ~[elasticsearch-1.15.0-rc2.jar:?]
	at our.group.our.package.IntegrationTestBase$Companion$elasticContainer$1.<init>(IntegrationTestBase.kt:63) ~[test-classes/:?]
	at our.group.our.package.IntegrationTestBase.<clinit>(IntegrationTestBase.kt:63) ~[test-classes/:?]
	... 63 more
Caused by: com.github.dockerjava.api.exception.DockerException: Status 403: {"message":"authorization denied by plugin pipelines: Invalid content length provided"}
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:249) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.post(DefaultInvocationBuilder.java:125) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:33) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.CreateContainerCmdExec.execute(CreateContainerCmdExec.java:13) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.CreateContainerCmdImpl.exec(CreateContainerCmdImpl.java:595) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.DockerClientFactory.runInsideDocker(DockerClientFactory.java:350) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:222) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.LazyDockerClient.listImagesCmd(LazyDockerClient.java:12) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.images.LocalImagesCache.maybeInitCache(LocalImagesCache.java:68) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.images.LocalImagesCache.get(LocalImagesCache.java:32) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.images.AbstractImagePullPolicy.shouldPull(AbstractImagePullPolicy.java:18) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:65) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:26) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:17) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:39) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1280) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:616) ~[testcontainers-1.15.0-rc2.jar:?]
	at org.testcontainers.elasticsearch.ElasticsearchContainer.<init>(ElasticsearchContainer.java:65) ~[elasticsearch-1.15.0-rc2.jar:?]
	at org.testcontainers.elasticsearch.ElasticsearchContainer.<init>(ElasticsearchContainer.java:53) ~[elasticsearch-1.15.0-rc2.jar:?]
	at our.group.our.package.IntegrationTestBase$Companion$elasticContainer$1.<init>(AMIntegrationTestBase.kt:63) ~[test-classes/:?]
	at our.group.our.package.IntegrationTestBase.<clinit>(AMIntegrationTestBase.kt:63) ~[test-classes/:?]
	... 63 more
2020-10-01 12:16:50,717 main INFO Log4j appears to be running in a Servlet environment, but there's no log4j-web module available. If you want better web container support, please add the log4j-web JAR to your web archive or server lib directory.
@rnorth
Copy link
Member

rnorth commented Oct 1, 2020

Ergh - there's not much to go on, but this post (final para) suggests that there's an incompatibility between docker-java and Bitbucket pipelines.

I wonder why we've not heard about this previously.

It's pretty odd that this issue is apparently only occurring with Bitbucket Pipelines, but I think it's pretty clear that a change would be needed in docker-java to reinstate(?) the content-length header if it's missing. WDYT @bsideup ?

@bsideup
Copy link
Member

bsideup commented Oct 1, 2020

@rnorth I think we do send the content-length header in docker-java where possible, but I can have a look. @meridsa could you please report an issue to the docker-java project?

@meridsa
Copy link
Author

meridsa commented Oct 1, 2020

Hi, reporting the issue to the docker-java project. Updated the initial post to include the full stack-trace from the initial failures. All the other integration tests fail as well with this stack-trace:

ERROR SpringApplication:reportFailure - Application run failed
java.lang.NoClassDefFoundError: Could not initialize class our.group.our.package.IntegrationTestBase
	at our.group.our.package.IntegrationTestBase$Initializer.initialize(IntegrationTestBase.kt:99) ~[test-classes/:?]
	at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:626) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:370) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:124) ~[spring-boot-test-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.junit.jupiter.SpringExtension.getApplicationContext(SpringExtension.java:202) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.test.context.junit.jupiter.SpringExtension.resolveParameter(SpringExtension.java:188) ~[spring-test-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:216) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameters(ExecutableInvoker.java:183) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:74) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestClassConstructor(ClassBasedTestDescriptor.java:329) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateTestClass(ClassBasedTestDescriptor.java:276) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:77) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:258) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:252) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at java.util.Optional.orElseGet(Optional.java:369) ~[?:?]
	at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:251) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:29) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:106) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:105) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:69) ~[junit-jupiter-engine-5.5.2.jar:5.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) ~[junit-platform-engine-1.5.2.jar:1.5.2]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) ~[junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) [junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) [junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) [junit-platform-launcher-1.3.1.jar:1.3.1]
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150) [surefire-junit-platform-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124) [surefire-junit-platform-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384) [surefire-booter-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345) [surefire-booter-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126) [surefire-booter-2.22.2.jar:2.22.2]
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418) [surefire-booter-2.22.2.jar:2.22.2]
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 4.889 s <<< FAILURE! - in our.group.our.package.CoreApplicationIT
[ERROR] contextLoads  Time elapsed: 0.003 s  <<< ERROR!
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [our.group.our.package.service SomeService someService] in constructor [public our.group.our.package.CoreApplicationIT(our.group.our.package.service.SomeService)]
Caused by: java.lang.ExceptionInInitializerError
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=docker.elastic.co/elasticsearch/elasticsearch-oss:6.8.3, imagePullPolicy=DefaultPullPolicy())
Caused by: com.github.dockerjava.api.exception.DockerException: 
Status 403: {"message":"authorization denied by plugin pipelines: Invalid content length provided"}
[ERROR] someTest  Time elapsed: 0 s  <<< ERROR!
org.junit.jupiter.api.extension.ParameterResolutionException: Failed to resolve parameter [our.group.our.package.service.SomeService someService] in constructor [public our.group.our.package.CoreApplicationIT(our.group.our.package.service.SomeService)]: Could not initialize class our.group.our.package.IntegrationTestBase
Caused by: java.lang.NoClassDefFoundError: Could not initialize class our.group.our.package.IntegrationTestBase

@nathanburrell
Copy link

Hello,
I made a comment on our BCLOUD ticket as to why we dont support transfer encoding chunked Ill link to it here and also replicate its contents.

Unfortunately we cant just add support for Transfer-Encoding: Chunked as the issue itself isnt with the transfer-encoding directly.

We run an authorization plugin attached to every steps docker in docker daemon that inspects the payloads of all the requests to the docker daemon for potentially malicious arguments that would allow users to subvert the security of containers (such as --privileged containers) as we are running a multi tenanted environment we dont want users to be able to subvert this.

How this plugins work is that when the docker daemon receives a request from a client (either the docker-cli, curl, some client in your favourite language etc) it first forwards that request (both the request line e.g. uri and query params and request body) to any authorization plugins which than perform inspections of them and return either an allow or deny (with an optional message) response. see for further information on authorization plugins: https://docs.docker.com/engine/extend/plugins_authorization/

Now unfortunately due to this line of code in the docker daemon https://github.com/moby/moby/blob/master/pkg/authorization/authz.go#L58

if sendBody(ctx.requestURI, r.Header) && r.ContentLength > 0 && r.ContentLength < maxBodySize {
Request bodies are only forwarded to the docker daemon iff they are not for the /auth endpoint and are of content-type: application/json and have a content length that is > 0 and their content length is not > 1mb.

Now unfortunately if your using transfer-encoding: chunked the content-length that most docker clients send through is 0 which is valid for that transfer encoding so that means the request body fails this request and the authorization plugin denies the request as we cant validate your request body doesnt contain any potentially malicious arguments.

Well behaving clients may set the content-length but than there is still and issue in that the body isnt forwarded to the authorization plugin as the docker daemon doesnt first buffer in the request body so if we were to read it it would drain the request body and than the docker daemon would fail the request as it couldnt read the body of the drained stream.

Really docker should improve as this affects not just pipelines but anyone using authorization plugins we are lucky enough to know of this and this can be exploited in other auth plugins who dont perform these extra validations of content-length.

So for now this is the reason why we cant support transfer-encoding: chunked.

Now as it seems your using https://github.com/docker-java/docker-java

It has multiple client backends (okhttp, jersey, netty) and I know one of them defaults to using transfer-encoding: chunked have you recently changed the backend used in a newer version of test-containers?

@ghost
Copy link

ghost commented Nov 3, 2020

Does anyone know where we stand on this? It's been 3 weeks since the last comment, and this is still an ongoing issue. Just curious if anyone has found a valid resolution.

@bsideup
Copy link
Member

bsideup commented Nov 3, 2020

@pconrey it requires a change (workaround) in docker-java, see the discussion there docker-java/docker-java#1467

@ghost
Copy link

ghost commented Nov 3, 2020

Thanks, @bsideup, but it looks like that one still isn't resolved either. Just trying to get a sense of when this will be fixed. For now I've downgraded to TestContainers v1.14.3, and downgraded Docker Desktop for Mac to 2.3.0.5. This combination works with bitbucket cloud, so I'll stick with that until this is fixed.

@bsideup
Copy link
Member

bsideup commented Nov 3, 2020

@pconrey as a FOSS project, we have the least resources in this combo (Docker, BitBucket, us) to work on this, sorry 😅

FYI you can upgrade your Docker for Mac and disable gRPC-FUSE, see #3166 (comment)

@ghost
Copy link

ghost commented Nov 3, 2020

@bsideup, I totally understand. Wasn't complaining, just making a note of my resolution so others could follow suit if necessary.

@michal-kaciuba
Copy link

michal-kaciuba commented Nov 12, 2020

Hey, is this issue supposed to be solved in 1.15.0? I'm getting a following error:

time="2020-11-12T15:28:30.290778769Z" level=error msg="AuthZRequest for POST /containers/create?name=testcontainers-checks-21e02c17-92ba-48a6-b42b-822014ef7681 returned error: authorization denied by plugin pipelines: Invalid request"

@lukass77
Copy link

I had the same issue with group: 'org.testcontainers', name: 'mysql', version: '1.15.0-rc2'
the current solution to by-pass this issue was

  1. downgrade testconrtainer to 'org.testcontainers', name: 'mysql', version: '1.14.3'
  2. set this on my gradle file -
    test { environment "TESTCONTAINERS_RYUK_DISABLED", "true" useJUnitPlatform() }

it seems that when RYUK is enabled , and version is '1.15.0-rc2'
this is the docker log I getting in bitbucket pipeline -

time="2020-11-16T21:18:09.412624553Z" level=warning msg="failed to load plugin io.containerd.internal.v1.opt" error="mkdir /opt/containerd: read-only file system"
time="2020-11-16T21:18:09.448152663Z" level=warning msg="Your kernel does not support cgroup blkio weight"
time="2020-11-16T21:18:09.448183673Z" level=warning msg="Your kernel does not support cgroup blkio weight_device"
time="2020-11-16T21:19:09Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/info
time="2020-11-16T21:19:09Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/info
time="2020-11-16T21:19:09Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/version
time="2020-11-16T21:19:09Z" level=info msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/images/json?filter=alpine%3A3.5"
time="2020-11-16T21:19:09Z" level=info msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/images/create?fromImage=alpine%3A3.5"
time="2020-11-16T21:19:10Z" level=info msg="Pipelines plugin request authorization." allowed=false method=POST plugin=pipelines uri="/containers/create?name=testcontainers-checks-640ab70f-0ff0-4e18-8a16-18361340c5eb"
time="2020-11-16T21:19:10.871712212Z" level=error msg="AuthZRequest for POST /containers/create?name=testcontainers-checks-640ab70f-0ff0-4e18-8a16-18361340c5eb returned error: authorization denied by plugin pipelines: Invalid request"

@bsideup
Copy link
Member

bsideup commented Nov 17, 2020

There is no need to disable Ryuk when on Docker for Mac, just disable gRPC-FUSE in Docker for Mac's settings.

Since the fix is in docker-java, I will lock this issue and close once Testcontainers is released with a new version of docker-java.

@testcontainers testcontainers locked as resolved and limited conversation to collaborators Nov 17, 2020
@bsideup bsideup added this to the 1.15.1 milestone Nov 23, 2020
@bsideup
Copy link
Member

bsideup commented Nov 23, 2020

FYI I just merged #3498 that includes a workaround that should cover most of the cases.

@bsideup
Copy link
Member

bsideup commented Dec 11, 2020

Released in 1.15.1

@bsideup bsideup closed this as completed Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants