Repository navigation
refactor: group encryption and KEK flags (M2 part 4) - #1440
Conversation
Move --encryptionSidecarPath, --encryption-enabled, --encryption-rotate-on-startup, --kekFile and --kekUri into encryptionFlags on serverFlags. The KEK load, start-up guards, KEK preflight and EncryptionAdmin mutator gate take it as a parameter. Protected bootstrap admission only needs whether encryption is configured and whether a startup rotation was requested; those travel as bootstrapEncryptionRequest in raftBootstrapConfig and stay on the bootstrap domain for WAL recovery. Bootstrap e2e fixtures and the KEK tests pass values instead of overwriting process globals. No flag name, default or help text changes. Signed-off-by: bootjp <contact@bootjp.me>
Signed-off-by: bootjp <contact@bootjp.me>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Design: docs/design/2026_11_12_partial_root_package_decomposition.md M2 part 5, following #1440. It moves the client-facing listener flags out of package globals into `listenerFlags`, which is registered on the FlagSet and passed down from `run()`. ## Changes - `listenerFlags` (`main_public_servers.go`) holds 15 flags: - Redis: `--redisAddress`, `--redisLuaMaxIdleStates`. - DynamoDB: `--dynamoAddress`. - S3: `--s3Address`, `--s3Region`, `--s3CredentialsFile`, `--s3PathStyleOnly`. - SQS: `--sqsAddress`, `--sqsPublicEndpoint`, `--sqsRegion`, `--sqsCredentialsFile`. - Metrics and pprof: `--metricsAddress`, `--metricsToken`, `--pprofAddress`, `--pprofToken`. - `resolveNetworkRuntimeInputs` → `resolveValidatedRuntimeInputs` → `resolveRuntimeInputs` pass it to `parseRuntimeConfig`. - `serversInput` carries it. The `runtimeServerRunner` fields it already had are now filled from it. - `prepareRedisServer` takes the Lua pool size as a parameter. - `prepareAdminFromFlags` takes the S3 credentials file (the admin listener reuses it) as a parameter. - `--address` stays a global for now. It is the node's Raft address and belongs with the Raft topology flags in the next part. ## Behavior change None. Flag names, defaults and help text are unchanged: `-help` output is identical to the base. ## Risk Low. The values are read-only after parsing, so passing them as copies changes nothing. ## Test evidence - `go test -race -count=1 .`: ok (225s). - `golangci-lint`: 0 issues. - `scripts/check-production-imports.sh`: ok. - `-help` output: identical to the base binary. - Test list: identical apart from the new `TestListenerFlagsDefaultsAndParsing`. - Jepsen: not run. Nothing in replication, MVCC or OCC changed. ## Self-review 1. **Data loss**: no write, apply or persistence path is touched. 2. **Concurrency**: the values are immutable after parsing, and nothing new is shared. 3. **Performance**: start-up only. No hot path is involved. 4. **Consistency**: each listener, leader map and credentials loader gets the same value it read from the global before. 5. **Test coverage**: a new test pins the defaults and the parsing of the S3, SQS and pprof flags. Existing callers of the changed signatures are updated.
Design: docs/design/2026_11_12_partial_root_package_decomposition.md
M2 part 4, following #1437, #1438 and #1439 (all merged). It moves the five encryption flags out of package globals into
encryptionFlags, which is registered on the FlagSet and passed down fromrun().Changes
encryptionFlags(main_encryption_kek.go) holds--encryptionSidecarPath,--encryption-enabled,--encryption-rotate-on-startup,--kekFileand--kekUri. The flag comments moved onto the struct.loadKEKAfterPreNonceStartupGuards,loadKEKAndRunStartupGuards,verifyKEKBeforeMutators,loadKEKWrapperFromFlags(renamed fromloadKEKWrapperFromFlag) andencryptionMutatorsEnabled.startRaftServersgets the flags throughserversInput/runtimeServerRunner.bootstrapEncryptionRequestinraftBootstrapConfig.loadProtectedBootstrapDomaintakes the wholeraftBootstrapConfig.t.Parallel.raftBootstrapPeerConfigDiris still a global and is still set by the e2e fixtures.Behavior change
None. Flag names, defaults and help text are unchanged:
-helpoutput is identical to the base. The bootstrap "requested" and recovery "not configured" conditions compute the same booleans as before.Risk
Low. The flags are read-only after parsing, so passing copies of their values changes nothing at runtime. The one new data path is
run()settingbootstrapCfg.encryptionright afterresolveNetworkRuntimeInputs, beforebuildShardGroupsWithEncryptionWiringreads it.Test evidence
go test -race -count=1 .: ok (225s).go test ./internal/encryption/: ok.golangci-lint: 0 issues.scripts/check-production-imports.sh: ok.-helpoutput: identical to the base binary.TestEncryptionFlagsBootstrapRequest.Self-review
bootstrapRequest()/requested(). The existing KEK, bootstrap-domain and rotation e2e tests now pass these values explicitly.Summary by CodeRabbit