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

cloudflared returning zero exit code on error #96

Open
cblecker opened this issue May 7, 2019 · 2 comments

Comments

2 participants
@cblecker
Copy link

commented May 7, 2019

If cloudflared starts up before networking and DNS resolution is up and running, it will throw an error and exit. However, this error is returning a zero/success exit code.. as such launchd on Darwin sees that the application intended to exit, and doesn't restart it.

$ cloudflared
INFO[0000] Build info: {GoOS:darwin GoVersion:go1.11.1 GoArch:amd64} 
INFO[0000] Version 2019.4.1                             
INFO[0000] Flags                                         hostname=example.com proxy-dns-upstream="https://1.1.1.1/dns-query, https://1.0.0.1/dns-query" url="ssh://127.0.0.1:22"
INFO[0000] cloudflared will not automatically update when run from the shell. To enable auto-updates, run cloudflared as a service: https://developers.cloudflare.com/argo-tunnel/reference/service/ 
INFO[0000] Starting metrics server                       addr="127.0.0.1:49693"
INFO[0000] Proxying tunnel requests to http://127.0.0.1:49694 
ERRO[0000] Error looking up Cloudflare edge IPs: the DNS query failed: lookup _warp._tcp.cloudflarewarp.com on [::1]:53: read udp [::1]:52309->[::1]:53: read: connection refused 
ERRO[0000] Please try the following things to diagnose this issue: 
ERRO[0000]   1. ensure that cloudflarewarp.com is returning "warp" service records. 
ERRO[0000]      Run your system's equivalent of: dig srv _warp._tcp.cloudflarewarp.com 
ERRO[0000]   2. ensure that your DNS resolver is not returning compressed SRV records. 
ERRO[0000]      See GitHub issue https://github.com/golang/go/issues/27546 
ERRO[0000]      For example, you could use Cloudflare's 1.1.1.1 as your resolver: 
ERRO[0000]      https://developers.cloudflare.com/1.1.1.1/setting-up-1.1.1.1/ 
INFO[0000] ResolveEdgeIPs err                           
ERRO[0000] Quitting due to error                         error="Could not lookup srv records on _warp._tcp.cloudflarewarp.com: lookup _warp._tcp.cloudflarewarp.com on [::1]:53: read udp [::1]:52309->[::1]:53: read: connection refused"
INFO[0000] Metrics server stopped                       
$ echo $?
0
$ 

If instead this reported a non-zero exit code, launchd would see that the process failed and it should attempt to restart it.

@nickvollmar

This comment has been minimized.

Copy link
Collaborator

commented May 7, 2019

Potential fixes:

  • sticking within the context of the cli framework, we can have the "Could not lookup srv records" error (and other errors) implement https://godoc.org/github.com/urfave/cli#ExitCoder
  • or we could fix it at a level "beneath" the cli framework by checking all the errors ourselves and exiting accordingly.

@cblecker cblecker referenced a pull request that will close this issue May 15, 2019

Open

Handle exit code on err #99

@cblecker

This comment has been minimized.

Copy link
Author

commented May 15, 2019

I believe #99 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.