Skip to content

fix(tektonresult): default route TLS termination to reencrypt - #4029

Open
divyansh42 wants to merge 1 commit into
tektoncd:mainfrom
divyansh42:fix/results-route-reencrypt-tls
Open

fix(tektonresult): default route TLS termination to reencrypt#4029
divyansh42 wants to merge 1 commit into
tektoncd:mainfrom
divyansh42:fix/results-route-reencrypt-tls

Conversation

@divyansh42

@divyansh42 divyansh42 commented Sep 3, 2026

Copy link
Copy Markdown
Member

Changes

The Results API route on OpenShift was defaulting to edge TLS termination,
which causes TLS handshake failures when clients try to connect. The router
terminates TLS at the edge and forwards unencrypted traffic to the gRPC
backend — but the backend only speaks TLS.

Additionally, when passthrough was used as a workaround, clients had to
pass --insecure-skip-tls-verify because the OpenShift service-serving
certificate was not trusted by external clients.

reencrypt is the correct termination type:

  • The router presents a trusted certificate to external clients (no --insecure needed)
  • The router re-encrypts to the backend using the OpenShift service-serving cert
  • End-to-end encryption is maintained

Upgrade migration

Changing the default only affects new installs — existing installs persist
the previous edge value in their TektonConfig/TektonResult CR, so they
would stay broken after upgrading. A version-gated pre-upgrade migration
(migrateResultsRouteTLSToReencrypt) updates the Results route TLS termination
from edgereencrypt on TektonConfig (the source of truth), which then
syncs to the TektonResult CR. It runs on OpenShift only and migrates only
edge; values set manually to reencrypt or passthrough are left untouched.

Changes made

File Change
tektonresult_defaults.go Default route_tls_termination changed from edgereencrypt
route-rbac/rbac.yaml (kodata) Route TLS termination updated from passthroughreencrypt
route-rbac/rbac.yaml (testdata) RBAC resourceNames fixed: tekton-results-api-servicetekton-results-api (matches actual Route name)
tektonresult_validation.go Extracted validateRouteTLSTermination; only edge, reencrypt, passthrough accepted
tektonconfig_validation.go Reject invalid spec.result.route_tls_termination at the parent CR level too
upgrade.go / pre_upgrade.go Added version-gated pre-upgrade migration edgereencrypt
docs/TektonResult.md, docs/TektonConfig.md Document that only reencrypt is supported on OpenShift; note the upgrade migration
*_test.go Tests for defaults, TektonResult/TektonConfig validation, route injection, and the migration

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): change default OpenShift Results API route TLS
termination from `edge` to `reencrypt`, and add a pre-upgrade
migration that flips existing installs from `edge` to `reencrypt`.
This fixes TLS handshake failures and eliminates the need for
`--insecure-skip-tls-verify` when accessing the Results API via the
OpenShift route. Also adds validation to reject unsupported
`route_tls_termination` values.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 3, 2026
@tekton-robot tekton-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 3, 2026
@divyansh42
divyansh42 force-pushed the fix/results-route-reencrypt-tls branch from a1fc393 to 9146282 Compare September 3, 2026 13:55
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 3, 2026
@divyansh42
divyansh42 requested a balanced review from Copilot September 3, 2026 13:57
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.71%. Comparing base (7dfc9db) to head (6b2e6f0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4029      +/-   ##
==========================================
+ Coverage   27.64%   27.71%   +0.06%     
==========================================
  Files         477      477              
  Lines       25458    25485      +27     
==========================================
+ Hits         7039     7062      +23     
- Misses      17696    17699       +3     
- Partials      723      724       +1     
Flag Coverage Δ
unit-tests 27.71% <ø> (+0.06%) ⬆️

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.

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

Existing installations are not migrated, TektonConfig bypasses the new validation, and stale test expectations will fail.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates OpenShift Results routes to use re-encrypt TLS and validates supported termination modes.

Changes:

  • Defaults route TLS termination to reencrypt.
  • Updates route manifests and RBAC resource names.
  • Adds validation and tests for TLS termination values.
File summaries
File Description
pkg/reconciler/openshift/tektonresult/testdata/static/tekton-results/route-rbac/rbac.yaml Updates test route and RBAC.
pkg/reconciler/openshift/tektonresult/extension_test.go Tests re-encrypt route injection.
pkg/apis/operator/v1alpha1/tektonresult_validation.go Validates termination modes.
pkg/apis/operator/v1alpha1/tektonresult_validation_test.go Tests termination validation.
pkg/apis/operator/v1alpha1/tektonresult_defaults.go Changes the default to re-encrypt.
pkg/apis/operator/v1alpha1/tektonresult_defaults_test.go Updates the primary default assertion.
cmd/openshift/operator/kodata/static/tekton-results/route-rbac/rbac.yaml Updates deployed route and RBAC.
Review details
  • Files reviewed: 7/7 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.

Comment thread pkg/apis/operator/v1alpha1/tektonresult_defaults_test.go
Comment thread pkg/apis/operator/v1alpha1/tektonresult_defaults.go
Comment thread pkg/apis/operator/v1alpha1/tektonresult_validation.go Outdated
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 3, 2026
@divyansh42

divyansh42 commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

Addressed the Copilot review comments in the follow-up commit (06d301f):

  1. Stale test expectations — Fixed all 6 occurrences of RouteTLSTermination: "edge" in TestResult_SetDefaultsBucketsAutoDefaulting to expect "reencrypt".

  2. TektonConfig bypasses validation — Extracted the TLS termination check into ResultsAPIProperties.validateRouteTLSTermination() and wired it into TektonConfig.Validate (at spec.result.route_tls_termination), with a corresponding test Test_ValidateTektonConfig_InvalidResultRouteTLSTermination.

  3. Existing installations not migrated — The edge termination never worked correctly (it causes TLS handshake failures), so any existing cluster with edge is already broken. Rather than adding a forced migration (which risks overwriting deliberate user choices for users who set edge knowingly), we are treating this as a known upgrade action: users on existing installations who have edge persisted should manually patch their TektonResult or TektonConfig CR to reencrypt.

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.

🔵 Needs a closer look

The release note overstates external certificate trust, which still depends on the cluster ingress certificate configuration.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

cmd/openshift/operator/kodata/static/tekton-results/route-rbac/rbac.yaml:61

  • The PR states that this eliminates --insecure-skip-tls-verify, but reencrypt only changes router-to-backend encryption; this Route still presents the cluster ingress certificate. A default OpenShift ingress certificate is internally signed and may remain untrusted by external clients. Please qualify the description/release note so this benefit is conditional on clients trusting the ingress CA (or on a trusted custom ingress certificate being configured).
  • Files reviewed: 9/9 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@pratap0007

Copy link
Copy Markdown
Contributor

Don't we also need to handle the upgrade scenario (updating TLS termination edge to reencrypt)?

@jkhelil

jkhelil commented Sep 4, 2026

Copy link
Copy Markdown
Member

@divyansh42 can you adress @pratap0007 concerns? what happens on upgrade, please post a proof of work

@enarha enarha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/approve

@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enarha

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 6, 2026
@jkhelil

jkhelil commented Sep 8, 2026

Copy link
Copy Markdown
Member

@divyansh42 can we deprecate passthroug ?
and eventually remove edge from valide values ?

@divyansh42
divyansh42 force-pushed the fix/results-route-reencrypt-tls branch from 06d301f to 3f31f8f Compare September 11, 2026 15:27
@divyansh42
divyansh42 requested a balanced review from Copilot September 11, 2026 15:32
@divyansh42

Copy link
Copy Markdown
Member Author

@divyansh42 can you adress @pratap0007 concerns? what happens on upgrade, please post a proof of work

I have handled the upgrade but still need to test end to end. Will update once done.

@divyansh42

Copy link
Copy Markdown
Member Author

/hold

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 11, 2026

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

The non-OpenShift test is environment-dependent, and the TLS documentation incorrectly associates --insecure with the edge failure.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 4
  • Review effort level: Balanced

Comment thread pkg/reconciler/shared/tektonconfig/upgrade/pre_upgrade_test.go
Comment thread docs/TektonConfig.md Outdated
Comment thread docs/TektonResult.md Outdated
Comment thread pkg/reconciler/shared/tektonconfig/upgrade/pre_upgrade.go Outdated

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

The documentation inaccurately characterizes external certificate trust and recommends --insecure as mandatory for passthrough.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 14/14 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread docs/TektonConfig.md Outdated
Comment thread docs/TektonResult.md Outdated
The Results API route was defaulting to `edge` TLS termination which
causes TLS handshake failures: the router terminates TLS and forwards
unencrypted traffic to the gRPC backend, which only speaks TLS.

`reencrypt` is the correct mode: the router presents a trusted cert to
external clients while re-encrypting to the backend (which has an
OpenShift service-serving cert). This eliminates the need for
`--insecure-skip-tls-verify` when using `opc results`.

Changes:
- Default `route_tls_termination` changed from `edge` to `reencrypt`
- Route YAML updated from `passthrough` to `reencrypt`
- Fix RBAC `resourceNames` from `tekton-results-api-service` to
  `tekton-results-api` to match the actual Route resource name
- Add validation: only `edge`, `reencrypt`, `passthrough` are accepted,
  shared between TektonResult.Validate and TektonConfig.Validate

Existing installs persist the previous `edge` default, so add a
version-gated pre-upgrade migration that updates the Results route TLS
termination from `edge` to `reencrypt` on TektonConfig (the source of
truth), which then syncs to the TektonResult CR. Only `edge` is
migrated; values set manually to `reencrypt` or `passthrough` are left
untouched.

Also document that only `reencrypt` is supported on OpenShift.

Signed-off-by: divyansh42 <diagrawa@redhat.com>
Assisted-by: Claude Opus 4.8 (via Claude Code)
Assisted-by: Claude Sonnet 4.6 (via Cursor)
Co-authored-by: Cursor <cursoragent@cursor.com>
@divyansh42
divyansh42 force-pushed the fix/results-route-reencrypt-tls branch from 97feb9d to 6b2e6f0 Compare September 12, 2026 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. 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.

6 participants