BastilleBSD / bastille

Bastille is an open-source system for automating deployment and management of containerized applications on FreeBSD.
https://bastillebsd.org
BSD 3-Clause "New" or "Revised" License
854 stars 136 forks source link

[BUG] Stopping/deleting jails is broken #373

Open zilti opened 3 years ago

zilti commented 3 years ago

[MANDATORY] Describe the bug [MANDATORY] When trying to stop and then delete a jail, it will fail. I have to wait about a minute after stopping a jail before it is possible to delete it.

[MANDATORY] Bastille and FreeBSD version (paste bastille -v && freebsd-version -kru output)

0.8.20210115
12.2-RELEASE
12.2-RELEASE
12.2-RELEASE

[MANDATORY] How did you install bastille? (port/pkg/git) pkg

[optional] Steps to reproduce?

sudo bastille stop testbox || true
[testbox]:
testbox: removed
sudo bastille destroy testbox || true
Deleting Jail: testbox.
cannot unmount '/usr/local/bastille/jails/testbox/root': Device busy
rm: /usr/local/bastille/jails/testbox/root: Device busy
rm: /usr/local/bastille/jails/testbox: Device busy
Note: jail console logs archived.
/var/log/bastille/testbox_console.log-2021-04-12
sudo bastille create testbox 12.2-RELEASE 10.0.0.5
Valid: (10.0.0.5).
Jail: testbox already created.
adriel-tech commented 3 years ago

I have also had this issue many times, each time I had to manually umount jailname/root folder. One time when it happen It deleted files in a zfs mount point when failing to destroying the jail, though this could be unrelated.

I was using: Bastille 0.8.20210115 host: 12.2-RELEASE jails: 12.2-RELEASE

I have this happen usually when creating a 'test' jail, destroying it and remaking it a few times in a row using the same name+ip.

laktech commented 2 years ago

lesson learned, check "issues" and count how many are tagged with "bugs" before adopting. what an embarrassing bug.

bmac2 commented 1 year ago

@zilti What would be a valid fix to you for this issue? Possible ones off the top of my head

  1. have destroy wait until jail stops then continue
  2. have destroy through a message that jail has not stopped yet please try again later
  3. ????

Suggest a workable solution to make this go away.

adriel-tech commented 1 year ago

From my experience option 1. Will do the trick. I started to delay my destroy command for a minute after the jail seems to shutdown and I don't get this issue anymore.

But if you want to test it, just add a bunch of mounts to a jail, start it, shutdown and destroy it quickly and you are sure to stumble Into this issue.