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

@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 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.34%. Comparing base (f407f97) to head (d7f756f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3884   +/-   ##
=======================================
  Coverage   26.33%   26.34%           
=======================================
  Files         465      465           
  Lines       24951    24953    +2     
=======================================
+ Hits         6572     6574    +2     
  Misses      17661    17661           
  Partials      718      718           
Flag Coverage Δ
unit-tests 26.34% <ø> (+<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

2 similar comments
@pujitha24

Copy link
Copy Markdown
Contributor Author

/retest

@jkhelil

jkhelil commented Aug 11, 2026

Copy link
Copy Markdown
Member

/retest

@jkhelil

jkhelil commented Aug 11, 2026

Copy link
Copy Markdown
Member

/lgtm

@jkhelil

jkhelil commented Aug 11, 2026

Copy link
Copy Markdown
Member

@enarha @khrm PTAL

@tekton-robot tekton-robot added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Aug 11, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@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 jkhelil 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

@jkhelil jkhelil closed this Aug 14, 2026
@jkhelil jkhelil reopened this Aug 14, 2026
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>
@pujitha24

Copy link
Copy Markdown
Contributor Author

Tide was flagging this as unmergeable because the branch had a merge commit from syncing upstream/main, which a clean rebase can't replay past a later commit (39604bf5d) touching the same function. Rebased onto current main and resolved it so history is linear again — no logic changes, the two touched files are byte-identical to what was already passing CI here. Tests and build still pass locally.

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.

3 participants