feat(fleet): profile catalog CRUD and apply-to-node with drift-ready store#49
Merged
Conversation
Store profiles as name plus the marshaled cryptos.v1.CertificateProfile, so the catalog is a lossless superset a node accepts verbatim. Add Profile, CreateProfile, UpdateProfile, and DeleteProfile to the Store interface, backed by both the Postgres and in-memory implementations. A v2 migration drops and recreates the profiles table with (name, spec bytea); profiles are seeded and not operator-critical pre-GA, so the reseed is acceptable. The seed builds each built-in as a full CertificateProfile. Refs #31
ListProfiles now unmarshals each stored profile into the full cryptos.v1.CertificateProfile a node also uses. Add CreateProfile, UpdateProfile, and DeleteProfile, all admin-gated with one audit event per successful write and none on failure, mapping a name collision to AlreadyExists and an absent profile to NotFound. ApplyProfileToNode reuses the S5 whole-config-safe path: it fetches the node's full config, clones it, inserts-or-replaces the named profile in pki.profiles[] matched by name, and applies the whole config back, so management and every other node-config field survive. Refs #31
3 tasks
# Conflicts: # go.mod # go.sum
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.
What and why
Turns the read-only seeded profile catalog into a fleet-managed one. The catalog now persists the full cryptos.v1.CertificateProfile a node also uses, so a catalog profile applies to a node verbatim and drift is a proto compare.
Merge order: the api PR (CryptOS-PKI/api#60) must merge first; this branch consumes the api change as a branch pseudo-version until then. After api merges, go.mod re-pins to merged-main. This supersedes the housekeeping api re-pin in manager#48.
Closes #31
Part of #24
Verification
task ci: gofmt, vet, golangci-lint 0 issues)task citest) including Postgres integration tests run against a throwaway postgres:18-alpine with MANAGER_TEST_DATABASE_URL set and -racego build ./...)task license)How this was verified
task cigreen with the Postgres integration tests actually executing (not skipped) against a real postgres:18-alpine on a throwaway port with -race; the v1 and v2 migrations applied and the profiles table verified as (name text PK, spec bytea).task licensereports every file carries the header. The whole-config safety test proves management and other node-config fields survive ApplyProfileToNode.