rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.8k stars 272 forks source link

Error Starting Kubernetes SyntaxError: Unexpected end of JSON input #2242

Open murphy85 opened 2 years ago

murphy85 commented 2 years ago

Actual Behavior

After first start of Rancher Desktop, it asks for admin priviledges. I enter my password, Rancher Desktop is starting and after about 1 minute a popup with an error message is shown

Steps to Reproduce

Download Rancher Desktop via brew (brew install --cask rancher), start Rancher Desktop.app

Result

Error message is shown

Expected Behavior

Rancher Desktop should start

Additional Information

Kubernetes Error Rancher Desktop 1.3.0 - darwin (x64) Error Starting Kubernetes SyntaxError: Unexpected end of JSON input Context: Waiting for nodes

Some recent logfile lines: Loaded image: rancher/mirrored-library-busybox:1.34.1 Loaded image: rancher/mirrored-library-traefik:2.6.2

Rancher Desktop Version

1.3.0

Rancher Desktop K8s Version

1.23.6

Which container runtime are you using?

moby (docker cli)

What operating system are you using?

macOS

Operating System / Build Version

macOS 12.4

What CPU architecture are you using?

arm64 (Apple Silicon)

Linux only: what package format did you use to install Rancher Desktop?

No response

Windows User Only

No response

murphy85 commented 2 years ago

With containerd it is starting, with dockerd it is not. There are some errors in log files:

k3s.log

E0520 13:03:06.512078    3521 controller.go:116] loading OpenAPI spec for "v1beta1.metrics.k8s.io" failed with: failed to retrieve openAPI spec, http error: ResponseCode: 503, Body: error trying to reach service: dial tcp 10.43.108.14:443: connect: connection refused
, Header: map[Content-Type:[text/plain; charset=utf-8] X-Content-Type-Options:[nosniff]]
I0520 13:03:06.512110    3521 controller.go:129] OpenAPI AggregationController: action for item v1beta1.metrics.k8s.io: Rate Limited Requeue.
E0520 13:03:07.392061    3521 available_controller.go:508] v1beta1.metrics.k8s.io failed with: failing or missing response from https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1: Get "https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1": dial tcp 10.43.108.14:443: connect: no route to host
W0520 13:03:08.399945    3521 handler_proxy.go:101] no RequestInfo found in the context
E0520 13:03:08.400034    3521 controller.go:116] loading OpenAPI spec for "v1beta1.metrics.k8s.io" failed with: failed to retrieve openAPI spec, http error: ResponseCode: 503, Body: service unavailable
, Header: map[Content-Type:[text/plain; charset=utf-8] X-Content-Type-Options:[nosniff]]
I0520 13:03:08.400048    3521 controller.go:129] OpenAPI AggregationController: action for item v1beta1.metrics.k8s.io: Rate Limited Requeue.
E0520 13:03:10.864815    3521 available_controller.go:508] v1beta1.metrics.k8s.io failed with: failing or missing response from https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1: Get "https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1": dial tcp 10.43.108.14:443: connect: connection refused
E0520 13:03:10.865164    3521 available_controller.go:508] v1beta1.metrics.k8s.io failed with: failing or missing response from https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1: Get "https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1": dial tcp 10.43.108.14:443: connect: connection refused
E0520 13:03:10.870028    3521 available_controller.go:508] v1beta1.metrics.k8s.io failed with: failing or missing response from https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1: Get "https://10.43.108.14:443/apis/metrics.k8s.io/v1beta1": dial tcp 10.43.108.14:443: connect: connection refused

lima.log

 * Caching service dependencies ... [ ok ]
 * Starting cri-dockerd ... [ ok ]
 * /var/log/k3s.log: creating file
Loaded image: rancher/mirrored-pause:3.5
Loaded image: rancher/klipper-helm:v0.6.6-build20211022
Loaded image: rancher/klipper-lb:v0.3.4
Loaded image: rancher/local-path-provisioner:v0.0.21
Loaded image: rancher/mirrored-coredns-coredns:1.9.1
Loaded image: rancher/mirrored-library-busybox:1.34.1
Loaded image: rancher/mirrored-library-traefik:2.6.1
Loaded image: rancher/mirrored-metrics-server:v0.5.2
 * Starting k3s ... [ ok ]
2022-05-20T13:02:48.664Z: Configuration /etc/rancher/k3s/k3s.yaml not present in lima vm; will check again...
2022-05-20T13:02:53.142Z: Error starting lima: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at $e.updateDockerContext (/Applications/Rancher Desktop.app/Contents/Resources/app.asar/dist/app/background.js:17:196339)
    at async /Applications/Rancher Desktop.app/Contents/Resources/app.asar/dist/app/background.js:17:203320

background.log

2022-05-20T13:09:10.436Z: Kubernetes was unable to start: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at $e.updateDockerContext (/Applications/Rancher Desktop.app/Contents/Resources/app.asar/dist/app/background.js:17:196339)
    at async /Applications/Rancher Desktop.app/Contents/Resources/app.asar/dist/app/background.js:17:203320
murphy85 commented 2 years ago

I connected to our corporate network via AnyConnect now. After that I could successfully reset Kubernetes. After disconnecting from network Rancher Desktop is still working. After resetting Kubernetes the error occurs again.

mook-as commented 2 years ago
2022-05-20T13:09:10.436Z: Kubernetes was unable to start: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at $e.updateDockerContext (/Applications/Rancher Desktop.app/Contents/Resources/app.asar/dist/app/background.js:17:196339)

That sounds more like your docker configuration (~/.docker/config.json) was invalid. But then doing things (that should mostly be unrelated) managed to make it valid again, which would be rather confusing…

(The relevant code is here.)

murphy85 commented 2 years ago

Thank you, that was a good hint, but I don't know why it was working before with older version of Rancher Desktop.

I have a ~/.docker/config.json_proxy and a ~/.docker/config.json_noproxy. When switching to corporate network, I replace the ~/.docker/config.json with the version with proxy settings and when I disconnect I replace it with the version without proxy. The version without a proxy is totally empty. After I added {} to the file, it works.

jandubois commented 2 years ago

That sounds more like your docker configuration (~/.docker/config.json) was invalid.

I think RD should deal with an invalid config.json file in a more user-friendly manner, i.e. show a dialog that explains the problem, and then abandon editing the file, and let the user fix it on their own.

We should make an exception to a file that is empty, or contains just whitespace because it is always safe to replace it with {}.