@@ -116,7 +116,7 @@ func CompareDeclarativeErrorsAndEmitMismatches(ctx context.Context, imperativeEr
116
116
mismatchDetails := gatherDeclarativeValidationMismatches (imperativeErrs , declarativeErrs , takeover )
117
117
for _ , detail := range mismatchDetails {
118
118
// Log information about the mismatch using contextual logger
119
- logger .Info ( detail )
119
+ logger .Error ( nil , detail )
120
120
121
121
// Increment the metric for the mismatch
122
122
validationmetrics .Metrics .IncDeclarativeValidationMismatchMetric ()
@@ -231,20 +231,20 @@ func createDeclarativeValidationPanicHandler(ctx context.Context, errs *field.Er
231
231
// If takeover is enabled, output as a validation error as authoritative validator panicked and validation should error
232
232
* errs = append (* errs , field .InternalError (nil , fmt .Errorf (errorFmt , r )))
233
233
} else {
234
- // if takeover not enabled, log the panic as an info message
235
- logger .Info ( fmt .Sprintf (errorFmt , r ))
234
+ // if takeover not enabled, log the panic as an error message
235
+ logger .Error ( nil , fmt .Sprintf (errorFmt , r ))
236
236
}
237
237
}
238
238
}
239
239
}
240
240
241
- // withRecover wraps a validation function with panic recovery logic.
241
+ // panicSafeValidateFunc wraps a validation function with panic recovery logic.
242
242
// It takes a validation function with the ValidateDeclaratively signature
243
243
// and returns a function with the same signature.
244
244
// The returned function will execute the wrapped function and handle any panics by
245
245
// incrementing the panic metric, and logging an error message
246
246
// if takeover=false, and adding a validation error if takeover=true.
247
- func withRecover (
247
+ func panicSafeValidateFunc (
248
248
validateFunc func (ctx context.Context , options sets.Set [string ], scheme * runtime.Scheme , obj runtime.Object ) field.ErrorList ,
249
249
takeover bool ,
250
250
) func (ctx context.Context , options sets.Set [string ], scheme * runtime.Scheme , obj runtime.Object ) field.ErrorList {
@@ -255,13 +255,13 @@ func withRecover(
255
255
}
256
256
}
257
257
258
- // withRecoverUpdate wraps an update validation function with panic recovery logic.
258
+ // panicSafeValidateUpdateFunc wraps an update validation function with panic recovery logic.
259
259
// It takes a validation function with the ValidateUpdateDeclaratively signature
260
260
// and returns a function with the same signature.
261
261
// The returned function will execute the wrapped function and handle any panics by
262
262
// incrementing the panic metric, and logging an error message
263
263
// if takeover=false, and adding a validation error if takeover=true.
264
- func withRecoverUpdate (
264
+ func panicSafeValidateUpdateFunc (
265
265
validateUpdateFunc func (ctx context.Context , options sets.Set [string ], scheme * runtime.Scheme , obj , oldObj runtime.Object ) field.ErrorList ,
266
266
takeover bool ,
267
267
) func (ctx context.Context , options sets.Set [string ], scheme * runtime.Scheme , obj , oldObj runtime.Object ) field.ErrorList {
@@ -292,7 +292,7 @@ func withRecoverUpdate(
292
292
// conversion fails, or if a panic occurs during validation when
293
293
// takeover is true.
294
294
func ValidateDeclarativelyWithRecovery (ctx context.Context , options sets.Set [string ], scheme * runtime.Scheme , obj runtime.Object , takeover bool ) field.ErrorList {
295
- return withRecover (ValidateDeclaratively , takeover )(ctx , options , scheme , obj )
295
+ return panicSafeValidateFunc (ValidateDeclaratively , takeover )(ctx , options , scheme , obj )
296
296
}
297
297
298
298
// ValidateUpdateDeclarativelyWithRecovery validates obj and oldObj against declarative
@@ -315,5 +315,5 @@ func ValidateDeclarativelyWithRecovery(ctx context.Context, options sets.Set[str
315
315
// conversion fails, or if a panic occurs during validation when
316
316
// takeover is true.
317
317
func ValidateUpdateDeclarativelyWithRecovery (ctx context.Context , options sets.Set [string ], scheme * runtime.Scheme , obj , oldObj runtime.Object , takeover bool ) field.ErrorList {
318
- return withRecoverUpdate (ValidateUpdateDeclaratively , takeover )(ctx , options , scheme , obj , oldObj )
318
+ return panicSafeValidateUpdateFunc (ValidateUpdateDeclaratively , takeover )(ctx , options , scheme , obj , oldObj )
319
319
}
0 commit comments