Fix misleading log line (#101532)

This commit is contained in:
Sarah Zinger
2025-03-03 15:52:47 -05:00
committed by GitHub
parent cedb4ef9c1
commit ed3f96ce28

View File

@ -160,7 +160,19 @@ func (r *queryREST) Connect(connectCtx context.Context, name string, _ runtime.O
// Actually run the query
rsp, err := b.execute(ctx, req)
if err != nil {
b.log.Error("hit unexpected error while executing query, this will show as an unhandled k8s status error", "err", err)
// log unexpected errors
var k8sErr *errorsK8s.StatusError
if errors.As(err, &k8sErr) {
// we do not need to log 4xx errors as they are expected
if k8sErr.ErrStatus.Code >= 500 {
b.log.Error("hit unexpected k8s error while executing query", "err", err, "status", k8sErr.Status())
}
b.log.Debug("sending a known k8s error to the client", "err", err, "status", k8sErr.Status())
} else {
b.log.Error("hit unexpected error while executing query, this will show as an unhandled k8s status error", "err", err)
}
// return the error to the client, will send all non k8s errors as a k8 unexpected error
responder.Error(err)
return
}