click chroot create and destroy don't check status of chroot before executing the subcommand

Bug #1307628 reported by Sergio Schvezov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
click (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Here's my use case:
1) create chroot
2) use it
3) destroy it

During the use it phase I have left over mounts, so when I destroy it it fails to remove it from the fs but actually destroys the reference to the chroot as when I try to delete it again after manually unmounting it says it doesn't exist and when I try to create it says the filepath already exists.

$ sudo click chroot -aarmhf -f ubuntu-sdk-13.10 destroy
[sudo] password for sergiusens:
Traceback (most recent call last):
  File "/usr/bin/click", line 86, in <module>
    sys.exit(main())
  File "/usr/bin/click", line 82, in main
    return mod.run(args)
  File "/usr/lib/python3/dist-packages/click/commands/chroot.py", line 171, in run
    return args.func(parser, args)
  File "/usr/lib/python3/dist-packages/click/commands/chroot.py", line 54, in destroy
    return chroot.destroy()
  File "/usr/lib/python3/dist-packages/click/chroot.py", line 396, in destroy
    shutil.rmtree(mount)
  File "/usr/lib/python3.4/shutil.py", line 463, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib/python3.4/shutil.py", line 405, in _rmtree_safe_fd
    onerror(os.rmdir, fullname, sys.exc_info())
  File "/usr/lib/python3.4/shutil.py", line 403, in _rmtree_safe_fd
    os.rmdir(name, dir_fd=topfd)
OSError: [Errno 16] Device or resource busy: 'home'
sergiusens@rivendell:~/source/apps/camera/trunk$ for i in $(mount|grep schroot | awk '{print $3;}')
> do
> sudo umount "$i"
> done
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-00bc918f-f4c0-4e67-8204-ba88e6800489: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-00bc918f-f4c0-4e67-8204-ba88e6800489/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-25f8c19d-35d3-459c-80bc-29550330f5ac: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-25f8c19d-35d3-459c-80bc-29550330f5ac/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-34a91293-6276-4aaf-b5c2-73dfdad38205: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-34a91293-6276-4aaf-b5c2-73dfdad38205/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-5519f21e-f174-4ebd-bd25-4eb7a7ff0ef6: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-5519f21e-f174-4ebd-bd25-4eb7a7ff0ef6/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-5f3ac58a-082c-410d-b4a6-e965b531cfda: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-5f3ac58a-082c-410d-b4a6-e965b531cfda/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-995fd90d-b89d-47a6-8345-997b877cba6b: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-995fd90d-b89d-47a6-8345-997b877cba6b/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-d900c3d1-e697-478d-880a-7202c9095819: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-d900c3d1-e697-478d-880a-7202c9095819/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-e86a84b7-3da0-400e-b2da-d5636971bb88: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-e86a84b7-3da0-400e-b2da-d5636971bb88/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-ed1ab74f-bb64-477d-ae0b-3e8d36e11788: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-ed1ab74f-bb64-477d-ae0b-3e8d36e11788/dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/trusty-amd64-b1da252b-4ba5-4df4-b841-2c92ca87c029: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
sergiusens@rivendell:~/source/apps/camera/trunk$ for i in $(mount|grep schroot | awk '{print $3;}'); do sudo umount "$i"; done
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-00bc918f-f4c0-4e67-8204-ba88e6800489: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-25f8c19d-35d3-459c-80bc-29550330f5ac: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-34a91293-6276-4aaf-b5c2-73dfdad38205: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-5519f21e-f174-4ebd-bd25-4eb7a7ff0ef6: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-5f3ac58a-082c-410d-b4a6-e965b531cfda: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-995fd90d-b89d-47a6-8345-997b877cba6b: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-d900c3d1-e697-478d-880a-7202c9095819: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-e86a84b7-3da0-400e-b2da-d5636971bb88: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
umount: /var/lib/schroot/mount/click-ubuntu-sdk-13.10-armhf-ed1ab74f-bb64-477d-ae0b-3e8d36e11788: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
sergiusens@rivendell:~/source/apps/camera/trunk$ sudo click chroot -aarmhf -f ubuntu-sdk-13.10 destroy
Traceback (most recent call last):
  File "/usr/bin/click", line 86, in <module>
    sys.exit(main())
  File "/usr/bin/click", line 82, in main
    return mod.run(args)
  File "/usr/lib/python3/dist-packages/click/commands/chroot.py", line 171, in run
    return args.func(parser, args)
  File "/usr/lib/python3/dist-packages/click/commands/chroot.py", line 54, in destroy
    return chroot.destroy()
  File "/usr/lib/python3/dist-packages/click/chroot.py", line 392, in destroy
    "Chroot %s does not exist" % self.full_name)
click.chroot.ClickChrootException: Chroot click-ubuntu-sdk-13.10-armhf does not exist
sergiusens@rivendell:~/source/apps/camera/trunk$ sudo click chroot -aarmhf -f ubuntu-sdk-13.10 create
Traceback (most recent call last):
  File "/usr/bin/click", line 86, in <module>
    sys.exit(main())
  File "/usr/bin/click", line 82, in main
    return mod.run(args)
  File "/usr/lib/python3/dist-packages/click/commands/chroot.py", line 171, in run
    return args.func(parser, args)
  File "/usr/lib/python3/dist-packages/click/commands/chroot.py", line 41, in create
    return chroot.create()
  File "/usr/lib/python3/dist-packages/click/chroot.py", line 221, in create
    os.makedirs(mount)
  File "/usr/lib/python3.4/os.py", line 244, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/var/lib/schroot/chroots/click-ubuntu-sdk-13.10-armhf'

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: click 0.4.21.1
ProcVersionSignature: Ubuntu 3.13.0-23.45-generic 3.13.8
Uname: Linux 3.13.0-23-generic x86_64
ApportVersion: 2.14.1-0ubuntu2
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Apr 14 14:29:26 2014
InstallationDate: Installed on 2013-09-10 (216 days ago)
InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424)
SourcePackage: click
UpgradeStatus: Upgraded to trusty on 2013-09-10 (216 days ago)

Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in click (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.