Repository navigation
refactor: group node auth and split-migration flags (M2, part 3) - #1439
Merged
Merged
Conversation
Move the Admin gRPC token and insecure mode, the split-migration token and peer-auth enforcement switch, peer gRPC TLS and the S3 blob peer token into nodeAuthFlags, passed down from run(). The split-migration readiness gate becomes a method on nodeAuthFlags. The distribution server, the split-job and ownership-refresh runners and the raft gRPC servers (through adminGRPCInterceptors) receive its method value; a missing gate fails closed. configureAdminService takes nodeAuthFlags instead of four positional values. The protected-bootstrap check that the startup token differs from the service tokens gets the token files through raftBootstrapConfig, so it still runs before any group opens. Flag names, defaults and usage text are unchanged (identical -help output). Tests build nodeAuthFlags values instead of overwriting globals. Signed-off-by: bootjp <contact@bootjp.me>
Signed-off-by: bootjp <contact@bootjp.me>
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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. |
Base automatically changed from
design/root-package-decomposition-m2b
to
main
November 12, 2026 14:18
bootjp
added a commit
that referenced
this pull request
Nov 12, 2026
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 from `run()`. ## Changes - `encryptionFlags` (`main_encryption_kek.go`) holds `--encryptionSidecarPath`, `--encryption-enabled`, `--encryption-rotate-on-startup`, `--kekFile` and `--kekUri`. The flag comments moved onto the struct. - These functions now take the flags as a parameter: `loadKEKAfterPreNonceStartupGuards`, `loadKEKAndRunStartupGuards`, `verifyKEKBeforeMutators`, `loadKEKWrapperFromFlags` (renamed from `loadKEKWrapperFromFlag`) and `encryptionMutatorsEnabled`. `startRaftServers` gets the flags through `serversInput` / `runtimeServerRunner`. - Protected bootstrap admission needs only two facts: whether encryption is configured (enabled, or a sidecar path is set) and whether a startup rotation was requested. - Those two facts now travel as `bootstrapEncryptionRequest` in `raftBootstrapConfig`. - `loadProtectedBootstrapDomain` takes the whole `raftBootstrapConfig`. - The bootstrap domain keeps the request, and WAL recovery uses it to decide whether the encryption registration is "not configured". - Tests: - The bootstrap e2e fixtures and the KEK and metrics tests pass flag values directly instead of overwriting process globals. - Two of those tests are now `t.Parallel`. - `raftBootstrapPeerConfigDir` is still a global and is still set by the e2e fixtures. ## Behavior change None. Flag names, defaults and help text are unchanged: `-help` output 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()` setting `bootstrapCfg.encryption` right after `resolveNetworkRuntimeInputs`, before `buildShardGroupsWithEncryptionWiring` reads 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. - `-help` output: identical to the base binary. - Test list: identical apart from the new `TestEncryptionFlagsBootstrapRequest`. - Jepsen: not run. Nothing in replication, MVCC or OCC changed. ## Self-review 1. **Data loss**: no change to the apply, persist or sidecar write paths. 2. **Concurrency**: the flag values are immutable after parsing, and the bootstrap domain stores the request once at construction. 3. **Performance**: no hot path is involved. 4. **Consistency**: the KEK guards, mutator gate, bootstrap admission and recovery registration all read the same values as before. 5. **Test coverage**: a new table test covers `bootstrapRequest()` / `requested()`. The existing KEK, bootstrap-domain and rotation e2e tests now pass these values explicitly. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **改善** * 暗号化とKEKの設定を起動処理や保護されたブートストラップで一貫して扱うようになりました。 * 暗号化が構成されているかどうかに応じて、ブートストラップ時の復旧状態を適切に判定します。 * テストで暗号化設定を個別に扱えるようになり、テスト間で設定が影響しにくくなりました。 <!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.
Design: docs/design/2026_11_12_partial_root_package_decomposition.md
Stacked on #1438 (M2 part 2), which is stacked on #1437. Retarget each to
mainas the one below it merges.What
Third part of M2 (typed flag config). The node auth flags become
nodeAuthFlags(main_node_auth.go):adminTokenFile/adminInsecureNoAuthsplitMigrationTokenFile/splitMigrationPeerAuthEnforcedgrpcTLSCAFile/grpcTLSCertFile/grpcTLSKeyFiles3BlobPeerTokenFileThese flags were read in many places, so some call paths change:
Split-migration readiness gate.
splitMigrationLocalReadinessGatebecomes a method onnodeAuthFlags. Its method value is handed to:startDistributionSplitJobRunner/startMigrationOwnershipRefreshadminGRPCInterceptors.migrationReadyfield. They apply it in the coverage interceptor (nownewMigrationCoverageUnaryGate(ready)) and inmigrationOwnershipRuntimeReady.The new
migrationReadinessGatetype fails closed when nil. Production always sets it; the nil branch keeps a future caller that forgets it from opening migration.configureAdminServicetakesnodeAuthFlagsinstead of four positional token/insecure values, and no longer reads the enforcement global.setupAdminServicetakes it fromserversInput.Peer TLS and start-up validation.
configureNodeGRPCTransport(nodeAuth)handles both.resolveNetworkRuntimeInputstakesnodeAuth.Protected bootstrap. The check that the startup token differs from the Admin, migration and S3 peer tokens used to read the three globals deep inside
loadProtectedBootstrapDomain. It now gets the token files throughraftBootstrapConfig.serviceTokenFiles, whichbuildShardGroupsalready receives. The check still runs before any group is opened.S3 blob cluster. The runner reads its token files from
runtimeServerRunner.nodeAuth.Still package globals after this PR:
Behavior change
None intended. Flag names, defaults and usage strings are unchanged:
-helpoutput is identical to the base. The readiness gate used to read the globals on each call. It now reads the parsed values bound at start-up, and nothing mutates these flags after parsing.Tests
nodeAuthFlagsvalues.enableMigrationRuntimeFlagsreturns one.*nodeAuthFlagsinassertMigrationRuntimeFlagsRequired).newOwnershipRefreshRaftNodetakes the gate explicitly. The refresh test keeps the default posture (gate closed), and the readiness tests pass their enabled one, matching what each saw through the globals before.TestMigrationReadinessGateMissingFailsClosed,TestValidateBootstrapStartupTokenRejectsServiceTokenReuse(that path had no direct test), andTestNodeAuthServiceTokenFilesCoverEveryServiceToken. The flag-binding test now covers node auth too.Verification
go build ./...,go vet .,golangci-lint(0 issues), importguardgo test -race -count=1 .: ok (224s)-runover the migration/admin/bootstrap tests) reported FAIL. I did not keep its output, so I cannot say which test failed or why. Two reruns of the same set and the full suite passed, so it may be an existing flaky e2e test, but that is not confirmed. Worth watching in CI.Self-review