Add psi setup --dry-run for secret state inspection#27
Merged
Conversation
A diagnostic that queries the Podman API for every shell-driver secret, cross-references each against state_dir, and compares stored driver opts against what psi install would generate right now. Classifies each secret as one of: - managed: mapping exists and driver opts match current psi.conf - stale-opts: mapping exists but opts drifted (e.g. token rotated but psi setup has not been re-run) - orphaned: no mapping file in state_dir; lookups would 404 Surfaces the silent-drift problem the token rotation work exposed: secrets created manually via `podman secret create --driver shell` that psi setup never touches, plus secrets left behind by a half-run rotation. Read-only — does not hit Infisical/HSM, does not mutate Podman state, and surfaces Podman API failures as ProviderError so the CLI prints a clean error instead of a traceback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
New diagnostic flag
psi setup --dry-runthat queries the Podman API for every shell-driver secret, cross-references each againststate_dir, and compares stored driver opts against whatpsi installwould generate right now. Classifies each secret as:state_dirand driver opts match currentpsi.confpsi setuphas not been re-run)state_dir; lookups would return 404Read-only: does not hit Infisical/HSM, does not mutate Podman state, and surfaces Podman API failures as
ProviderErrorso the CLI prints a clean error instead of a traceback.Why
Surfaces the silent-drift problem the token rotation work exposed: secrets created manually via
podman secret create --driver shellthatpsi setupnever touches, plus secrets left behind by a half-run rotation. We want to see the real state of a production deployment before deciding the shape of any cleanup or schema changes.Test plan
pytest tests/test_dry_run_setup.py— unit tests for_parse_driver_opts(opts extraction from generated TOML),_classify_secrets(managed / stale-opts / orphaned / mixed / missing-name edge cases), anddry_run_setupitself (Podman API failure wrapping and end-to-end report with no filesystem mutations).ruff check/ruff format --check/ty check— clean.sudo podman exec psi-secrets psi setup --dry-runand review the report.