Skip to content

api(cleanup): Replace deprecated h2c with net/http package - #1545

Open
enarha wants to merge 1 commit into
tektoncd:mainfrom
enarha:remove-deprecated-h2c-pkg
Open

enarha wants to merge 1 commit into
tektoncd:mainfrom
enarha:remove-deprecated-h2c-pkg

Conversation

@enarha

@enarha enarha commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

From doc: Package h2c is deprecated and unsupported. This package used to support unencrypted HTTP/2. Unencrypted HTTP/2 is now supported directly by the net/http package.
We need to further remove support for unencrypted connections, at least the fallback mode, but it's a breaking change and we'll do it separately.

Changes

/kind cleanup

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

ACTION REQUIRED: The plaintext (no-TLS) serving path of the API now uses Go's native unencrypted HTTP/2 support (net/http's Protocols.SetUnencryptedHTTP2) instead of golang.org/x/net/http2/h2c. This supports HTTP/2 cleartext via "prior knowledge" (RFC 7540 §3.4), which is what gRPC client libraries use. It does not support the legacy HTTP/1.1 Upgrade: h2c handshake (RFC 7540 §3.2). Clients that negotiate h2c via the Upgrade mechanism rather than prior knowledge will no longer be able to establish HTTP/2 on the plaintext port.

@tekton-robot tekton-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 21, 2026
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 21, 2026
@enarha
enarha requested a balanced review from Copilot November 21, 2026 18:16

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 change drops support for the HTTP/1.1 Upgrade: h2c handshake, so compatibility must be preserved or the break explicitly documented in release notes.

1 open issue
What changed in this PR

Replaces the API server’s deprecated h2c wrapper with native net/http protocol configuration while retaining plaintext serving alongside TLS.

Changes:

  • Enables HTTP/1 and unencrypted HTTP/2 on the plaintext listener.
  • Simplifies gRPC and REST request dispatch by removing the h2c wrapper.
  • Reclassifies golang.org/x/net as an indirect dependency.
File Description
go.mod Moves golang.org/x/net to indirect dependencies.
cmd/​api/​main.go Configures native plaintext HTTP/2 and removes deprecated transport imports and wrapping.

Review effort: Balanced

Comment thread cmd/api/main.go
// for gRPC clients, using net/http's native Protocols support.
var cleartextProtocols http.Protocols
cleartextProtocols.SetHTTP1(true)
cleartextProtocols.SetUnencryptedHTTP2(true)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Documented the issue as a breaking change. It's more of a theoretical issue, but indeed it should be properly indicated.

From doc: Package h2c is deprecated and unsupported.
This package used to support unencrypted HTTP/2. Unencrypted HTTP/2 is now
supported directly by the net/http package.
We need to further remove support for unencrypted connections, at least
the fallback more, but it's a breaking change and we'll do it separately.

Known compatibility change: The plaintext (no-TLS) serving path now uses
Go's native unencrypted HTTP/2 support (net/http's Protocols.SetUnencryptedHTTP2)
instead of golang.org/x/net/http2/h2c. This supports HTTP/2 cleartext
via "prior knowledge" (RFC 7540 §3.4), which is what gRPC client libraries use.
It does not support the legacy HTTP/1.1 Upgrade: h2c handshake (RFC 7540 §3.2).
Clients that negotiate h2c via the Upgrade mechanism rather than prior knowledge
will no longer be able to establish HTTP/2 on the plaintext port.
@enarha
enarha force-pushed the remove-deprecated-h2c-pkg branch from 390c947 to 2ab3995 Compare November 21, 2026 18:57

@olegbet olegbet 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
/lgtm

@tekton-robot

Copy link
Copy Markdown
Contributor

@olegbet: changing LGTM is restricted to collaborators

Details

In response to this:

/approve
/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olegbet
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

@adityavshinde

Copy link
Copy Markdown
Contributor

Could we add a focused test for the plaintext server path? It should verify that a gRPC client using insecure credentials can connect over HTTP/2 and that a normal HTTP/1.1 REST request still works. Optionally, it could also confirm that an Upgrade: h2c request no longer upgrades, documenting the intentional compatibility change.

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

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants