Skip to content

Commit b239e96

Browse files
authored
feat: add resource context to validation failure logs (#3323)
Validation failures previously logged only the error message, making it difficult to identify which specific resource failed. The log now includes the name, namespace, and kind fields, providing necessary context for troubleshooting. Issue tektoncd/9358
1 parent 9fb97f5 commit b239e96

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

webhook/resourcesemantics/validation/validation_admit.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *a
188188
}
189189

190190
if result := resource.Validate(ctx); result != nil {
191-
logger.Infow("Failed the resource specific validation", zap.Error(result))
191+
logger.Infow("Failed the resource specific validation",
192+
zap.String("name", req.Name),
193+
zap.String("namespace", req.Namespace),
194+
zap.String("kind", req.Kind.Kind),
195+
zap.Error(result))
192196
// While we have the strong typing of apis.FieldError, partition the
193197
// returned error into the error-level diagnostics and warning-level
194198
// diagnostics, so that the admission response can embed things into

0 commit comments

Comments
 (0)