Skip to content

fix(api) Improve reporting of log backend failures - #1489

Open
enarha wants to merge 2 commits into
tektoncd:mainfrom
enarha:fix-error-msg-logs-deleted-ns
Open

fix(api) Improve reporting of log backend failures#1489
enarha wants to merge 2 commits into
tektoncd:mainfrom
enarha:fix-error-msg-logs-deleted-ns

Conversation

@enarha

@enarha enarha commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Changes

The PR intentionally includes two commits. First one improves the reporting of log backend failures with accurate status codes. The second one improves propagation of the log backend errors from streaming GetLog. Check the actual commit messages for more details.

/kind misc

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you review them:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Tested your changes locally (if this is a code change)
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user-facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contain the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

Log retrieval flattened every backend failure to codes.Internal, so the
HTTP handler always returned 500. After a run's namespace is deleted the
LokiStack gateway returns 403, which surfaced as an opaque 500 with no
indication that the failure was an authorization decision.

Map backend HTTP status codes to the corresponding gRPC codes for the
Loki, Splunk and Blob backends, map transport-level failures to
DeadlineExceeded or Unavailable, and have LogMux derive the HTTP status
from the resulting gRPC code instead of hardcoding 500.

Backend 400 responses and blob InvalidArgument errors are deliberately
reported as Internal: the queries and object keys are built by the API
server from its own configuration, never from caller input, so a
rejected request is a server-side defect rather than a bad request.

Also correct a logging statement in the Splunk fetch-log path that
reported the job-creation status code instead of the fetch response's.

Signed-off-by: Emil Natan <ena@redhat.com>
Assisted-by: Claude Opus 5 <noreply@anthropic.com>
The gRPC GetLog handler logged errors returned by the log backend and
then returned nil, so clients received an empty but successful stream
when log retrieval failed.

Return the error instead, preserving the status code produced by the
backend, and normalise errors that carry no gRPC status to Internal
rather than letting gRPC default them to Unknown.

Signed-off-by: Emil Natan <ena@redhat.com>
Assisted-by: Claude Opus 5 <noreply@anthropic.com>
@tekton-robot tekton-robot added kind/misc Categorizes issue or PR as a miscellaneuous one. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Sep 13, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from enarha after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@enarha
enarha removed the request for review from divyansh42 September 13, 2026 18:53
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 13, 2026
@enarha
enarha requested a balanced review from Copilot September 13, 2026 18:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Blob HTTP streaming can retain status 200 after failures, while Splunk polling errors remain misclassified.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Improves log-backend failure reporting across gRPC and HTTP APIs.

Changes:

  • Maps HTTP, transport, and blob failures to appropriate gRPC/HTTP statuses.
  • Propagates streaming GetLog errors.
  • Adds error-mapping and integration tests.
File summaries
File Description
plugin_logs.go Implements backend error mapping and propagation.
plugin_logs_getlog_test.go Tests gRPC error propagation.
plugin_logs_errorcodes_test.go Tests mappings and backend failures.
export_test.go Exposes internal helpers to external tests.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if err != nil {
s.logger.Errorf("error creating bucket reader: %s for log part: %s", err, part)
return err
return blobError(err, "error reading log storage object")
Comment on lines +716 to +717
return status.Errorf(httpStatusToCode(resp.StatusCode),
"splunk log backend search job creation failed with HTTP %d (%s)", resp.StatusCode, http.StatusText(resp.StatusCode))
Comment on lines +290 to +296
mock := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/services/search/v2/jobs" {
w.WriteHeader(tc.httpStatus)
return
}
w.WriteHeader(http.StatusOK)
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/misc Categorizes issue or PR as a miscellaneuous one. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants