Commit 7607623
committed
operator: Replace zap logger with global ContextFree logger
The multicluster command constructed its own ctrlzap.New() logger and
passed it to RaftConfiguration.Logger, which forwarded it to the
controller-runtime manager via ctrl.Options.Logger.
Because this logger had a non-nil sink, controller-runtime skipped the
global logger fallback:
if options.Logger.GetSink() == nil {
options.Logger = log.Log // <-- never reached
}
The manager then used this raw zap sink to build per-reconciliation
loggers in reconcileHandler:
log := c.LogConstructor(&req)
ctx = logf.IntoContext(ctx, log)
When reconciler code called otelutil/log.FromContext(ctx), which appends
"ctx", ctx to keysAndValues, the zap sink serialized context.Context as
the full wrapper chain:
"ctx":"context.Background.WithCancel.WithCancel.WithValue(logr...)"
The global logger set by main.go via log.SetGlobals(logger.NewLogger())
wraps non-OTEL sinks with ContextFree, which strips context.Context
values from keysAndValues before they reach the underlying sink. But the
per-command zap logger bypassed SetGlobals entirely, so it never got the
ContextFree wrapper.
Fix by replacing the standalone ctrlzap.New() with log.FromContext(ctx),
which retrieves the global logger already wrapped with ContextFree.
Remove the now-unused --log-level flag and parseLogLevel helper, as log
level is already configured globally via the root command's logOptions.1 parent 51f5a3e commit 7607623
File tree
2 files changed
+13
-40
lines changed- operator/cmd/multicluster
- pkg/multicluster
2 files changed
+13
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | | - | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | | - | |
64 | 62 | | |
65 | 63 | | |
66 | 64 | | |
| |||
141 | 139 | | |
142 | 140 | | |
143 | 141 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | 142 | | |
162 | 143 | | |
163 | 144 | | |
| |||
170 | 151 | | |
171 | 152 | | |
172 | 153 | | |
173 | | - | |
174 | 154 | | |
175 | 155 | | |
176 | 156 | | |
| |||
207 | 187 | | |
208 | 188 | | |
209 | 189 | | |
210 | | - | |
| 190 | + | |
211 | 191 | | |
212 | 192 | | |
213 | 193 | | |
| |||
233 | 213 | | |
234 | 214 | | |
235 | 215 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | 216 | | |
246 | 217 | | |
247 | 218 | | |
248 | 219 | | |
249 | 220 | | |
250 | | - | |
| 221 | + | |
251 | 222 | | |
252 | 223 | | |
253 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
496 | 498 | | |
497 | 499 | | |
498 | 500 | | |
| |||
504 | 506 | | |
505 | 507 | | |
506 | 508 | | |
507 | | - | |
| 509 | + | |
508 | 510 | | |
509 | 511 | | |
510 | 512 | | |
511 | | - | |
| 513 | + | |
512 | 514 | | |
513 | 515 | | |
514 | 516 | | |
| |||
0 commit comments