question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intermittent AccessDeniedException while building the image

See original GitHub issue

Environment:

  • Jib version: jib-maven-plugin 2.8.0
  • Build tool: Apache Maven 3.6.2 on OpenJDK 11
  • OS: Windows 10

Description of the issue: The image build is intermittently failing while copying files in the jib cache. This issue is related to https://github.com/GoogleContainerTools/jib/issues/1763. The failure is caused by the virus scanner locking the file, but since the build is done in a work environment, there is not much I can do about it. The virus scanning software used is McAfee Endpoint Security 10.6. Moreover the friendly exception message introduced with https://github.com/GoogleContainerTools/jib/pull/1887 is not shown. This is probably due to https://github.com/GoogleContainerTools/jib/blob/52d867fac945b05edbc0e977812dedfc1e7a03da/jib-core/src/main/java/com/google/cloud/tools/jib/cache/Retry.java#L135-L140 eventually rethrowing the exception instead of returning false.

Expected behavior: The image build should not fail due to a virus scanner temporarily blocking access to a cache file. I suggest to increase the waiting period and/or the number of retries. Ideally this would be configurable by the user. If the image build fails, the IOException with the friendly message from https://github.com/GoogleContainerTools/jib/blob/52d867fac945b05edbc0e977812dedfc1e7a03da/jib-core/src/main/java/com/google/cloud/tools/jib/cache/CacheStorageWriter.java#L134-L139 should be thrown, instead of the raw AccessDeniedException.

[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.8.0:dockerBuild (default-cli) on project module: C:\GIT\project\module\target\jib-cache\tmp\9796658
997542756861 -> C:\GIT\project\module\target\jib-cache\layers\da49230cceb485be22432aa073ee7baf8dd3d868a13bc7eacb39688edf4d1e22 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.cloud.tools:jib-maven-plugin:2.8.0:dockerBuild (default-cli) on project module: C:\GIT\project\module\target\jib-cache\tmp\9796658997542756861 -> C:\GIT\project\module\target\jib-cache\layers\da49230cceb485be22432aa073ee7baf8dd3d868a13bc7eacb39688edf4d1e22
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: C:\GIT\project\module\target\jib-cache\tmp\9796658997542756861 -> C:\GIT\project\module\target\jib-cache\layers\da49230cceb485be22432aa073ee7baf8dd3d868a13bc7eacb39688edf4d1e22
    at com.google.cloud.tools.jib.maven.BuildDockerMojo.execute (BuildDockerMojo.java:165)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.nio.file.AccessDeniedException: C:\GIT\project\module\target\jib-cache\tmp\9796658997542756861 -> C:\GIT\project\module\target\jib-cache\layers\da49230cceb485be22432aa073ee7baf8dd3d868a13bc7eacb39688edf4d1e22
    at sun.nio.fs.WindowsException.translateToIOException (WindowsException.java:89)
    at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:103)
    at sun.nio.fs.WindowsFileCopy.move (WindowsFileCopy.java:395)
    at sun.nio.fs.WindowsFileSystemProvider.move (WindowsFileSystemProvider.java:288)
    at java.nio.file.Files.move (Files.java:1421)
    at com.google.cloud.tools.jib.cache.CacheStorageWriter.lambda$moveIfDoesNotExist$3 (CacheStorageWriter.java:126)
    at com.google.cloud.tools.jib.cache.Retry.run (Retry.java:126)
    at com.google.cloud.tools.jib.cache.CacheStorageWriter.moveIfDoesNotExist (CacheStorageWriter.java:132)
    at com.google.cloud.tools.jib.cache.CacheStorageWriter.writeUncompressed (CacheStorageWriter.java:270)
    at com.google.cloud.tools.jib.cache.Cache.writeUncompressedLayer (Cache.java:144)
    at com.google.cloud.tools.jib.builder.steps.BuildAndCacheApplicationLayerStep.call (BuildAndCacheApplicationLayerStep.java:109)
    at com.google.cloud.tools.jib.builder.steps.BuildAndCacheApplicationLayerStep.call (BuildAndCacheApplicationLayerStep.java:38)
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly (TrustedListenableFutureTask.java:125)
    at com.google.common.util.concurrent.InterruptibleTask.run (InterruptibleTask.java:69)
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run (TrustedListenableFutureTask.java:78)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
    at java.lang.Thread.run (Thread.java:834)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chanseokohcommented, Mar 16, 2021

#3133 will increase the retry number from 5 to 10, which will be up to 150ms of delay in the worst case. It also improved the error message and fixed the bug that swallowed the error. After 10 attempts, I think it’s reasonable to fail, as it could mean that an anti-virus program is really affecting the productivity, and the error message will offer a workaround that has a potential to significantly improve build time.

At the moment, it feels weird to put the application cache config into the global Jib config file. But maybe it’s possible to have a flag there to do Jib CLI-style caching (#2495 and #2929). However, it’s not likely we’ll revisit this anytime soon, as our resources are very limited.

0reactions
chanseokohcommented, Apr 9, 2021

We will close the issue with based on the changes in #3133, which is included in the Jib build plugins 3.0 that we just released. But anyone, feel free to update feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.nio.file.AccessDeniedException: while retrieving image ...
I tried the similar thing and it seems to be working. Below is my working code. public static void main(String args[]) throws IOException ......
Read more >
AccessDeniedException - Android Developers
Checked exception thrown when a file system operation is denied, typically due to a file permission or other ... public AccessDeniedException (String file)....
Read more >
AccessDeniedException caused by delayed file deletion on ...
AccessDeniedException in Windows family platforms intermittently. The exception is not thrown by an illegal access to the file, but its lock file.
Read more >
java.nio.file.AccessDeniedException thrown on GWT compile
Correction: The exception is thrown before the compile even occurs. It seems to be random when it actually happens (however, it will only...
Read more >
[Solved]-java.nio.file.AccessDeniedException of Jenkins when ...
AccessDeniedException of Jenkins when Jenkins container accessing the local ... not found when building docker image using Docker Jenkins container pipeline ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found