feat: Reinit server with token on demand, enable reusing exisitng configuration in all modes, update error output #210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix is tied to the issue I opened (#209), below is a review of what I aim to solve here.
Please let me know if this belongs in a
renovate/
branch!Problem Analysis
Panic when running in other modes without configuration
I noticed this when playing with attic, trying to run in
api-server
mode with no config panicked every time.atticd --api-server
without a pre-existing configuration file causes a panic.run_oobe
function, responsible for generating default configurations and tokens, is bypassed when the server is executed in API Server mode, leaving the server in an undefined state.Missing Root Token in Monolithic Mode with Pre-Existing Configuration
Scenario: When the server is run in Monolithic Mode with a configuration file that includes an RS256 key, the
run_oobe
function is skipped. This prevents a root token from being generated.Root Cause: The logic incorrectly assumes that the presence of a configuration file implies a fully initialized server, bypassing critical token generation steps.
Impact:
atticadm
generates "do-nothing" tokens, effectively rendering it non-functional.So far, my testing has consisted of trying to work through my desired use case of using this for ci/cd builds. I intend to try deploying this fix within a container and running it there with a sqlite db.
I have also ran the
nix build .
command from the root to ensure the entire project can be recreated. Please let me know if there's other work/testing output you'd like to see!