snowdrop / java-buildpack-client

A java buildpack (https://buildpacks.io/) platform implementation
Apache License 2.0
14 stars 7 forks source link

volume m2-repo is being used by the following container(s) #91

Closed cmoulliard closed 5 days ago

cmoulliard commented 6 days ago

Isue

From time to time when we execute "mvn exec:java" we got this error using buildpack java client on a quarkus example

2024-11-19T10:06:45+01:00 ERROR: failed to build: exit status 1
[WARNING] 
com.github.dockerjava.api.exception.ConflictException: Status 409: {"cause":"volume is being used","message":"volume m2-repo is being used by the following container(s): 221233b18f3e78f174c37d6c2d8e8780fb57239d70adbdd3067a5569183ce520: volume is being used","response":409}

    at com.github.dockerjava.core.DefaultInvocationBuilder.execute (DefaultInvocationBuilder.java:245)
    at com.github.dockerjava.core.DefaultInvocationBuilder.delete (DefaultInvocationBuilder.java:56)
    at com.github.dockerjava.core.exec.RemoveVolumeCmdExec.execute (RemoveVolumeCmdExec.java:25)
    at com.github.dockerjava.core.exec.RemoveVolumeCmdExec.execute (RemoveVolumeCmdExec.java:11)
    at com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec (AbstrSyncDockerCmdExec.java:21)
    at com.github.dockerjava.core.command.AbstrDockerCmd.exec (AbstrDockerCmd.java:33)
    at com.github.dockerjava.core.command.RemoveVolumeCmdImpl.exec (RemoveVolumeCmdImpl.java:35)
    at dev.snowdrop.buildpack.docker.VolumeUtils.removeVolume (VolumeUtils.java:41)
    at dev.snowdrop.buildpack.lifecycle.LifecyclePhaseFactory.tidyUp (LifecyclePhaseFactory.java:211)
    at dev.snowdrop.buildpack.lifecycle.LifecycleExecutor.execute (LifecycleExecutor.java:145)
    at dev.snowdrop.buildpack.BuildpackBuild.build (BuildpackBuild.java:108)
    at dev.snowdrop.buildpack.BuildConfig.<init> (BuildConfig.java:64)
    at dev.snowdrop.buildpack.EditableBuildConfig.<init> (EditableBuildConfig.java:17)
    at dev.snowdrop.buildpack.BuildConfigBuilder.build (BuildConfigBuilder.java:60)
    at dev.snowdrop.Pack.main (Pack.java:52)

Originally posted by @cmoulliard in https://github.com/snowdrop/java-buildpack-client/issues/90#issuecomment-2485108250

@BarDweller

BarDweller commented 5 days ago

Looking at your sample project you have customized your cache volume name as part of the builder config.

This cache is for buildpack usage, it allows any buildpack to store information that it will reuse on subsequent builds. It does not provide a way to attach a maven .m2 repo to a build (as is suggested by your naming of the volume).

After each build, the library cleans up any volumes it used by removing them. The error is coming from that cleanup phase (potentially after a failed build in this instance, but it's hard to say because you only supply such a short window of the log).

It looks like that volume is in use by something else, and thus docker isn't allowed to remove it.

Either..

cmoulliard commented 5 days ago

As such a volume cannot attach a m2 repository, I will then remove it from the example that I'm testing

Thanks for the trick => .withDeleteCacheAfterBuild(false)