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

http-cache keeps 401 responses #76774

Closed
w3irdrobot opened this issue Apr 18, 2019 · 12 comments
Closed

http-cache keeps 401 responses #76774

w3irdrobot opened this issue Apr 18, 2019 · 12 comments
Assignees
Labels
area/client-libraries kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@w3irdrobot
Copy link

What happened:

Started to get error: You must be logged in to the server (Unauthorized) responses when interacting with minikube using kubectl. I decided to delete my minikube instance and recreate it, but that didn't solve the problem. Verbose output from kubectl get po returned the following:

I0417 19:46:23.800737    7579 loader.go:359] Config loaded from file /foo/bar/.kube/config_merge
I0417 19:46:23.801074    7579 loader.go:359] Config loaded from file /foo/bar/another/kubeconfig
I0417 19:46:23.801461    7579 loader.go:359] Config loaded from file /foo/bar/yet-another/kubeconfig
I0417 19:46:23.805913    7579 round_trippers.go:419] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.14.0 (darwin/amd64) kubernetes/641856d" 'https://192.168.99.100:8443/api?timeout=32s'
I0417 19:46:23.806328    7579 round_trippers.go:438] GET https://192.168.99.100:8443/api?timeout=32s 401 Unauthorized in 0 milliseconds
I0417 19:46:23.806345    7579 round_trippers.go:444] Response Headers:
I0417 19:46:23.806353    7579 round_trippers.go:447]     Content-Length: 129
I0417 19:46:23.806357    7579 round_trippers.go:447]     Content-Type: application/json
I0417 19:46:23.806362    7579 round_trippers.go:447]     Date: Mon, 14 Jan 2284 08:38:06 GMT
I0417 19:46:23.806366    7579 round_trippers.go:447]     X-From-Cache: 1
I0417 19:46:23.806403    7579 request.go:942] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401}
I0417 19:46:23.807402    7579 cached_discovery.go:121] skipped caching discovery info due to Unauthorized
I0417 19:46:23.807911    7579 round_trippers.go:419] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.14.0 (darwin/amd64) kubernetes/641856d" 'https://192.168.99.100:8443/api?timeout=32s'
I0417 19:46:23.807994    7579 round_trippers.go:438] GET https://192.168.99.100:8443/api?timeout=32s 401 Unauthorized in 0 milliseconds
I0417 19:46:23.808006    7579 round_trippers.go:444] Response Headers:
I0417 19:46:23.808011    7579 round_trippers.go:447]     X-From-Cache: 1
I0417 19:46:23.808017    7579 round_trippers.go:447]     Content-Length: 129
I0417 19:46:23.808025    7579 round_trippers.go:447]     Content-Type: application/json
I0417 19:46:23.808029    7579 round_trippers.go:447]     Date: Mon, 14 Jan 2284 08:38:06 GMT
I0417 19:46:23.808046    7579 request.go:942] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401}
I0417 19:46:23.808107    7579 cached_discovery.go:121] skipped caching discovery info due to Unauthorized
I0417 19:46:23.808132    7579 shortcut.go:89] Error loading discovery information: Unauthorized
I0417 19:46:23.808222    7579 round_trippers.go:419] curl -k -v -XGET  -H "User-Agent: kubectl/v1.14.0 (darwin/amd64) kubernetes/641856d" -H "Accept: application/json, */*" 'https://192.168.99.100:8443/api?timeout=32s'
I0417 19:46:23.808298    7579 round_trippers.go:438] GET https://192.168.99.100:8443/api?timeout=32s 401 Unauthorized in 0 milliseconds
I0417 19:46:23.808308    7579 round_trippers.go:444] Response Headers:
I0417 19:46:23.808313    7579 round_trippers.go:447]     Content-Length: 129
I0417 19:46:23.808319    7579 round_trippers.go:447]     Content-Type: application/json
I0417 19:46:23.808323    7579 round_trippers.go:447]     Date: Mon, 14 Jan 2284 08:38:06 GMT
I0417 19:46:23.808329    7579 round_trippers.go:447]     X-From-Cache: 1
I0417 19:46:23.808342    7579 request.go:942] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401}
I0417 19:46:23.808373    7579 cached_discovery.go:121] skipped caching discovery info due to Unauthorized
I0417 19:46:23.808448    7579 round_trippers.go:419] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.14.0 (darwin/amd64) kubernetes/641856d" 'https://192.168.99.100:8443/api?timeout=32s'
I0417 19:46:23.808517    7579 round_trippers.go:438] GET https://192.168.99.100:8443/api?timeout=32s 401 Unauthorized in 0 milliseconds
I0417 19:46:23.808528    7579 round_trippers.go:444] Response Headers:
I0417 19:46:23.808535    7579 round_trippers.go:447]     Content-Length: 129
I0417 19:46:23.808541    7579 round_trippers.go:447]     Content-Type: application/json
I0417 19:46:23.808547    7579 round_trippers.go:447]     Date: Mon, 14 Jan 2284 08:38:06 GMT
I0417 19:46:23.808553    7579 round_trippers.go:447]     X-From-Cache: 1
I0417 19:46:23.808567    7579 request.go:942] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401}
I0417 19:46:23.808603    7579 cached_discovery.go:121] skipped caching discovery info due to Unauthorized
I0417 19:46:23.808666    7579 round_trippers.go:419] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.14.0 (darwin/amd64) kubernetes/641856d" 'https://192.168.99.100:8443/api?timeout=32s'
I0417 19:46:23.808727    7579 round_trippers.go:438] GET https://192.168.99.100:8443/api?timeout=32s 401 Unauthorized in 0 milliseconds
I0417 19:46:23.808737    7579 round_trippers.go:444] Response Headers:
I0417 19:46:23.808743    7579 round_trippers.go:447]     Content-Length: 129
I0417 19:46:23.808747    7579 round_trippers.go:447]     Content-Type: application/json
I0417 19:46:23.808759    7579 round_trippers.go:447]     Date: Mon, 14 Jan 2284 08:38:06 GMT
I0417 19:46:23.808774    7579 round_trippers.go:447]     X-From-Cache: 1
I0417 19:46:23.808795    7579 request.go:942] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Unauthorized","reason":"Unauthorized","code":401}
I0417 19:46:23.808835    7579 cached_discovery.go:121] skipped caching discovery info due to Unauthorized
I0417 19:46:23.809281    7579 helpers.go:196] server response object: [{
  "metadata": {},
  "status": "Failure",
  "message": "Unauthorized",
  "reason": "Unauthorized",
  "code": 401
}]
F0417 19:46:23.809309    7579 helpers.go:114] error: You must be logged in to the server (Unauthorized)

I still got these response even when minikube was not running. Also, hitting it directly with curl would give me correct access when minikube was running.

curl https://192.168.99.100:8443/api --cacert ~/.minikube/ca.crt --cert ~/.minikube/client.crt --key ~/.minikube/client.key

I tried restarting my computer, recreating the minikube cluster...all that. Nothing worked.

Dug into the cache inside .kube and deleted http-cache and that solved the problem.

What you expected to happen:

I expected 401 calls to not be cached.

How to reproduce it (as minimally and precisely as possible):

Honestly, I'm not sure what happened in the first place. So I'm not sure how to recreate it.

Anything else we need to know?:

The 57 on Heinz ketchup bottles represents the number of varieties of pickles the company once had.

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-26T00:04:52Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration:
Minikube on VirtualBox
  • OS (e.g: cat /etc/os-release):
MacOS Mojave v10.14.4
  • Kernel (e.g. uname -a):
Darwin mycomputername 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin
  • Install tools:
minikube version: v1.0.0
@w3irdrobot w3irdrobot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 18, 2019
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Apr 18, 2019
@w3irdrobot
Copy link
Author

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 18, 2019
@liggitt liggitt added area/client-libraries sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Apr 18, 2019
@fedebongio
Copy link
Contributor

/assign @apelisse

@yue9944882
Copy link
Member

the http response from kube-apiserver should respect rfc5861 and properly set Cache-Control http headers so that kubectl can correctly refresh the http.

@apelisse
Copy link
Member

Not that you're wrong or anything, but the problem here is that the client is doing the wrong thing. I still have absolutely no idea how this can have happened to be honest. I'm starting to suspect that something actually returned cache headers somewhere, maybe in minikube?

@apelisse
Copy link
Member

if this happens to anyone, we should look at the cache file to understand what's going on ...

@lzecca78
Copy link

lzecca78 commented May 17, 2019

Happens the same in my team after a crash of the vm with minikube. I tried to reboot the vm, going inside the vm and using kubectl from within the vm, everything works perfectly, but outside the vm(from the laptop) the response is always error: You must be logged in to the server (Unauthorized) even if the vm switched off. Same behaviour i mean.
Is there any working workaround?

@apelisse
Copy link
Member

Deleting the ~/.kube/http-cache is the best option. But if that happens, I'd be more than happy to have a look at the files in there ...

@liggitt liggitt added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Jun 12, 2019
@saniic
Copy link

saniic commented Jan 30, 2020

Deleting ~/.kube/http-cache also not solved the issue. I am facing the issue with KOPS cluster not with EKS

@apelisse
Copy link
Member

I'm a little clueless at this point. @shurcooL can you help us look at that?

@invidian
Copy link
Member

invidian commented Mar 2, 2020

I also hit this issue, but I have no idea how to that happened..

@ardaguclu
Copy link
Member

There have been quite a lot of changes happened on the project from the version 1.14. Would it make sense to try to reproduce it and if not, close this issue?

@w3irdrobot
Copy link
Author

@ardaguclu i am not doing kubernetes work anymore these days. given all the work that has gone into this project since i created this issue, i think it's okay to close and just create a new issue if someone runs into it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client-libraries kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
Archived in project
Development

No branches or pull requests

10 participants