logging: migrate both binaries to projecteru2/core/log - #43
Merged
Merged
Conversation
controller-runtime and klog log through logr. New(ctx) returns a logr.Logger whose sink forwards each line to projecteru2/core/log, so both binaries and vk-sandbox keep one log stream. Only V(0) passes; Error(nil) becomes a warning because core/log drops a nil err. Adds github.com/projecteru2/core v0.1.5.
Both binaries set up core/log from OPERATOR_LOG_LEVEL (default info, zerolog level names; an unknown level exits 1 with "setup log:") and route controller-runtime through pkg/logbridge; sandbox-apiserver also routes klog there, tagged klog, so the generic apiserver's output joins the same stream. Level mapping: logr Info -> Info, V(1).Info -> Debug, Error(err) -> Error with err structural, klog InfoS/ErrorS in cmd -> Info/Error, klog.ErrorS + os.Exit(1) in envd-proxy main -> Fatalf. The warm-pool driver's no-token skip moves from Info to Warn: logr has no warn level, and a fail-closed skip is degradation, not normal operation. Packages log through log.WithFunc at the log site, so the claim, list and proxy request paths build no logger on success. e2bcompat's writeVerbError/writeLookupError take the request instead of the id, which they now read from the sandboxID path value, so the error log has the request context. Exported surface removed: scale.WithLogger, warmpool.Options.Log, e2bcompat.Options.Log, envdproxy.Options.Log. Callers and tests drop the logr.Discard() argument; no test asserted on a log line.
client-go's flowcontrol and reflector lines in the proxy stayed in klog's own stderr format; one binary now has one stream, as the apiserver does.
logr and klog.Errorf/Errorln pass Error(nil, ...) for an error with no value; the bridge logged it as a warning, so OPERATOR_LOG_LEVEL=error filtered real errors such as an apiserver shutdown timeout. core/log drops a nil err, so the message becomes the err instead.
CMGS
force-pushed
the
review/core-log-0924
branch
from
September 24, 2026 03:45
866f739 to
e516e18
Compare
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.
Both binaries move from logr + klog to
github.com/projecteru2/core/log, the logger the rest of the cocoon family uses. Rebased onto master after #42 merged.What changes
pkg/logbridge(new): alogr.LogSinkthat writes through core/log, the same shape as cocoon-operator'slogbridge.go.logbridge.New(ctx)returns alogr.Logger;Enabledkeeps level 0 only (V(1+) is dropped, which is today's verbosity 0),Error(nil, …)(what logr andklog.Errorf/Errorlnpass for an error with no value) stays at error level with the message as the error, since core/log drops a nil err, key/value pairs render ask=v. vk-sandbox consumes this package too.sandbox-apiserver:log.SetupLogfromOPERATOR_LOG_LEVEL(defaultinfo, zerolog level names; an unknown level exits 1 withsetup log:), thenctrl.SetLogger(logbridge.New(ctx))andklog.SetLogger(logbridge.New(ctx).WithName("klog")), so the generic apiserver's klog output joins the same stream.sandbox-envd-proxy: the same setup,ctrl.SetLoggerandklog.SetLogger(client-go's flowcontrol and reflector lines join the stream too);klog.ErrorS+os.Exit(1)becomesFatalf.log.WithFunc("pkg.Func")at the log site, so the claim, list and proxy request paths build no logger on success. Level mapping: logrInfo→Info,V(1).Info→Debug,Error(err, …)→Errorwith the error structural. One level change: the warm-pool driver's no-token skip moves from Info to Warn (logr has no warn level; a fail-closed skip is degradation).writeVerbError/writeLookupErrortake the request instead of the id (which they read from thesandboxIDpath value, as every caller did), so the error log carries the request context.scale.WithLogger,warmpool.Options.Log,e2bcompat.Options.Log,envdproxy.Options.Log. Callers and tests drop thelogr.Discard()argument; no test asserted on a log line, so none is deleted.github.com/projecteru2/core v0.1.5(the family's current pin; the one-version rule is tracked in Org upkeep: lint baseline (revive, nolintlint) and tool/toolchain pin refresh across the family .github#1 §6).go-logr/logrstays (the bridge implements its sink),klog/v2stays (klog.SetLogger).configuration.mddocuments the core/log stream andOPERATOR_LOG_LEVEL.LOC
Prod +163 / −94 (net +69): the bridge is 60 of those lines and is the family's controller-runtime pattern shared with vk-sandbox; the rest is
log.WithFunc(…)and the level/setup blocks replacing shorter logr calls. Tests +36 (the bridge test). Comment lines +3 / −4.Gates (re-run at the PR head)
make lint: 6 ×0 issues.(both GOOS, with and without each harness tag);make fmt-checkrc=0.asl -forwarder=false: 0 findings on darwin and linux, with and without each harness tag.go test -race -count=1 ./...: 9 packages ok;go veton both tagged harnesses ok;go mod tidyno diff;make generate/make api-docsno diff.OPERATOR_LOG_LEVEL=loudexits 1 withsetup log: Unknown Level String: 'loud'on both binaries; withdebug, both print their start line through core/log (INF starting sandbox-apiserver … func=main.run), controller-runtime's config error arrives through the bridge (func=controller-runtime.client.config), and envd-proxy's exit is theFTL … func=mainline.pkg/logbridgetest:Errorwith and without an err value logs at error level with its name, message and key/values; it fails on a warn downgrade. Routing also checked from a scratch program: named/valued controller-runtime lines,klog.InfoS/ErrorSunderfunc=klog, V(1)+ dropped.