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

Improve error reporting if kubeconfig is missing or cluster unreachable #315

Closed
duglin opened this issue Jul 29, 2019 · 16 comments · Fixed by #725
Closed

Improve error reporting if kubeconfig is missing or cluster unreachable #315

duglin opened this issue Jul 29, 2019 · 16 comments · Fixed by #725
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@duglin
Copy link
Contributor

duglin commented Jul 29, 2019

on master right now I see this in a totally clean env:

$ kn service create --image asd asd
invalid configuration: no configuration has been provided

A config file should be optional.

@duglin duglin added the kind/bug Categorizes issue or PR as related to a bug. label Jul 29, 2019
@duglin
Copy link
Contributor Author

duglin commented Jul 29, 2019

Did some more testing and I think that it's due to a kube config issue. Try this to reproduce it:

$ KUBECONFIG= ./kn service create asd --image asd

I think it's probably ok that it generates some kind of error since it can't talk to the server/kube, but it would be nice if it gave some of hint as to either a) which config file that's missing, or b) let it fail with a TCP error so we'll get a better error about not being able to connect to localhost.

@navidshaikh
Copy link
Collaborator

The current behavior falls back to the default location ~/.kube/config even if you specify explicitly

$ KUBECONFIG= ./kn service create asd --image asd

just saying.

Beside,

but it would be nice if it gave some of hint as to either a) which config file that's missing,

+1

@daisy-ycguo
Copy link
Member

daisy-ycguo commented Nov 6, 2019

I tested with the latest version of kn.

  1. If no KUBECONFIG is provided, the error message is:
$ KUBECONFIG= kn service create create asd --image asd
no Knative serving API found on the backend. Please verify the installation.
  1. if server is not reachable but KUBECONFIG is configured, the error message is:
Get https://c1.au-syd.containers.cloud.ibm.com:27435/apis/serving.knative.dev/v1alpha1/namespaces/default/services/fib-knative: dial tcp 135.90.69.66:27435: i/o timeout

I think the error messages are acceptable to some extend. The possible improvements may be:

  • for the first case, add a statement to guide users to "Please verify the installation or use KUBECONFIG to point to a Kubernetes with serving installed."
  • for the second case, remove the long url and just say "Unable to connect to the server: dial tcp 130.198.66.26:27435: i/o timeout" ( copied from kubectl )

@navidshaikh any comments ?

@duglin
Copy link
Contributor Author

duglin commented Nov 6, 2019

@daisy-ycguo in this case:

$ KUBECONFIG= kn service create create asd --image asd
no Knative serving API found on the backend. Please verify the installation.

what is the error condition being detected? No URL specified to connect to? If so, perhaps we could simply reword this say that - something like:

No serving API specified, please verify the installation

It's minor but saying "specified" is clearer that config data is missing. Saying something on the "backend" is missing isn't as clear to me what's going on because someone could interpret it as a server-side issue, not a client one.

@daisy-ycguo
Copy link
Member

The error is detected when the invocation to backend serving API returns a 404 error.

what is the error condition being detected? No URL specified to connect to? If so, perhaps we could simply reword this say that - something like:

No serving API specified, please verify the installation

@navidshaikh
Copy link
Collaborator

I tested with the latest version of kn.

@daisy-ycguo:

on latest release v0.9.0 or current master with no ~/.kube/config or env $KUBECONFIG, I see

➜  client git:(4ab869a) KUBECONFIG= ./kn service create svc  --image foo.bar  
invalid configuration: no configuration has been provided

(this is the original issue Doug reported, we should add a hint here about missing 'kubeconfig')

restoring kubeconfig and make the cluster unreachable

➜  client git:(master) mv ~/config ~/.kube 
➜  client git:(master) crc stop           
Stopping the OpenShift cluster, this may take a few minutes...
The OpenShift cluster stopped

➜  client git:(master) KUBECONFIG= ./kn service create svc  --image foo.bar
Get https://api.crc.testing:6443/apis/serving.knative.dev/v1alpha1/namespaces/kne2etests0/services/svc: dial tcp: lookup api.crc.testing on 127.0.0.1:53: read udp 127.0.0.1:55884->127.0.0.1:53: i/o timeout

This error message can be improved, sure!

but the other error you mentioned

no Knative serving API found on the backend. Please verify the installation.

is correct I think.

@navidshaikh
Copy link
Collaborator

/assign

@duglin
Copy link
Contributor Author

duglin commented Nov 7, 2019

What's kind of funny is that when I think about the two errors messages:
1 : no Knative serving API found on the backend
2: Get https://api.crc.te... dial tcp: lookup api.crc.testing on 127.0.0.1:53: read udp 127.0.0.1:55884->127.0.0.1:53: i/o timeout

I actually find the 2nd one more helpful (user friendly) despite it using more geeky terms - which is the opposite what I might expect. ;-)

I think it's because the 2nd one gives the exact reason behind the error condition and gives the user the exact info they need to try to fix it... their server at that address isn't there. The 1st one is too vague for people to know exactly what happened and doesn't give a hint how to fix it. For example, if the first one said what @daisy-ycguo mentioned "a 404 was returned from the server URL" (and showed me the URL) I think there would be no confusion at all and I have a hint at how to fix it - despite it being more geeky.

So, what about something like:
The serving endpoint (<insert URL here>) does not appear to a valid Knative server, please check your installation. or something like that. That gives me the location of the server, so I can check whether that URL is correct or not - and if not it's a client config issue. And, if the URL is correct then I know to go debug why the server isn't talking knative.

@kristianmandrup
Copy link

I had a similar issue getting started with KNative. Just bought the KNative in Action book and trying to follow the instructions in Chapter 2:

I installed knative:

However I keep getting i/o timeout for any kn command I execute. Would be nice with a more helpful message, perhaps adding some kind of status command to inspect the kn configuration and alert if anything is missing, such as a configuration file etc

➜  knative-play kn
Manage your Knative building blocks:

* Serving: Manage your services and release new software to them.
* Eventing: Manage event subscriptions and channels. Connect up event sources.

Usage:
  kn [command]

Available Commands:
  completion  Output shell completion code
  help        Help about any command
  plugin      Plugin command group
  revision    Revision command group
  route       Route command group
  service     Service command group
  source      Event source command group
  trigger     Trigger command group
  version     Prints the client version

Flags:
      --config string        kn config file (default is $HOME/.kn/config.yaml)
  -h, --help                 help for kn
      --kubeconfig string    kubectl config file (default is $HOME/.kube/config)
      --log-http             log http traffic
      --lookup-plugins       look for kn plugins in $PATH
      --plugins-dir string   kn plugins directory (default "~/.kn/plugins")

Use "kn [command] --help" for more information about a command.
➜  knative-play kn service list
Get https://192.168.99.100:8443/apis/serving.knative.dev/v1/namespaces/default/services: dial tcp 192.168.99.100:8443: i/o timeout
knative-play kn service create hello-example --image gcr.io/knative-samples/helloworld-go --env TARGET="First"
Get https://192.168.99.100:8443/apis/serving.knative.dev/v1/namespaces/default/services/hello-example: dial tcp 192.168.99.100:8443: i/o timeout

@kristianmandrup
Copy link

Tried to install by cloning repo and running go install ./cmd/kn
Finishes after a while without reporting anything to std out (I had previously run it where it listed all the module dependencies)

I guess I need to add it to my PATH, but have no idea where the build is after the install

I then tried following other approaches from https://knative.dev/docs/install/install-kn/

The links at the bottom for nightly and latest release both give a Page not found error

https://knative.dev/docs/install/install-kn/gcr.io/knative-nightly/knative.dev/client/cmd/kn

Please improve the installation/setup guide :)

@kristianmandrup
Copy link

Is this the "correct" way of installing KNative!?

To install Knative, first install the CRDs by running the kubectl apply command once with the -l knative.dev/crd-install=true flag. This prevents race conditions during the install, which cause intermittent errors:

kubectl apply --selector knative.dev/crd-install=true \
--filename https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.12.0/eventing.yaml \
--filename https://github.com/knative/serving/releases/download/v0.12.0/monitoring.yaml

To complete the install of Knative and its dependencies, run the kubectl apply command again, this time without the --selector flag, to complete the install of Knative and its dependencies:

kubectl apply --filename https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml \
--filename https://github.com/knative/eventing/releases/download/v0.12.0/eventing.yaml \
--filename https://github.com/knative/serving/releases/download/v0.12.0/monitoring.yaml

Monitor the Knative components until all of the components show a STATUS of Running:

kubectl get pods --namespace knative-serving
kubectl get pods --namespace knative-eventing
kubectl get pods --namespace knative-monitoring

It is very unclear and confusing...

@kristianmandrup
Copy link

When I try this approach, I get:

unable to recognize "https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml": no matches for kind "Image" in version "caching.internal.knative.dev/v1alpha1"
unable to recognize "https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml": no matches for kind "Gateway" in version "networking.istio.io/v1alpha3"
unable to recognize "https://github.com/knative/serving/releases/download/v0.12.0/serving.yaml": no matches for kind "Gateway" in version "networking.istio.io/v1alpha3"

I've installed Istio though

@navidshaikh
Copy link
Collaborator

navidshaikh commented Feb 20, 2020

@kristianmandrup : Thanks for reporting!

I guess I need to add it to my PATH, but have no idea where the build is after the install

go install will output the binary in your $GOPATH/bin directory. As part of the go setup, its recommended to have $GOPATH/bin added to your $PATH.

The links at the bottom for nightly and latest release both give a Page not found error

Yes, its fixed and ready to be rolled out in the next release, correct links are
Nightly kn container: https://gcr.io/knative-nightly/knative.dev/client/cmd/kn
Released kn container: https://gcr.io/knative-releases/knative.dev/client/cmd/kn
(also available in development version of docs site at https://knative.dev/development/install/install-kn/)

@navidshaikh navidshaikh added this to the v0.13.0 milestone Feb 20, 2020
@kristianmandrup
Copy link

@navidshaikh Thanks for your quick reply

I installed go via brew install go on Mac OSX

$ which go   
/usr/local/bin/go

GOPATH is not set:

echo $GOPATH 

➜  client git:(master) ✗

I haven't used Go before, looking at GOPATH wiki docs

The GOPATH environment variable is used to specify directories outside of $GOROOT that contain the source for Go projects and their binaries.

Currently I have no Go projects however, but I guess I can create a placeholder in ~/repos/go and set GOPATH to point there, then run go install again - or use the correct release links you pointed me to

echo $PATH 
/Users/kristianmandrup/.nvm/versions/node/v13.7.0/bin::/Users/kristianmandrup/.nimble/bin:/Users/kristianmandrup/.gem/ruby/2.6.0/bin:/usr/local/opt/python/libexec/bin:/Users/kristianmandrup/Library/Python/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/kristianmandrup/Library/Android/sdk/tools/bin:/Users/kristianmandrup/Library/Android/sdk/platform-tools:/Users/kristianmandrup/Library/Android/sdk/emulator
➜  client git:(master) ✗

Thanks

@kristianmandrup
Copy link

I still have no idea how to install KNative on Mac OSX using any of these approached.
Would be nice with brew install knative

I will try to follow this guide now: https://ubuntu.com/blog/getting-started-with-knative-1

@rhuss
Copy link
Contributor

rhuss commented Feb 20, 2020

For reference, see #648 for way to install kn on macOs Mojave.

@navidshaikh navidshaikh changed the title kn won't start w/o a config Improve error reporting if kubeconfig is missing or cluster unreachable Mar 10, 2020
navidshaikh added a commit to navidshaikh/client that referenced this issue Mar 10, 2020
 Fixes knative#315
 - Improve error reporting if
    - kubeconfig file is missing or
    - there is no route to host
    - i/o timeout
navidshaikh added a commit to navidshaikh/client that referenced this issue Mar 10, 2020
 Fixes knative#315
 - Improve error reporting if
    - kubeconfig file is missing or
    - there is no route to host
    - i/o timeout
navidshaikh added a commit to navidshaikh/client that referenced this issue Mar 10, 2020
 Fixes knative#315
 - Improve error reporting if
    - kubeconfig file is missing or
    - there is no route to host
    - i/o timeout
navidshaikh added a commit to navidshaikh/client that referenced this issue Mar 10, 2020
 Fixes knative#315
 - Improve error reporting if
    - kubeconfig file is missing or
    - there is no route to host
    - i/o timeout
knative-prow-robot pushed a commit that referenced this issue Mar 10, 2020
Fixes #315
 - Improve error reporting if
    - kubeconfig file is missing or
    - there is no route to host
    - i/o timeout
coryrc pushed a commit to coryrc/client that referenced this issue May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants