Unable to Stop 'New Version' Warning from Displaying - Breaking Scripts🐛
The cloudflared Linux binary forces warning lines to the screen using what appear to be non-standard methods (writing directly to tty maybe) and thus, it cannot be stopped from displaying, which breaks scripts that try to parse the output for further action.
To Reproduce
# cloudflared tunnel list | grep -A1 ID | grep -v ID | wc -l
expected output should be just a number, like 1, or 2, etc.
however, if the cloudflared agent is out of date, this is the output:
2022-09-22T15:13:46Z WRN Your version 2022.9.0 is outdated. We recommend upgrading it to 2022.9.1
1
Expected behavior The WRN error should not be forced to tty, or there should be a "--quiet" option to stop all warning/error output.
Environment and versions
- OS: Ubuntu Linux
- Architecture: AMD
- Version: 2022.9.0
You can disable the auto-update check during the cloudflared tunnel list by running with cloudflared tunnel --no-autoupdate list.
I agree though that this update message shouldn't trigger during basic API operations and only when running a tunnel. I'll try and see if we can disable it by default for anything besides running a tunnel.
Hi, that doesn't work:
root@cftunnel1:/var/prtg/scripts# cloudflared tunnel --no-autoupdate list | grep -A1 ID | grep -v ID | wc -l
2022-09-22T18:18:09Z WRN Your version 2022.9.0 is outdated. We recommend upgrading it to 2022.9.1
1
neither does this:
root@cftunnel1:/var/prtg/scripts# cloudflared --no-autoupdate tunnel list | grep -A1 ID | grep -v ID | wc -l 2022-09-22T18:19:07Z WRN Your version 2022.9.0 is outdated. We recommend upgrading it to 2022.9.1 1
I'm running the version from the official Ubuntu 22.04 repos, fwiw.
I see, that's a different check from tunnel run. Currently there is no way to omit that check via a flag. As I mentioned though, I will see if we can introduce one.
Thanks, I appreciate it.
As an aside, I love all the power and metrics cloudflared provides. It makes monitoring for various issues really, really easy - aside from making the tunnels themselves brain-dead simple.
I just worked around the problem for now by grabbing/installing the 2022.9.1 deb manually.
The upgrade message is printed on stderr, so you can ignore it by adding 2> /dev/null to your cloudflared invocation.
You should look into using -o to switch output to json or yaml if you want to automate cloudflared. Better yet, consider using the API directly.
Hi, I tried 2> /dev/null , which is standard bash ops. It doesn't filter it, thus why I think they're writing to the tty directly.
As far as json, etc - this is for my homelab, so I'd rather not invest that much time when about 10 lines of bash accomplish what I need.
cloudflared tunnel list -o yaml 2> /dev/null | fgrep -- '- id:' | cut -c 7-
works for me to list IDs of my tunnels.
I upgraded manually, but if it pops up again, I'll be sure to try this. I appreciate the extra effort you put in to find a command chain that works!