cloudserver icon indicating copy to clipboard operation
cloudserver copied to clipboard

config.json in container and 'Device or resource busy'

Open robertkarbowski opened this issue 4 years ago • 2 comments

Bug report information

Description

In docker-entrypoint.sh there is a command:

...
    mv config.json.tmp config.json
...

It works fine as long as no-one wants to mount external config.json file (docker run -v $(pwd)/config.json:/usr/src/app/config.json ...). If so "docker" fails with the error:

mv: cannot move 'config.json.tmp' to 'config.json': Device or resource busy

The reason is that Linux does not allow to delete/rename mount points (mv uses actually rename() syscall).

One of the possible solutions is to replace "mv" with 2 commands:

--- old/docker-entrypoint.sh    2021-08-31 07:47:00.832079384 +0000
+++ new/docker-entrypoint.sh    2021-08-31 07:47:30.516815669 +0000
@@ -197,7 +197,8 @@
 
 if [[ $JQ_FILTERS_CONFIG != "." ]]; then
     jq "$JQ_FILTERS_CONFIG" config.json > config.json.tmp
-    mv config.json.tmp config.json
+    cp config.json.tmp config.json
+    rm config.json.tmp
 fi

robertkarbowski avatar Aug 31 '21 13:08 robertkarbowski

We also encountered this problem for kubernetes v1.20. Instead of mounting config.json, we mount .docker directory. In this way, you can change config.json (rewrite, replace, etc.) in container environment.

yishangru avatar Nov 02 '22 08:11 yishangru

duplicate https://github.com/scality/cloudserver/issues/1520#issuecomment-419576769

sytolk avatar Jan 27 '23 13:01 sytolk