Repository navigation
Conversation
d97ddd3 to
df27e3d
Compare
df27e3d to
846e006
Compare
Limit cryptsetup to 300 seconds and udevadm to 60 seconds so stalled device operations return control to the caller. Assisted-by: OpenCode (DeepSeek v4.1 Flash) Co-authored-by: Billy Olsen <billy.olsen@canonical.com> Co-authored-by: Lucas Payne <lucas.payne@canonical.com> Co-authored-by: Heather Lanigan <heather.lanigan@canonical.com> Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
Return JSON for successful device setup and controlled failures. Validate configuration errors and preserve explicit retryable and unexpected exit codes. Assisted-by: OpenCode (DeepSeek v4.1 Flash) Co-authored-by: Billy Olsen <billy.olsen@canonical.com> Co-authored-by: Lucas Payne <lucas.payne@canonical.com> Co-authored-by: Heather Lanigan <heather.lanigan@canonical.com> Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
846e006 to
49d7ef8
Compare
| """Test case base class for all functional tests.""" | ||
|
|
||
| #: KV secrets engine version under test. | ||
| kv_version = '1' |
There was a problem hiding this comment.
question: why default to the old version and not the newest?
There was a problem hiding this comment.
For this test fixture, I kept v1 to preserve what it used before this change. The KV v2 test class overrides it with kv_version = '2'
| #: Maximum time to wait for a cryptsetup command. | ||
| CRYPTSETUP_TIMEOUT_SECONDS = 300 | ||
|
|
||
| #: Maximum time to wait for a udevadm command. | ||
| UDEVADM_TIMEOUT_SECONDS = 60 | ||
|
|
There was a problem hiding this comment.
question: where did the values of 300 and 60 seconds come from? It'd be handy to have a comment to tell us.
There was a problem hiding this comment.
These are initial limits to stop a stuck command from waiting forever, they are initial defaults rather than limits based on benchmarks. We give 5 minutes for cryptsetup for slower device I/O and a 1 minute limit for udevadm
| :param: args: argparser generated cli arguments | ||
| :param: args: parsed command-line arguments | ||
| :param: client: hvac.Client for Vault access | ||
| :param: config: configparser object of vaultlocker config | ||
| :param: config: parsed vaultlocker configuration |
There was a problem hiding this comment.
nit: both ways of describing args and config params are used throughout this file, although the argparser and configparser variants are much more common. We should use a consistent format throughout.
There was a problem hiding this comment.
Updated, thanks Lucas!
Reconcile Vault and LUKS state before mutation, preserve operation keys across retries, and fail closed on conflicts or inconclusive device state. Assisted-by: OpenCode (DeepSeek v4.1 Flash) Co-authored-by: Billy Olsen <billy.olsen@canonical.com> Co-authored-by: Lucas Payne <lucas.payne@canonical.com> Co-authored-by: Heather Lanigan <heather.lanigan@canonical.com> Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
Run encryption, decryption, enrollment, and Vault key-conflict scenarios against both supported KV engine versions. Assisted-by: OpenCode (DeepSeek v4.1 Flash) Co-authored-by: Raven Kaur <raven.kaur@canonical.com> Co-authored-by: Lucas Payne <lucas.payne@canonical.com> Co-authored-by: Heather Lanigan <heather.lanigan@canonical.com> Signed-off-by: Raven Kaur <raven.kaur@canonical.com>
49d7ef8 to
922ee7c
Compare
Summary
This change makes
vaultlocker encryptandvaultlocker enrollsafe for a caller to run again after a failure.The commands check the existing device and Vault state before continuing. Successful commands return the LUKS UUID and mapper path as JSON. Failures return an error message as JSON.
This builds on the snap and boot-unlock work in #31.
Why
A Vaultlocker operation can fail after part of the work has already completed. For example, a device may have been formatted successfully even if
cryptsetuptimed out before reporting success.We should be able to call Vaultlocker again without formatting the device again, overwriting a Vault key, or adding another managed key.
Safe to retry means that it is safe to run the command again. It does not mean that the next attempt will succeed. Configuration, credentials, Vault availability, or device state still need to be fixed first.
Changes
cryptsetupandudevadmcommands so a stuck device command cannot block forever.luks_uuidandmapper_pathas JSON after a successfulencryptorenroll.luksFormatorluksAddKeyreports an error or timeout.Command results
Successful
encryptandenrollcommands return:{ "luks_uuid": "<device UUID>", "mapper_path": "/dev/mapper/crypt-<device UUID>" }Failures return an error as JSON on stderr:
{ "error": "<message>" }Handled failures exit with code 3. Unexpected failures exit with code 1.
Manual testing
Built the snap and tested in a LXD vm with a scratch device: