Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47566

Unexpected end of ZLIB input stream on permission errors

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: core
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      When trying to archive an artifact which is not readable by the user running Jenkins from a slave started via SSH I get the stack trace:

      [test] $ /bin/sh -xe /tmp/jenkins663015508021388474.sh
       + echo foo
       + sudo chown root bar.txt
       + sudo chmod 600 bar.txt
       Archiving artifacts
       ERROR: Failed to archive artifacts: bar.txt
       java.io.EOFException: Unexpected end of ZLIB input stream
       at com.jcraft.jzlib.InflaterInputStream.fill(InflaterInputStream.java:186)
       at com.jcraft.jzlib.InflaterInputStream.read(InflaterInputStream.java:106)
       at org.apache.commons.compress.utils.IOUtils.readFully(IOUtils.java:160)
       at org.apache.commons.compress.utils.IOUtils.readFully(IOUtils.java:134)
       at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.readRecord(TarArchiveInputStream.java:419)
       at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getRecord(TarArchiveInputStream.java:388)
       at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:269)
       at hudson.FilePath.readFromTar(FilePath.java:2295)
       Also: Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to test
       at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1655)
       at hudson.remoting.UserResponse.retrieve(UserRequest.java:308)
       at hudson.remoting.Channel$2.adapt(Channel.java:940)
       at hudson.remoting.Channel$2.adapt(Channel.java:937)
       at hudson.remoting.FutureAdapter.get(FutureAdapter.java:59)
       at hudson.FilePath.copyRecursiveTo(FilePath.java:2224)
       at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)
       at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:245)
       at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
       at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
       at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
       at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
       at hudson.model.Build$BuildExecution.post2(Build.java:186)
       at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
       at hudson.model.Run.execute(Run.java:1749)
       at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
       at hudson.model.ResourceController.execute(ResourceController.java:97)
       at hudson.model.Executor.run(Executor.java:421)
       java.io.IOException: This archives contains unclosed entries.
       at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.finish(TarArchiveOutputStream.java:225)
       at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.close(TarArchiveOutputStream.java:241)
       at hudson.util.io.TarArchiver.close(TarArchiver.java:127)
       at hudson.FilePath.writeToTar(FilePath.java:2281)
       at hudson.FilePath.access$2100(FilePath.java:196)
       at hudson.FilePath$45.invoke(FilePath.java:2216)
       at hudson.FilePath$45.invoke(FilePath.java:2212)
       at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2760)
       at hudson.remoting.UserRequest.perform(UserRequest.java:205)
       at hudson.remoting.UserRequest.perform(UserRequest.java:52)
       at hudson.remoting.Request$2.run(Request.java:356)
       at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)
       Caused: java.util.concurrent.ExecutionException
       at hudson.remoting.Channel$2.adapt(Channel.java:942)
       at hudson.remoting.Channel$2.adapt(Channel.java:937)
       at hudson.remoting.FutureAdapter.get(FutureAdapter.java:59)
       at hudson.FilePath.copyRecursiveTo(FilePath.java:2224)
       Caused: java.io.IOException: Failed to extract /tmp/slave/workspace/test/transfer of 1 files
       at hudson.FilePath.readFromTar(FilePath.java:2317)
       at hudson.FilePath.copyRecursiveTo(FilePath.java:2221)
       at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)
       at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:245)
       at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
       at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
       at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
       at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:682)
       at hudson.model.Build$BuildExecution.post2(Build.java:186)
       at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:627)
       at hudson.model.Run.execute(Run.java:1749)
       at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
       at hudson.model.ResourceController.execute(ResourceController.java:97)
       at hudson.model.Executor.run(Executor.java:421)
       Build step 'Archive the artifacts' changed build result to FAILURE
       Finished: FAILURE

      This happened on our production system, but I was able to reproduce it on a freshly installed jenkins instance with version 2.85 using this build script.

      echo foo > bar.txt
      sudo chown root bar.txt
      sudo chmod 600 bar.txt

      I have attached config.xml from my test job.

      The workaround is obviously to fix the permission issue on the slave, but I lost quite a few hours trying to debug this issue and a more appropriate error message would have helped quite a lot.

        Attachments

          Activity

          Hide
          ikedam ikedam added a comment -

          Apparently, this is not an issue of copyartifact.

          Show
          ikedam ikedam added a comment - Apparently, this is not an issue of copyartifact.
          Hide
          ifernandezcalvo Ivan Fernandez Calvo added a comment -

          This is your script

          echo foo > bar.txt
          sudo chown root bar.txt
          sudo chmod 600 bar.txt
          

          If the user that runs the agent is nor root does not have access to the bar.txt file, only root can read this file, so if you use a no root user to try to archive the artifacts you see this error.

          ERROR: Failed to archive artifacts: bar.txt
          java.io.EOFException: Unexpected end of ZLIB input stream
          	at com.jcraft.jzlib.InflaterInputStream.fill(InflaterInputStream.java:186)
          	at com.jcraft.jzlib.InflaterInputStream.read(InflaterInputStream.java:106)
          	at org.apache.commons.compress.utils.IOUtils.readFully(IOUtils.java:160)
          	at org.apache.commons.compress.utils.IOUtils.readFully(IOUtils.java:134)
          	at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.readRecord(TarArchiveInputStream.java:419)
          	at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getRecord(TarArchiveInputStream.java:388)
          	at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:269)
          	at hudson.FilePath.readFromTar(FilePath.java:2351)
          Also:   	Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to local
          			at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737)
          			at hudson.remoting.UserResponse.retrieve(UserRequest.java:313)
          			at hudson.remoting.Channel$2.adapt(Channel.java:986)
          			at hudson.remoting.Channel$2.adapt(Channel.java:983)
          			at hudson.remoting.FutureAdapter.get(FutureAdapter.java:59)
          			at hudson.FilePath.copyRecursiveTo(FilePath.java:2280)
          			at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)
          			at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:245)
          			at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
          			at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
          			at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
          			at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
          			at hudson.model.Build$BuildExecution.post2(Build.java:186)
          			at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
          			at hudson.model.Run.execute(Run.java:1752)
          			at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          			at hudson.model.ResourceController.execute(ResourceController.java:97)
          			at hudson.model.Executor.run(Executor.java:429)
          java.io.IOException: This archives contains unclosed entries.
          		at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.finish(TarArchiveOutputStream.java:225)
          		at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.close(TarArchiveOutputStream.java:241)
          		at hudson.util.io.TarArchiver.close(TarArchiver.java:127)
          		at hudson.FilePath.writeToTar(FilePath.java:2337)
          		at hudson.FilePath.access$2300(FilePath.java:208)
          		at hudson.FilePath$45.invoke(FilePath.java:2272)
          		at hudson.FilePath$45.invoke(FilePath.java:2268)
          		at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2816)
          		at hudson.remoting.UserRequest.perform(UserRequest.java:210)
          		at hudson.remoting.UserRequest.perform(UserRequest.java:53)
          		at hudson.remoting.Request$2.run(Request.java:364)
          		at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
          		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          		at java.lang.Thread.run(Thread.java:748)
          	Caused: java.util.concurrent.ExecutionException
          		at hudson.remoting.Channel$2.adapt(Channel.java:988)
          		at hudson.remoting.Channel$2.adapt(Channel.java:983)
          		at hudson.remoting.FutureAdapter.get(FutureAdapter.java:59)
          		at hudson.FilePath.copyRecursiveTo(FilePath.java:2280)
          Caused: java.io.IOException: Failed to extract /tmp/workspace/test/transfer of 1 files
          	at hudson.FilePath.readFromTar(FilePath.java:2373)
          	at hudson.FilePath.copyRecursiveTo(FilePath.java:2277)
          	at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)
          	at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:245)
          	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
          	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
          	at hudson.model.Build$BuildExecution.post2(Build.java:186)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
          	at hudson.model.Run.execute(Run.java:1752)
          	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          	at hudson.model.ResourceController.execute(ResourceController.java:97)
          	at hudson.model.Executor.run(Executor.java:429)
          Build step 'Archive the artifacts' changed build result to FAILURE
          

          The solution it is to give the right permission to the files in order to allow the agent process to archive the file, if you need a set of specific permissions on files, you should package the files before archiving, theb you can archive the result zip file.

          Show
          ifernandezcalvo Ivan Fernandez Calvo added a comment - This is your script echo foo > bar.txt sudo chown root bar.txt sudo chmod 600 bar.txt If the user that runs the agent is nor root does not have access to the bar.txt file, only root can read this file, so if you use a no root user to try to archive the artifacts you see this error. ERROR: Failed to archive artifacts: bar.txt java.io.EOFException: Unexpected end of ZLIB input stream at com.jcraft.jzlib.InflaterInputStream.fill(InflaterInputStream.java:186) at com.jcraft.jzlib.InflaterInputStream.read(InflaterInputStream.java:106) at org.apache.commons.compress.utils.IOUtils.readFully(IOUtils.java:160) at org.apache.commons.compress.utils.IOUtils.readFully(IOUtils.java:134) at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.readRecord(TarArchiveInputStream.java:419) at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getRecord(TarArchiveInputStream.java:388) at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:269) at hudson.FilePath.readFromTar(FilePath.java:2351) Also: Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to local at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737) at hudson.remoting.UserResponse.retrieve(UserRequest.java:313) at hudson.remoting.Channel$2.adapt(Channel.java:986) at hudson.remoting.Channel$2.adapt(Channel.java:983) at hudson.remoting.FutureAdapter.get(FutureAdapter.java:59) at hudson.FilePath.copyRecursiveTo(FilePath.java:2280) at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61) at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:245) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690) at hudson.model.Build$BuildExecution.post2(Build.java:186) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635) at hudson.model.Run.execute(Run.java:1752) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) java.io.IOException: This archives contains unclosed entries. at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.finish(TarArchiveOutputStream.java:225) at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.close(TarArchiveOutputStream.java:241) at hudson.util.io.TarArchiver.close(TarArchiver.java:127) at hudson.FilePath.writeToTar(FilePath.java:2337) at hudson.FilePath.access$2300(FilePath.java:208) at hudson.FilePath$45.invoke(FilePath.java:2272) at hudson.FilePath$45.invoke(FilePath.java:2268) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2816) at hudson.remoting.UserRequest.perform(UserRequest.java:210) at hudson.remoting.UserRequest.perform(UserRequest.java:53) at hudson.remoting.Request$2.run(Request.java:364) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Caused: java.util.concurrent.ExecutionException at hudson.remoting.Channel$2.adapt(Channel.java:988) at hudson.remoting.Channel$2.adapt(Channel.java:983) at hudson.remoting.FutureAdapter.get(FutureAdapter.java:59) at hudson.FilePath.copyRecursiveTo(FilePath.java:2280) Caused: java.io.IOException: Failed to extract /tmp/workspace/test/transfer of 1 files at hudson.FilePath.readFromTar(FilePath.java:2373) at hudson.FilePath.copyRecursiveTo(FilePath.java:2277) at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61) at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:245) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690) at hudson.model.Build$BuildExecution.post2(Build.java:186) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635) at hudson.model.Run.execute(Run.java:1752) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:429) Build step 'Archive the artifacts' changed build result to FAILURE The solution it is to give the right permission to the files in order to allow the agent process to archive the file, if you need a set of specific permissions on files, you should package the files before archiving, theb you can archive the result zip file.
          Hide
          mattiasa Mattias Amnefelt added a comment -

          Yes, fixing the permissions was the workaround I mentioned in the the initial ticket description. This ticket was about the error message which imho should be something better than
          Unexpected end of ZLIB input stream
          If the error message had mentioned permission denied anywhere, I would not have wasted several hours trying to find out what was wrong with the build slave.

          I do not think this is Not A Defect as the error message is highly misleading.

          Show
          mattiasa Mattias Amnefelt added a comment - Yes, fixing the permissions was the workaround I mentioned in the the initial ticket description. This ticket was about the error message which imho should be something better than Unexpected end of ZLIB input stream If the error message had mentioned permission denied anywhere, I would not have wasted several hours trying to find out what was wrong with the build slave. I do not think this is Not A Defect as the error message is highly misleading.
          Hide
          simonmartineaugv Simon Martineau added a comment -

          The problem that should be resolved, as described by the person who initially opened this ticket is the highly misleading error message.

          This has to be fixed. I wasted a lot of time, exactly as the person who initially open this ticket.

          Show
          simonmartineaugv Simon Martineau added a comment - The problem that should be resolved, as described by the person who initially opened this ticket is the highly misleading error message. This has to be fixed. I wasted a lot of time, exactly as the person who initially open this ticket.

            People

            • Assignee:
              Unassigned
              Reporter:
              mattiasa Mattias Amnefelt
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: