Skip to content

fix(tektonresult): default watcher logs_api from spec - #3884

Open
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-2600
Open

fix(tektonresult): default watcher logs_api from spec#3884
pujitha24 wants to merge 1 commit into
tektoncd:mainfrom
pujitha24:auto/issue-2600

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Changes

Fixes a bug where setting spec.logs_api: true on a TektonResult (or via TektonConfig) enabled the LOGS_API env var on the tekton-results-api deployment, but did not propagate to the tekton-results-watcher deployment's separate -logs_api flag (which defaults to false). As a result, users following the documented example of only setting the top-level logs_api ended up with an API server that had logging enabled but a Watcher that never forwarded logs, so logs were never stored.

Result.setDefaults() now defaults Result.Watcher.LogsAPI from the top-level ResultsAPIProperties.LogsAPI whenever the user has not explicitly set spec.watcher.logs_api, mirroring the existing RouteEnabled/RouteTLSTermination defaulting in the same function. An explicit spec.watcher.logs_api value is never overridden.

Note: this defaulting runs wherever Result.setDefaults() runs today (i.e. when a TektonResult is created/updated via TektonConfig, the documented install path). TektonResult.SetDefaults does not call Result.setDefaults(), so a CR applied directly as a standalone kind: TektonResult does not get this (or the pre-existing RouteEnabled) default — that gap predates this change and is not addressed here.

Submitter Checklist

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

See the contribution guide for more details.

Release Notes

Fix TektonResult so that setting `spec.logs_api: true` also defaults the tekton-results-watcher's log forwarding flag, ensuring TaskRun/PipelineRun logs are actually stored when the top-level `logs_api` option is enabled.

AI assistance: this change was drafted with Claude Code.

Fixes #2600

Motivation: setting spec.logs_api: true on a TektonResult (or via
TektonConfig) enables the LOGS_API env var on the tekton-results-api
deployment, but the tekton-results-watcher deployment has its own,
separate -logs_api command-line flag that defaults to false. That
flag is what actually makes the Watcher forward TaskRun/PipelineRun
logs to the API server; nothing defaulted it from the top-level
logs_api setting, so users following the documented example (setting
only the top-level logs_api) got an API server with logging enabled
but a Watcher that never sends logs, and logs were never stored.

Approach: default Result.Watcher.LogsAPI from the top-level
ResultsAPIProperties.LogsAPI in Result.setDefaults() whenever the
user has not explicitly set spec.watcher.logs_api, mirroring the
adjacent RouteEnabled/RouteTLSTermination defaulting already in that
function. An explicit spec.watcher.logs_api value is never
overridden.

This defaulting runs wherever Result.setDefaults() runs today, i.e.
when a TektonResult is created/updated via TektonConfig (the
documented install path). TektonResult.SetDefaults does not call
Result.setDefaults() at all, so a CR applied directly as a
standalone `kind: TektonResult` (bypassing TektonConfig) does not
get this or the pre-existing RouteEnabled default either; that gap
predates this change and is not addressed here.

Validation: added TestResult_SetDefaultsWatcherLogsAPI, a table test
covering propagate-true, propagate-false, no-override-when-explicit,
and no-op-when-top-level-unset. Confirmed by temporarily reverting
the fix that the two propagation subtests fail without it and pass
with it:
  go test ./pkg/apis/operator/v1alpha1/... \
    -run TestResult_SetDefaultsWatcherLogsAPI -v
Also ran, all passing:
  go build ./...
  go test ./pkg/apis/operator/v1alpha1/... \
    ./pkg/reconciler/kubernetes/tektonresult/... \
    ./pkg/reconciler/kubernetes/tektonconfig/...
  gofmt -l on both changed files (clean)
golangci-lint could not be run in this sandbox (its download step
fails a checksum check with no network access); go vet ./pkg/apis/
operator/v1alpha1/... was run instead and reported nothing.

Report: tektoncd#2600
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 10, 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 assign enarha after the PR has been reviewed.
You can assign the PR to them by writing /assign @enarha in a comment when ready.

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

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.13%. Comparing base (aadfe5a) to head (2a3bf98).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3884   +/-   ##
=======================================
  Coverage   26.13%   26.13%           
=======================================
  Files         465      465           
  Lines       24933    24935    +2     
=======================================
+ Hits         6516     6518    +2     
  Misses      17697    17697           
  Partials      720      720           
Flag Coverage Δ
unit-tests 26.13% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pujitha24

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@pujitha24

Copy link
Copy Markdown
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The TektonResults component cannot store logs information.

2 participants