Replicating iocage dataset results in non-working jail configuration

Description

Replicating the iocage dataset to a 2nd pool which is also imported leads to non-working pool configuration that cannot be rectified using the GUI. If the pool is degraded, running jails cannot be stopped.

To reproduce:

1) create jails or plugins and have them running
2) create a recursive snapshot on the pool
3) create a 2nd pool
4) zfs send -R firstpool@snap | zfs receive -Fd secondpool
5) remove disk from “firstpool” → pool DEGRADED
6) remove disk from “secondpool” → pool DEGRADED
7) go to “Plugins” and the following error appears:

CallError
[EFAULT] Error occurred getting activated pool: tank thor You have 2 poolsmarked active for iocage usage. Run "iocage activate ZPOOL" on the preferred pool.

Note the typo in the error message: “poolsmarked” (missing space)

Details:

Error: Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/middlewared/plugins/jail_freebsd.py", line 1040, in get_activated_pool
pool = ioc.IOCage(skip_jails=True, reset_cache=True).get('', pool=True)
File "/usr/local/lib/python3.8/site-packages/iocage_lib/iocage.py", line 95, in _init_
self.generic_iocjson = ioc_json.IOCJson()
File "/usr/local/lib/python3.8/site-packages/iocage_lib/ioc_json.py", line 1372, in _init_
super()._init_(location, checking_datasets, silent, callback)
File "/usr/local/lib/python3.8/site-packages/iocage_lib/ioc_json.py", line 429, in _init_
self.pool, self.iocroot = self.get_pool_and_iocroot()
File "/usr/local/lib/python3.8/site-packages/iocage_lib/ioc_json.py", line 553, in get_pool_and_iocroot
pool = get_pool()
File "/usr/local/lib/python3.8/site-packages/iocage_lib/ioc_json.py", line 476, in get_pool
raise RuntimeError(f'{pools}\nYou have {len(matches)} pools'
RuntimeError: tank
thor
You have 2 poolsmarked active for iocage usage.
Run "iocage activate ZPOOL" on the preferred pool.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/middlewared/main.py", line 137, in call_method
result = await self.middleware._call(message['method'], serviceobj, methodobj, params, app=self,
File "/usr/local/lib/python3.8/site-packages/middlewared/main.py", line 1206, in _call
return await self.run_in_executor(prepared_call.executor, methodobj, *prepared_call.args)
File "/usr/local/lib/python3.8/site-packages/middlewared/main.py", line 1110, in run_in_executor
return await loop.run_in_executor(pool, functools.partial(method, *args, **kwargs))
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.8/site-packages/middlewared/schema.py", line 977, in nf
return f(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/middlewared/plugins/jail_freebsd.py", line 1042, in get_activated_pool
raise CallError(f'Error occurred getting activated pool: {e}')
middlewared.service_exception.CallError: [EFAULT] Error occurred getting activated pool: tank
thor
You have 2 poolsmarked active for iocage usage.
Run "iocage activate ZPOOL" on the preferred pool.

However, running “iocage activate <pool>” fails as well:

root@freenas[~]# iocage activate tank
Traceback (most recent call last):
File "/usr/local/bin/iocage", line 10, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 764, in _call_
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/iocage_cli/activate.py", line 37, in cli
ioc.IOCage(activate=True).activate(zpool)
File "/usr/local/lib/python3.8/site-packages/iocage_lib/iocage.py", line 377, in activate
pool.activate_pool()
File "/usr/local/lib/python3.8/site-packages/iocage_lib/pools.py", line 37, in activate_pool
raise PoolNotActivated(
iocage_lib.ioc_exceptions.PoolNotActivated: Please check pool status, it should be ONLINE

root@freenas[~]# zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
freenas-boot 14.9G 11.4G 3.44G - - - 76% 1.00x ONLINE -
tank 16.2T 13.0T 3.21T - - 14% 80% 1.00x DEGRADED /mnt
thor 21.8T 8.17T 13.6T - - 0% 37% 1.00x DEGRADED /mnt

There's no way to mark the active pool for iocage in the GUI. And also the suggested command “iocage activate tank” fails, because the pool is degraded.

The result is there are jails running now and there's no way to stop them or enter the jails or plugins section in the GUI.

Problem/Justification

None

Impact

None

SmartDraw Connector

Katalon Manual Tests (BETA)

Activity

Show:

Bug Clerk January 14, 2021 at 7:38 PM

Marco January 8, 2021 at 7:17 PM

I was able to reproduce this in a VM. I've attached the debug of that VM in case you need it.

Marco December 21, 2020 at 9:30 PM

I have attached the debug output from the console (freenas-debug -A) because the “Save Debug” fails () in this case.

Bonnie Follweiler December 21, 2020 at 2:10 PM

Thank you for the report .  Can you please provide a debug by navigating to System -> Advanced, click save debug, and upload attachment to this ticket?

Complete

Details

Assignee

Reporter

Labels

Fix versions

Affects versions

Priority

More fields

Katalon Platform

Created December 20, 2020 at 3:02 PM
Updated July 1, 2022 at 4:59 PM
Resolved January 14, 2021 at 7:38 PM