projectatomic / container-storage-setup

Service to set up storage for Docker and other container systems
Apache License 2.0
153 stars 77 forks source link

"atomic storage reset" fails if /var/lib/docker is mounted #254

Open mbarnes opened 7 years ago

mbarnes commented 7 years ago

Following the RHEL documentation for setting up the overlay2 graph driver, which recommends:

CONTAINER_ROOT_LV_MOUNT_PATH=/var/lib/docker

atomic storage reset subsequently fails with

rm: cannot remove ‘/var/lib/docker’: Device or resource busy

because the LV is still mounted there.

rhatdan commented 7 years ago

You should do

systemctl stop docker
atomic storage reset
atomic storage modify --storage=overlay2
systemctl start docker
mbarnes commented 7 years ago

I should have emphasized this is when running atomic storage reset again after all that.

Observed this while working on a devicemapper-to-overlay2 playbook (based on yours) and trying to reset the state back to devicemapper (see https://github.com/openshift/openshift-ansible/pull/5216).

rhatdan commented 7 years ago

@rhvgoyal Ideas?

mbarnes commented 7 years ago

What about just:

diff --git a/Atomic/storage.py b/Atomic/storage.py
index 77c1cbb..6e02256 100644
--- a/Atomic/storage.py
+++ b/Atomic/storage.py
@@ -160,6 +160,7 @@ class Storage(Atomic):
         util.call(["umount", root + "/devicemapper"], stderr=DEVNULL)
         util.call(["umount", root + "/overlay"], stderr=DEVNULL)
         util.call(["umount", root + "/overlay2"], stderr=DEVNULL)
+        util.call(["umount", root], stderr=DEVNULL)
         shutil.rmtree(root)
         os.mkdir(root)
         try:

And let it silently fail if there's nothing mounted there?

rhatdan commented 7 years ago

If that works, open a pull request with atomic.

mbarnes commented 7 years ago

Gah, just realized I filed this issue against the wrong project. Sorry about that. 😖