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

Why does the url contain %00 #1347

Open
caoJiang7 opened this issue Apr 8, 2024 · 2 comments
Open

Why does the url contain %00 #1347

caoJiang7 opened this issue Apr 8, 2024 · 2 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@caoJiang7
Copy link

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
Copy link
Member

liggitt commented Apr 8, 2024

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

@k8s-ci-robot k8s-ci-robot added the kind/support Categorizes issue or PR as a support question. label Apr 8, 2024
@caoJiang7
Copy link
Author

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

3 participants