Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zfs: load keys for encrypted datasets during pool import
If a user has set up their own zpools and given them to us to manage, it's possible they've configured ZFS-native encryption. For the most part, this works completely transparently to us. However, because we manually do zpool-import and zpool-export during startup and shutdown of Incus, ZFS datasets with keys will have their keys unloaded during shutdown and then the keys are not automatically loaded on startup. This results in containers being unable to start on startup because all IOs are blocked indefinitely until the dataset keys are loaded manually by the admin -- even if the admin has configured automatic key loading on their system! The simplest solution would be to pass -l to zfs-import (which causes ZFS to auto-import all keys for all datasets in the pool). However, for users that use keylocation=prompt, doing this naively would result in errors when importing pools (because there is no stdin for the zpool-import command). So we would have to silently ignore errors -- but this would mean we would ignore regular import errors as well. Instead, we do zfs-load-key manually after checking if there are any non-file:// keylocation properties set within the dataset. If there are then we are more forgiving with zfs-load-key errors and output some warnings to tell users why their containers are not starting (previously containers would just fail to start with no explanation). If all of the keys are file:// then we make any load-key errors hard errors to help admins realise their keylocation= configurations are wrong. Signed-off-by: Aleksa Sarai <[email protected]>
- Loading branch information