Skip to content
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

client-go: share the same transport for generated clientsets #105490

Merged
merged 7 commits into from Oct 20, 2021

Conversation

aojea
Copy link
Member

@aojea aojea commented Oct 5, 2021

/kind bug
/kind cleanup

Until now, when creating a Kubernetes Clientset, a new RESTClient was created per group/version. Since RESTClient transport can not be cached in some occasions, i.e. when using a custom transport, this has the consequence that each group/version had an independent TCP connection to the API server.

Since the Transport, of the RESTClient can be shared when creating a global Kubernetes Clientset, this PR adds a new RESTClient constructor RESTClientForConfigAndClient to allow to generate clientsets using the same http client.

Fixes #91913, #103225

client-go uses the same http client for all the generated groups and versions, allowing to share customized transports for multiple groups versions.

@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. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/code-generation area/test sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 5, 2021
@aojea aojea force-pushed the restclient-shared-transport branch 2 times, most recently from 8a42af3 to 0c5ce9d Compare October 5, 2021 16:58
@aojea aojea force-pushed the restclient-shared-transport branch from 0c5ce9d to acb56c2 Compare October 6, 2021 08:49
@aojea aojea changed the title [WIP] Restclient shared transport client-go: share the same transport for generated clientsets Oct 6, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 6, 2021
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 6, 2021
@aojea aojea force-pushed the restclient-shared-transport branch from 0c8187b to cfe8d4c Compare October 6, 2021 10:05
@aojea
Copy link
Member Author

aojea commented Oct 6, 2021

/kind bug
/kind cleanup
/assign @liggitt
/cc @yliaog
/triage accepted

@fedebongio this supersedes #105432 (comment)

This is working now, there was a bug for the clientset generated without a custom transport because it wasn't using the configured Timeout option.
It was hidden because only showed up with this change, 🤔 something in the generated chain should be fixing it, I've added an unit test to verify it.

@aojea aojea force-pushed the restclient-shared-transport branch from 46cb4a2 to 032d0d6 Compare October 20, 2021 04:39
@liggitt
Copy link
Member

liggitt commented Oct 20, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 20, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, liggitt

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

The pull request process is described 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 20, 2021
@aojea
Copy link
Member Author

aojea commented Oct 20, 2021

There are no nodes that your pod can schedule to - check your requests, tolerations, and node selectors (skip schedule deleting pod: test-pods/af2ebe83-31c2-11ec-9c4e-3231390c1bb4)

/test pull-kubernetes-verify-govet-levee

@k8s-ci-robot
Copy link
Contributor

@aojea: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-unit 032d0d6 link unknown /test pull-kubernetes-unit

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@aojea
Copy link
Member Author

aojea commented Oct 20, 2021

k8s.io/kubernetes/pkg/registry/core/service/storage: TestFeatureExternalTrafficPolicy/LoadBalancer_policy:Cluster_hcnp:none_policy:Local_hcnp:specified expand_more 0s
k8s.io/kubernetes/pkg/registry/core/service/storage: TestFeatureExternalTrafficPolicy expand_more

/test pull-kubernetes-unit

@aojea
Copy link
Member Author

aojea commented Oct 20, 2021

=== RUN TestFeatureExternalTrafficPolicy/LoadBalancer_policy:Cluster_hcnp:none_policy:Local_hcnp:specified
I1020 16:48:40.327679 63217 alloc.go:821] Transition to LoadBalancer type service with ExternalTrafficPolicy=Local
storage_test.go:774: unexpected error updating service: Internal error occurred: failed to allocate requested HealthCheck NodePort 30000: provided port is already allocated
W1020 16:48:40.385152 63217 clientconn.go:1326] [core] grpc: addrConn.createTransport failed to connect to {localhost:38187 localhost 0 }. Err: connection error: desc = "transport: Error while dialing dial tcp [::1]:38187: connect: connection refused". Reconnecting...
W1020 16:48:40.396525 63217 clientconn.go:1326] [core] grpc: addrConn.createTransport failed to connect to {localhost:33473 localhost 0 }. Err: connection error: desc = "transport: Error while dialing dial tcp [::1]:33473: connect: connection refused". Reconnecting...
--- FAIL: TestFeatureExternalTrafficPolicy/LoadBalancer_policy:Cluster_hcnp:none_policy:Local_hcnp:specified (0.08s)

that sounds like a flake

@k8s-ci-robot k8s-ci-robot merged commit 881980a into kubernetes:master Oct 20, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 20, 2021
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. area/code-generation area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl output flooded with warnings about aws-iam-authenticator
3 participants