kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
9.12k stars 2.95k forks source link

Why does the url contain %00 #1347

Closed caoJiang7 closed 2 months ago

caoJiang7 commented 7 months ago

client-go Version: v0.28.2 k8s version: v1.28.3

log: W0408 01:50:20.316882 7 reflector.go:535] pkg/mod/k8s.io/client-go@v0.28.2/tools/cache/reflector.go:229: failed to list v1.Pod: Get "https://10.254.0.1:443/%00api/v1/pods?fieldSelector=spec.nodeName%3Dminion-2&resourceVersion=12299792": stream error: stream ID 137; PROTOCOL_ERROR; invalid header field name "\x01\x00\x00\x00\x04\x00\x00\x00" E0408 01:50:20.316954 7 reflector.go:147] pkg/mod/k8s.io/client-go@v0.28.2/tools/cache/reflector.go:229: Failed to watch v1.Pod: failed to list *v1.Pod: Get "https://10.254.0.1:443/%00api/v1/pods?fieldSelector=spec.nodeName%3Dminion-2&resourceVersion=12299792": stream error: stream ID 137; PROTOCOL_ERROR; invalid header field name "\x01\x00\x00\x00\x04\x00\x00\x00"

liggitt commented 7 months ago

The configuration or file you are setting up the client from likely contains a null character at the end of the server url line which is getting picked up as part of the base URL

/kind support

caoJiang7 commented 7 months ago

The configuration or file you are setting up the client from likely contains a null character at the end of the server url line which is getting picked up as part of the base URL

/kind support

Use clientcmd.BuildConfigFromFlags("", "") to build the client configuration. This should not cause problems with %00 (NULL characters) in URLs. And the problem occurs randomly.

code: clientConfig, err := clientcmd.BuildConfigFromFlags("", "") if err != nil { return nil, err } clientConfig.ContentType = "application/vnd.kubernetes.protobuf" clientset, err := kubernetes.NewForConfig(clientConfig) if err != nil { return nil, err }

k8s-triage-robot commented 4 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-ci-robot commented 2 months ago

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes/client-go/issues/1347#issuecomment-2330544972): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue with `/reopen` >- Mark this issue as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close not-planned > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.