jkube: Error processing tar file(archive/tar: missed writing 4096 bytes):

Description

The jkube:build goal failes on CentOS Linux release 7.9.2009 (Core) with:

[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.3.0:build (default) on project myapp-docker: Failed to execute the build: Error while trying to build the image: Unable to build image [someco/myapp:latest] : {"message":"Error processing tar file(archive/tar: missed writing 4096 bytes): "} (Internal Server Error: 500) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.3.0:build (default) on project myapp-docker: Failed to execute the build
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to execute the build
        at org.eclipse.jkube.maven.plugin.mojo.build.AbstractDockerMojo.buildAndTag(AbstractDockerMojo.java:665)
        at org.eclipse.jkube.maven.plugin.mojo.build.AbstractDockerMojo.processImageConfig(AbstractDockerMojo.java:503)
        at org.eclipse.jkube.maven.plugin.mojo.build.AbstractDockerMojo.executeBuildGoal(AbstractDockerMojo.java:632)
        at org.eclipse.jkube.maven.plugin.mojo.build.BuildMojo.executeInternal(BuildMojo.java:49)
        at org.eclipse.jkube.maven.plugin.mojo.build.AbstractDockerMojo.execute(AbstractDockerMojo.java:444)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more
Caused by: org.eclipse.jkube.kit.config.service.JKubeServiceException: Error while trying to build the image: Unable to build image [someco/myapp:latest] : {"message":"Error processing tar file(archive/tar: missed writing 4096 bytes): "} (Internal Server Error: 500)
        at org.eclipse.jkube.kit.config.service.kubernetes.DockerBuildService.build(DockerBuildService.java:52)
        at org.eclipse.jkube.maven.plugin.mojo.build.AbstractDockerMojo.buildAndTag(AbstractDockerMojo.java:662)
        ... 26 more
Caused by: org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException: Unable to build image [someco/myapp:latest] : {"message":"Error processing tar file(archive/tar: missed writing 4096 bytes): "} (Internal Server Error: 500)
        at org.eclipse.jkube.kit.build.service.docker.access.hc.DockerAccessWithHcClient.buildImage(DockerAccessWithHcClient.java:272)
        at org.eclipse.jkube.kit.build.service.docker.BuildService.doBuildImage(BuildService.java:179)
        at org.eclipse.jkube.kit.build.service.docker.BuildService.buildImage(BuildService.java:143)
        at org.eclipse.jkube.kit.build.service.docker.BuildService.buildImage(BuildService.java:77)
        at org.eclipse.jkube.kit.config.service.kubernetes.DockerBuildService.build(DockerBuildService.java:44)
        ... 27 more
Caused by: org.eclipse.jkube.kit.build.service.docker.access.hc.http.HttpRequestException: {"message":"Error processing tar file(archive/tar: missed writing 4096 bytes): "} (Internal Server Error: 500)
        at org.eclipse.jkube.kit.build.service.docker.access.hc.ApacheHttpClientDelegate$StatusCodeCheckerResponseHandler.handleResponse(ApacheHttpClientDelegate.java:200)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
        at org.eclipse.jkube.kit.build.service.docker.access.hc.ApacheHttpClientDelegate.post(ApacheHttpClientDelegate.java:121)
        at org.eclipse.jkube.kit.build.service.docker.access.hc.DockerAccessWithHcClient.buildImage(DockerAccessWithHcClient.java:270)
        ... 31 more

The same project is working on Windows.

The TAR file looks fine with tar -tf docker-build.tar.

The image can be built manually by going into the assembly directory and running docker build . so docker and the docker daemon are working.

The TAR file is somehow not valid for the docker daemon:

[root@srv3 tmp]# cat docker-build.tar | docker build -
Sending build context to Docker daemon   212 kB
Error response from daemon: Error processing tar file(archive/tar: missed writin 4096 bytes):
[root@srv3 tmp]#

Info

  • Eclipse JKube version : 1.3.0
  • Maven version (mvn -v) : 3.6.3

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 47 (23 by maintainers)

Commits related to this issue

Most upvoted comments

(thank you guys and keep up the good work)

I noticed that in case of jkube directory size was more than zero:

[vagrant@localhost vagrant]$ tar -tvf /tmp/jkube.tar 
drwxr-xr-x 0/0              22 2021-07-27 10:47 maven/
-rw-r--r-- 0/0              94 2021-07-27 10:47 Dockerfile
-rw-r--r-- 0/0        19337676 2021-07-27 10:47 maven/test.jar
[vagrant@localhost vagrant]$ tar -tvf /tmp/fabric8.tar 
drwxrwxr-x vagrant/vagrant   0 2021-07-27 11:28 maven/
-rw-rw-r-- vagrant/vagrant 19337676 2021-07-27 11:27 maven/test.jar
-rw-rw-r-- vagrant/vagrant       93 2021-07-27 11:28 Dockerfile

When I set TarArchiveEntry size only in case of files, I’m able to get jkube working with docker: https://github.com/eclipse/jkube/blob/15bb59fbe2eb8c5f26e450ec7e4256bae19fe070/jkube-kit/common/src/main/java/org/eclipse/jkube/kit/common/archive/JKubeTarArchiver.java#L78

[vagrant@localhost vagrant-jkube-connection-reset-by-peer]$ mvn k8s:build
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Eclipse JKube :: Quickstarts :: Maven :: Dockerfile :: Simple 1.3.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.4.0-SNAPSHOT:build (default-cli) @ test ---
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[WARNING] k8s: Cannot access cluster for detecting mode: Unknown host kubernetes.default.svc: Name or service not known
[WARNING] Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring.
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[INFO] k8s: [test:1.3.0]: Created docker-build.tar in 160 milliseconds
[INFO] k8s: [test:1.3.0]: Built image sha256:d4fb4
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.483 s
[INFO] Finished at: 2021-07-27T14:23:10+02:00
[INFO] Final Memory: 31M/273M
[INFO] ------------------------------------------------------------------------
[vagrant@localhost vagrant-jkube-connection-reset-by-peer]$ docker run d4fb4

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Ye, thats exactly what we see. The docker host seems to reject the tar file or something to that effect… we uave a fair few docker file based projects that need migrating so i would be super appreciative if you could find a solution.

Hi @pmbsa It’s in our sprint plan but haven’t had the chance to investigate yet. We’re currently focused on releasing JKube (yesterday -> 2022-05-24), and Fabric8 Kubernetes Client. 😓

Hi Paul, sorry still no time. I’ll reopen the issue and try to allocate some time for us to investigate.

That gets really hard for me to do, I have to sell my soul to the gods of banking before I am allowed to do stuff like that but I will try. Its worth mentioning though that the structure in the target/docker folder is perfectly formed for the image. If I run “docker build” from the folder that has the generated Dockerfile I am able to build the image perfectly and stand up the container

Using mvn 3.3.9. Splitting phases is not enough if I still call the goals in the following sequence mvn ... clean package k8s:build deploy

Instead it works fine - splitting phases or not doesn’t matter - if I simply call them separately, i.e.

  1. mvn ... clean package k8s:build
  2. mvn ... deploy

That said the logging issue is not reproducible using a slightly more recent version of maven such as 3.6.3 (trioed that as it is already in use on other CI systems)

Let me create a separate issue for this.

If it’s not necessary I’d rather keep it this way. Maybe the unnecessary fix breaks something else. I just added the comment for the record in case we hit some other issue in the future.

@davidecavestro : Thanks a lot for sharing vagrantfile, I can reproduce your issue

I think in FMP we relied on Maven to generate the tar file. We really need to see the difference of a tar file generated with one plugin and the other. With two equivalent configurations (image model), the tar generated from FMP and JKube should be exactly the same.

Any clue on how to push to an insecure registry using jib? (creds over http)

😦 Could you open a specific feature request issue for that 🙏

Never tried with jib build strategy here. Great idea, I’ll give it a try. Updating Docker is the last resort, as this is an old CI server manually mantained by other folks so far, hence potentially plenty of pitfalls. About commons-compress it would be interesting to compare the tar with one generated by tar cli (maybe I’ll give it a try)

The docker load command fails with

open /var/lib/docker/tmp/docker-import-738275560/opt/json: no such file or directory

both on the problematic server and in dev local env.

At https://github.com/davidecavestro/vagrant-jkube-connection-reset-by-peer I’ve shared some stuff to reproduce the issue on a vagrant box.