openfaas / faas-cli

Official CLI for OpenFaaS
https://www.openfaas.com/
Other
794 stars 226 forks source link

[Suggestion] Suppress error output when GitHub version check fails #874

Open rgee0 opened 3 years ago

rgee0 commented 3 years ago

Expected Behaviour

The faas-cli failing to check whether it is the latest version does not affect the operation of the downloaded binary. If an error is encountered encourage the user to check manually, rather than distracting them with a verbose error message.

Current Behaviour

$ faas version
  ___                   _____           ____
 / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
| | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
 \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

CLI:
 commit:  2cec97955a254358de5443987bedf8ceee272cf8
 version: 0.13.9
Unable to find latest version online error: Head "https://github.com/openfaas/faas-cli/releases/latest": dial tcp 127.0.0.1:443: connect: connection refused

This is a forced error, so somewhat contrived, however a screenshot from a user is shown below: image

Possible Solution

Suppress the error emitted here, or add additional detail to explain that the user can check by browsing to https://github.com/openfaas/faas-cli/releases/latest

https://github.com/openfaas/faas-cli/blob/7de6613ff8fcfa16961fec6b8a00408650a843ec/commands/version.go#L71

Context

Supporting a new user on Slack who on seeing the error thought they had encountered an error, effectively on step 1. By providing a more human message this false barrier to entry is removed.

Your Environment

CLI: commit: 2cec97955a254358de5443987bedf8ceee272cf8 version: 0.13.9


* Docker version ( Full output from: `docker version` ):
n/a
* Are you using Docker Swarm (FaaS-swarm ) or Kubernetes (FaaS-netes)?
n/a
* Operating System and version (e.g. Linux, Windows, MacOS):
MacOS
* Link to your project or a code example to reproduce issue:
n/a
alexellis commented 3 years ago

This looks like the error was generated from an incorrectly configured HTTP PROXY? Given the URL is reported as 127.0.0.1?

Should we keep this around and see if anyone else is affected? If you want to silently fail the error, I'm OK with that too, and perhaps set a shorter timeout at the same time.

superherointj commented 1 year ago

I'm a nixpkgs maintainer, and I'm struggling to avoid triggering this network error when looking up version of faas-cli package for automated version test. Builds in Nix are only done offline. And the error is causing the version test to fail.

$ faas-cli version --short-version

Unable to find latest version online error: Head "https://github.com/openfaas/faas-cli/releases/latest": dial tcp: lookup github.com on [::1]:53: read udp [::1]:38672->[::1]:53: read: connection refused

If there is a solution to this, I'd like to know. (So I can properly fix the package.)

Thank you.

alexellis commented 1 year ago

Hi @superherointj would a flag like --quiet work for you?

cc @welteki (who also maintains Nix packages AFAIK)

Alex

superherointj commented 1 year ago

Thanks for the prompt answer.

Would --quiet print the version still? I need to get the version as output for check. If it is not too much trouble, can the flag to also opt out of network communication?

welteki commented 1 year ago

There is already a flag to skip the check.

faas-cli version --short-version --warn-update=false

When this is used there should not be any network communication.

superherointj commented 1 year ago

There is already a flag to skip the check.

faas-cli version --short-version --warn-update=false

When this is used there should not be any network communication.

I see. Thanks.

alexellis commented 1 year ago

@rgee0 can we close the issue?

rgee0 commented 1 year ago

Up to you. I think the original sentiment is still valid - the user is misdirected towards an error situation through what is essentially an informational failure. A silent failure in this situation would be more user friendly.