Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicate which node is missing agenix and agenix-rekey modules #56

Conversation

LoganBarnett
Copy link
Contributor

Note: This is just error enhancement.

When running agenix rekey, if a node (typically a host) doesn't have both agenix and agenix-rekey included as modules, you will see an error like this:

       error: attribute 'age' missing
       at /nix/store/zy9vgszqqqh51wmk8cjj6hghx6fydwbi-source/apps/rekey.nix:41:43:
           40|
           41|   nodesWithDerivationStorage = filter (x: x.config.age.rekey.storageMode == "derivation") (attrValues nodes);
             |                                           ^
           42|

This error doesn't tell you which host is missing the modules, let alone that the modules should be included. The agenix rekey tool has this information available and can provide it upon encountering this issue. These changes will detect the missing keys and halt with an error indicating which node is causing the problem and that the required modules (agenix and agenix-rekey) must be included. The user will still encounter the error in the same place and there is no change in actual functionality. Now this is what they will see:

       error: Node "my-host" is missing the agenix module.
       agenix-rekey cannot continue until all nodes include the agenix module.

When only agenix-rekey is missing:

       error: Node "my-host" is missing the agenix-rekey module.
       agenix-rekey cannot continue until all nodes include the agenix-rekey module.

When running `agenix rekey`, if a node (typically a host) doesn't have both
`agenix` and `agenix-rekey` included as modules, you will see an error like
this:

```
       error: attribute 'age' missing
       at /nix/store/zy9vgszqqqh51wmk8cjj6hghx6fydwbi-source/apps/rekey.nix:41:43:
           40|
           41|   nodesWithDerivationStorage = filter (x: x.config.age.rekey.storageMode == "derivation") (attrValues nodes);
             |                                           ^
           42|
```

This error doesn't tell you which host is missing the modules, let alone that
the modules should be included.  The `agenix rekey` tool has this information
available and can provide it upon encountering this issue.  These changes will
detect the missing keys and halt with an error indicating which node is causing
the problem and that the required modules (`agenix` and `agenix-rekey`) must be
included.  The user will still encounter the error in the same place and there
is no change in actual functionality.  Now this is what they will see:

```
       error: Node "my-host" is missing the agenix module.
       agenix-rekey cannot continue until all nodes include the agenix module.
```

When only `agenix-rekey` is missing:

```
       error: Node "my-host" is missing the agenix-rekey module.
       agenix-rekey cannot continue until all nodes include the agenix-rekey module.
```
@LoganBarnett
Copy link
Contributor Author

Looks like the branch build is failing on account of a formatting issue. I was originally working on this from an older version where the formatting was different. I thought the new formatting got picked up (there were changes made). Computers are hard to use 😅

I'll get it addressed next time I'm behind my machine.

@LoganBarnett
Copy link
Contributor Author

I think I misread my email. Looks like it's passing here! Must've been one of my earlier commits before I'd rebased things.

@skrobul
Copy link

skrobul commented Dec 8, 2024

I am not an author or maintainer, but just wanted to thank you for this PR - I spent several hours trying to troubleshoot this error and triple checking the steps executed against the project's README. It never occurred to me that both agenix and agenix-rekey have to be imported to ALL of the hosts, even if they are used only in one...
The error: attribute 'age' missing message is absolutely useless and this PR pointed me in the right direction, thanks!

@oddlama
Copy link
Owner

oddlama commented Dec 14, 2024

Thanks, this is a great addition :)

@oddlama oddlama merged commit 1472730 into oddlama:main Dec 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants