Skip to content

WIP: client-go transport: allow forcing debug wrapping #131508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Apr 28, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This may be useful in consumers which do not configure klog verbosity. More work may be necessary in callers of the transport package. For example, the transports constructed here still only depend on klog verbosity:

https://github.com/kubernetes/kubernetes/blob/0abee6bd55f7274f06174d9404050c684d9f9f35/staging/src/k8s.io/client-go/rest/transport.go#L71-L8

// RoundTripperFor transforms the passed rest config into a wrapped roundtripper, as well
// as a pointer to the websocket RoundTripper. The websocket RoundTripper contains the
// websocket connection after RoundTrip() on the wrapper. Returns an error if there is
// a problem creating the round trippers.
func RoundTripperFor(config *restclient.Config) (http.RoundTripper, ConnectionHolder, error) {

Which issue(s) this PR fixes:

This is an alternative to #129831.

Special notes for your reviewer:

Extending transport.Config with an additional boolean is backwards-compatible. If unset, the previous behavior is preserved (i.e. checking klog.V(6)).

/cc @alvaroaleman @ahmetb

This may be useful in consumers which do not configure klog verbosity.
More work may be necessary in callers of the transport package. For example,
the transports constructed here still only depend on klog verbosity:

https://github.com/kubernetes/kubernetes/blob/0abee6bd55f7274f06174d9404050c684d9f9f35/staging/src/k8s.io/client-go/rest/transport.go#L71-L8
https://github.com/kubernetes/kubernetes/blob/0abee6bd55f7274f06174d9404050c684d9f9f35/staging/src/k8s.io/client-go/transport/websocket/roundtripper.go#L179-L183

Extending transport.Config with an additional boolean is
backwards-compatible. If unset, the previous behavior is
preserved (i.e. checking klog.V(6)).
@k8s-ci-robot k8s-ci-robot requested a review from ahmetb April 28, 2025 11:09
@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot
Copy link
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 28, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 28, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pohly
Once this PR has been reviewed and has the lgtm label, please assign caesarxuchao for approval. For more information see the Code Review Process.

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

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

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 28, 2025
@@ -43,7 +43,7 @@ func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTrip
rt = config.WrapTransport(rt)
}

rt = DebugWrappers(rt)
rt = MaybeDebugWrappers(rt, config.ForceDebugWrappers)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alvaroaleman, @ahmetb: which APIs built on top of his would need to be extended to make this useful for consumers of controller-runtime?

Copy link
Member

Choose a reason for hiding this comment

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

I think the Maybe portion is just not gonna be easy to work with. We want this to be ideally enabled for all controllers by default, and most controllers explicitly provide a rest.Config to the controller-runtime, and they won't do ForceDebugWrappers=true.

I'd really want us to reconsider always wrapping. I remember the concern was having another point where ctx cancellation could happen, or another method shows up in the call stack? These don't strike me as too critical, and they can be mitigated to a good extent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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.

3 participants