refactor(controller): read env configuration in constructors, not package init - #16702
refactor(controller): read env configuration in constructors, not package init#16702Joibel wants to merge 5 commits into
Conversation
Signed-off-by: Alan Clucas <alan@clucas.org>
…nstructor Signed-off-by: Alan Clucas <alan@clucas.org>
Signed-off-by: Alan Clucas <alan@clucas.org>
…rop GetRequeueTime Signed-off-by: Alan Clucas <alan@clucas.org>
Move the CRON_SYNC_PERIOD env read out of the package init() and into NewCronController, storing it on the new Controller.syncPeriod field and using it in Run instead of the package-level cronSyncPeriod var. The init()-time RFC822 timezone-parse sanity check remains, but no longer involves the init logger: it now simply panics on failure, which writes to stderr with no special handling. Signed-off-by: Alan Clucas <alan@clucas.org>
fd3f362 to
4ad6e80
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughWorkflow and cron controllers now store environment-derived timing and feature settings per instance. Workflow semaphore indexing accepts explicit configuration. Runtime operations use controller fields instead of package-level values. ChangesWorkflow controller configuration
Cron controller configuration
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This refactor relocates configuration reads into constructors without any supplied evidence of a current-head correctness, availability, or deployment risk. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
Part 1 of 3 in a stack that retires
util/logging's init logger (see #16705 for the endgame; follows up on #16693, which fixed the init logger's process-wide signal handler swallowing SIGTERM).Motivation
The init logger exists to buffer log messages emitted before the main logger is configured — almost all of them package-level
var/init()env-config reads. Moving those reads into constructors (where a real, correctly-formatted logger is already in context) removes the need for pre-mainlogging entirely, makes the config values testable witht.Setenv, and turns config echoes into ordinary constructor log lines in the operator's chosen format and level.Modifications
Pure moves of where each env read happens — every variable keeps its exact name and default:
WorkflowControllergains constructor-read fields forINDEX_WORKFLOW_SEMAPHORE_KEYS,CACHE_GC_PERIOD,SEMAPHORE_NOTIFY_DELAY,CACHE_GC_AFTER_NOT_HIT_DURATION,HEALTHZ_AGE,MAX_OPERATION_TIME, andDEFAULT_REQUEUE_TIME; the package-level vars andinit()blocks are deleted. ThenewControllertest helper mirrors each default explicitly.WorkflowSemaphoreKeysIndexFuncbecomes an explicit factory parameter (enabled bool) and the package-levelindexersvar becomesnewIndexers(semaphoreKeysEnabled bool); its tests now cover the disabled branch without env mutation.fixedItemIntervalRateLimitercarries the requeue time as a field; the exported, otherwise-unusedGetRequeueTime()is removed (breaking only for downstream importers — nothing in-repo references it).CRON_SYNC_PERIODmoves intoNewCronController. Theinit()-time RFC822 timezone-parse sanity check remains, but no longer involves the init logger: it now simply panics on failure (stderr, no special handling).Deliberate behavior change: an unparseable duration value now fails at constructor time with a real message (previously it panicked at package-init via the init logger's unimplemented
WithPanic).Verification
go build ./...,golangci-lint(0 issues), andgo test ./workflow/... -count=1all pass (one pre-existing, unrelated environment failure inworkflow/executor/osspecificreproduces identically onmain). Each field's default is asserted equal between constructor and test helper by inspection; the semaphore-index factory gained a new disabled-branch test.Documentation
Not needed: every env var keeps its documented name, default, and semantics;
docs/environment-variables.mdremains accurate.AI
Claude Code planned and implemented this change under human direction, with per-task and whole-branch review passes; the author reviewed and takes responsibility for the result.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SqVAUnuPJZ7sQZCy44bBSE
Summary by CodeRabbit