Destroying Jails with a snapshot

PeterSM

Dabbler
Joined
Dec 21, 2014
Messages
30
I am recreating my Jails in TrueNas 12 having upgraded from Freenas. I have a jail "plex" and have created a new jail (neither are plugins) "plex_jl". Having satisfied myself that the new jail is working I use
Code:
iocage destroy plex
to try to destroy the jail but I get the error
Code:
plex has dependent jails (who may also have dependents), use --recursive to destroy:
  auto-2020-11-07_07-45

I know (ask me how I know!) that if I use --recursive I will also destroy Plex_jl.

If I delete the snapshots "auto-2020-11-07_07-45" (there appear to be many with the same name?) will I be able to destroy the jail?
By deleting the snapshots will I lose anything else?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
iocage destroy plex
If you run that command like this:
iocage destroy --recursive plex

You will destroy that jail and all snapshots of that jail (and nothing else).


EDIT: Both CLI and GUI are broken and will destroy all jails with the same primitive... naming jails becones an important thing until this bug is resolved.

Absolutely don't do that from the GUI, nor CLI (since you have multiple jails with the same name beginning, so all would be lost)
 
Last edited:

PeterSM

Dabbler
Joined
Dec 21, 2014
Messages
30
Thanks for the response.
How can I remove plex without removing plex_jl?
 

tony_m

Cadet
Joined
Apr 18, 2019
Messages
8
If you run that command like this:
iocage destroy --recursive plex

You will destroy that jail and all snapshots of that jail (and nothing else).

Absolutely don't do that from the GUI (since you have multiple jails with the same name beginning, so all would be lost)

Sorry, but this is wrong information. DO NOT delete through the GUI nor the CLI recursively or you will lose both jails. I experienced this five minutes ago which prompted me to come here and search the forums.

Is this a bug or a feature?

I'd also like to know how to *safely* delete jails that have similar names to other jails.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Sorry, but this is wrong information. DO NOT delete through the GUI nor the CLI recursively or you will lose both jails. I experienced this five minutes ago which prompted me to come here and search the forums.
OK, so I re-ran a test and see that the CLI is also broken. fair point.
 
Last edited:

PeterSM

Dabbler
Joined
Dec 21, 2014
Messages
30
Yes that was my experience (As Sretalla says). I am wondering if I delete the snapshot will I then be able to remove the jail I dont want or will this still delete both jails?
 

tony_m

Cadet
Joined
Apr 18, 2019
Messages
8
Yes that was my experience (As Sretalla says). I am wondering if I delete the snapshot will I then be able to remove the jail I dont want or will this still delete both jails?

I did a few tests when I got home this morning and was able to remove a jail without destroying a similarly named jail by first renaming it. I won't guarantee this 100% so make sure you have a backup but in my testing this worked fine:

iocage rename plex delete_me iocage destroy --recursive delete_me
 
Last edited:

PeterSM

Dabbler
Joined
Dec 21, 2014
Messages
30
Thanks Tony I will try that and report back.
 

tony_m

Cadet
Joined
Apr 18, 2019
Messages
8
Thanks Tony I will try that and report back.

How'd that work out?

BTW, I tracked down the bug and the fix is scheduled to be included in the next Truenas update. If you feel like fixing it early, It's a simple change in the file: /usr/local/lib/python3.8/site-packages/iocage_lib/cache.py

Change line 90 from if ds.startswith(k): to if ds == k or ds.startswith(f'{k}/'):
 

PeterSM

Dabbler
Joined
Dec 21, 2014
Messages
30
Thanks for the update Tony
How'd that work out?
It didn't work I received the same message so I didn't delete.

I have found and changed the file.
Do I need to reboot?
Will the change survive a reboot?
 

tony_m

Cadet
Joined
Apr 18, 2019
Messages
8
No need to reboot. You will still get a message saying it will delete all dependents, but this time it will only delete the jail you specify and not the others.

Edit: to be clear, it will delete plex and all snapshots of plex but it won't touch plex_jl
 

PeterSM

Dabbler
Joined
Dec 21, 2014
Messages
30
That works thank you!

To be clear I had to use the command iocage destroy plex --recursive
 
Top